Skip to content

Commit 7b6d3bc

Browse files
committed
rust/Makefile: add RUSTC and RUSTDOC to CARGO_ENV
And consistently use the CARGO_ENV for all cargo calls. This allows a user to point to rust binaries that are not on their path just during ./configure, for example: PATH=/usr/lib/rust-1.89/bin:$PATH ./configure ... The full path to rustc and rustdoc will now be used, as discovered in the PATH without the user have to carry the path over to the "make" command. This was already done for cargo. Related to ticket: OISF#8381 (cherry picked from commit d5f6df0)
1 parent 64f4c02 commit 7b6d3bc

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

rust/Makefile.am

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ if RUST_CROSS_COMPILE
4747
RUST_TARGET = --target $(host_triplet)
4848
endif
4949

50+
CARGO_ENV = RUSTC="$(RUSTC)" RUSTDOC="$(RUSTDOC)"
51+
5052
if HAVE_CYGPATH
51-
CARGO_ENV = @rustup_home@ \
53+
CARGO_ENV += @rustup_home@ \
5254
CARGO_HOME="$(CARGO_HOME)" \
5355
CARGO_TARGET_DIR="$(e_rustdir)/target" \
5456
SURICATA_LUA_SYS_HEADER_DST="$(e_rustdir)/gen"
5557
else
56-
CARGO_ENV = @rustup_home@ \
58+
CARGO_ENV += @rustup_home@ \
5759
CARGO_HOME="$(CARGO_HOME)" \
5860
CARGO_TARGET_DIR="$(abs_top_builddir)/rust/target" \
5961
SURICATA_LUA_SYS_HEADER_DST="$(abs_top_builddir)/rust/gen"
@@ -124,7 +126,7 @@ endif
124126

125127
check:
126128
cd $(abs_top_srcdir)/rust && \
127-
$(CARGO_ENV) RUSTDOC=$(RUSTDOC) \
129+
$(CARGO_ENV) \
128130
$(CARGO) test --all $(RELEASE) --features "$(RUST_FEATURES)"
129131
$(MAKE) check-bindgen-bindings
130132

@@ -172,7 +174,7 @@ endif
172174
if HAVE_CBINDGEN
173175
gen/rust-bindings.h: $(RUST_SURICATA_LIB) cbindgen.toml
174176
cd $(abs_top_srcdir)/rust && \
175-
CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
177+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
176178
--quiet --verify --output $(abs_top_builddir)/rust/gen/rust-bindings.h || true
177179
else
178180
gen/rust-bindings.h:
@@ -181,18 +183,18 @@ endif
181183
if HAVE_CBINDGEN
182184
gen/htp/htp_rs.h: $(RUST_SURICATA_LIB) htp/cbindgen.toml
183185
cd $(abs_top_srcdir)/rust/htp && \
184-
CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/htp/cbindgen.toml \
186+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/htp/cbindgen.toml \
185187
--quiet --verify --output $(abs_top_builddir)/rust/gen/htp/htp_rs.h || true
186188
else
187189
gen/htp/htp_rs.h:
188190
endif
189191

190192
doc:
191-
CARGO_HOME=$(CARGO_HOME) RUSTDOC=$(RUSTDOC) $(CARGO) doc --all-features --no-deps
193+
$(CARGO_ENV) $(CARGO) doc --all-features --no-deps
192194

193195
if HAVE_CBINDGEN
194196
dist/rust-bindings.h:
195-
CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
197+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
196198
--quiet --output $(abs_top_builddir)/rust/dist/rust-bindings.h
197199
else
198200
dist/rust-bindings.h:
@@ -201,7 +203,7 @@ endif
201203
if HAVE_CBINDGEN
202204
dist/htp/htp_rs.h:
203205
cd $(abs_top_srcdir)/rust/htp && \
204-
CARGO=$(CARGO) $(CBINDGEN) --config cbindgen.toml \
206+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config cbindgen.toml \
205207
--quiet --output $(abs_top_builddir)/rust/dist/htp/htp_rs.h
206208
else
207209
dist/htp/htp_rs.h:
@@ -210,5 +212,5 @@ endif
210212
Cargo.toml: Cargo.toml.in
211213

212214
update-lock: Cargo.toml
213-
$(CARGO) update
215+
$(CARGO_ENV) $(CARGO) update
214216
mv Cargo.lock Cargo.lock.in

0 commit comments

Comments
 (0)