summaryrefslogtreecommitdiff
path: root/src/rust
diff options
context:
space:
mode:
Diffstat (limited to 'src/rust')
-rw-r--r--src/rust/.cargo/meson.build8
-rw-r--r--src/rust/meson.build16
-rwxr-xr-xsrc/rust/tor_rust/build.sh10
-rw-r--r--src/rust/tor_rust/meson.build10
4 files changed, 32 insertions, 12 deletions
diff --git a/src/rust/.cargo/meson.build b/src/rust/.cargo/meson.build
index 378aac4dc..de931c014 100644
--- a/src/rust/.cargo/meson.build
+++ b/src/rust/.cargo/meson.build
@@ -1,14 +1,14 @@
cargo_config_conf = configuration_data()
cargo_args = []
-chost = get_option('chost')
-if chost == ''
+target = get_option('target')
+if target == ''
if meson.is_cross_build()
- error('must specify chost for rust cross-compiling')
+ error('must specify target for rust cross-compiling')
endif
cargo_config_conf.set('target', '')
else
- cargo_config_conf.set('target', 'target = "' + chost + '"')
+ cargo_config_conf.set('target', 'target = "' + target + '"')
endif
if get_option('cargo_online')
diff --git a/src/rust/meson.build b/src/rust/meson.build
index 47db35e7e..51775ab2a 100644
--- a/src/rust/meson.build
+++ b/src/rust/meson.build
@@ -1,7 +1,21 @@
subdir('.cargo')
subdir('tor_rust')
-tor_rust = declare_dependency(sources: [libtor_rust, 'asan.c'])
+tor_rust_deps = []
+
+# manually copied from rustc --print native-static-libs
+if host_machine.system() == 'windows'
+ foreach lib : ['advapi32', 'ws2_32', 'userenv', 'shell32', 'gcc_eh', 'pthread']
+ tor_rust_deps += cc.find_library(lib)
+ endforeach
+endif
+
+tor_rust = declare_dependency(
+ # work around meson declare_dependency dependencies bug
+ link_args: ['-Wl,--whole-archive', libtor_rust.full_path(), '-Wl,--no-whole-archive'],
+ sources: [libtor_rust, 'asan.c'],
+ dependencies: tor_rust_deps
+)
cargo_test_args = ['test', '--all', '--all-features',
'--manifest-path', meson.source_root() + '/src/rust/Cargo.toml']
diff --git a/src/rust/tor_rust/build.sh b/src/rust/tor_rust/build.sh
index eba496286..5ad75c890 100755
--- a/src/rust/tor_rust/build.sh
+++ b/src/rust/tor_rust/build.sh
@@ -2,7 +2,7 @@
cargo_args=
-chost="$1"
+target="$1"
build_type="$2"
cargo="$3"
manifest="$(realpath "$4")"
@@ -20,9 +20,9 @@ fi
CARGO_OUTPUT_DIR="$abs_top_builddir/src/rust/target"
-if [ -n "$chost" ]; then
- cargo_args="$cargo_args --target $chost"
- cargo_output_dir="$CARGO_OUTPUT_DIR/$chost/$cargo_build_type"
+if [ -n "$target" ]; then
+ cargo_args="$cargo_args --target $target"
+ cargo_output_dir="$CARGO_OUTPUT_DIR/$target/$cargo_build_type"
else
cargo_output_dir="$CARGO_OUTPUT_DIR/$cargo_build_type"
fi
@@ -34,4 +34,4 @@ cd "$abs_top_builddir/src/rust/tor_rust"
"$cargo" build --manifest-path "$manifest" $cargo_args "$@"
)
-cp -p "$cargo_output_dir/libtor_rust.a" "$output_lib"
+cp -p "$cargo_output_dir/${output_lib##*/}" "$output_lib"
diff --git a/src/rust/tor_rust/meson.build b/src/rust/tor_rust/meson.build
index b0e1a4971..9ca120939 100644
--- a/src/rust/tor_rust/meson.build
+++ b/src/rust/tor_rust/meson.build
@@ -1,13 +1,19 @@
+if host_machine.system() == 'windows'
+ libtor_rust_name = 'tor_rust.lib'
+else
+ libtor_rust_name = 'libtor_rust.a'
+endif
+
libtor_rust = custom_target(
'libtor_rust',
build_always: true,
command: [
files('build.sh'),
- get_option('chost'),
+ get_option('target'),
get_option('buildtype'),
cargo.path(),
'@INPUT@',
meson.build_root(),
'@OUTPUT@'],
input: 'Cargo.toml',
- output: 'libtor_rust.a')
+ output: libtor_rust_name)