Skip to content

Commit a7c8efe

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 a7c8efe

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

rust/Makefile.am

Lines changed: 11 additions & 10 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,15 +126,14 @@ 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

131133
vendor:
132134
$(CARGO_ENV) $(CARGO) vendor
133135

134136
update-bindings:
135-
if HAVE_BINDGEN
136137
$(BINDGEN) \
137138
-o sys/src/sys.rs.tmp \
138139
--rust-target 1.68 \
@@ -172,7 +173,7 @@ endif
172173
if HAVE_CBINDGEN
173174
gen/rust-bindings.h: $(RUST_SURICATA_LIB) cbindgen.toml
174175
cd $(abs_top_srcdir)/rust && \
175-
CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
176+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
176177
--quiet --verify --output $(abs_top_builddir)/rust/gen/rust-bindings.h || true
177178
else
178179
gen/rust-bindings.h:
@@ -181,18 +182,18 @@ endif
181182
if HAVE_CBINDGEN
182183
gen/htp/htp_rs.h: $(RUST_SURICATA_LIB) htp/cbindgen.toml
183184
cd $(abs_top_srcdir)/rust/htp && \
184-
CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/htp/cbindgen.toml \
185+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/htp/cbindgen.toml \
185186
--quiet --verify --output $(abs_top_builddir)/rust/gen/htp/htp_rs.h || true
186187
else
187188
gen/htp/htp_rs.h:
188189
endif
189190

190191
doc:
191-
CARGO_HOME=$(CARGO_HOME) RUSTDOC=$(RUSTDOC) $(CARGO) doc --all-features --no-deps
192+
$(CARGO_ENV) $(CARGO) doc --all-features --no-deps
192193

193194
if HAVE_CBINDGEN
194195
dist/rust-bindings.h:
195-
CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
196+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config $(abs_top_srcdir)/rust/cbindgen.toml \
196197
--quiet --output $(abs_top_builddir)/rust/dist/rust-bindings.h
197198
else
198199
dist/rust-bindings.h:
@@ -201,7 +202,7 @@ endif
201202
if HAVE_CBINDGEN
202203
dist/htp/htp_rs.h:
203204
cd $(abs_top_srcdir)/rust/htp && \
204-
CARGO=$(CARGO) $(CBINDGEN) --config cbindgen.toml \
205+
$(CARGO_ENV) CARGO=$(CARGO) $(CBINDGEN) --config cbindgen.toml \
205206
--quiet --output $(abs_top_builddir)/rust/dist/htp/htp_rs.h
206207
else
207208
dist/htp/htp_rs.h:
@@ -210,5 +211,5 @@ endif
210211
Cargo.toml: Cargo.toml.in
211212

212213
update-lock: Cargo.toml
213-
$(CARGO) update
214+
$(CARGO_ENV) $(CARGO) update
214215
mv Cargo.lock Cargo.lock.in

0 commit comments

Comments
 (0)