summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-04-29 16:08:08 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-04-29 16:08:08 -0400
commit6c49ae7ec68c3b650370dc3838f356d94db175f9 (patch)
tree493c405b7cef1bb7c061aa70c9733bce74dbe03e
parent785c64fc6b6b6d6fd557a383890b02f79f9fe009 (diff)
downloadtor-6c49ae7ec68c3b650370dc3838f356d94db175f9.tar.xz
tor-6c49ae7ec68c3b650370dc3838f356d94db175f9.zip
Fix Windows Rust cross-compilation.meson
-rw-r--r--meson_options.txt2
-rw-r--r--src/or/meson.build2
-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
6 files changed, 34 insertions, 14 deletions
diff --git a/meson_options.txt b/meson_options.txt
index f5558de36..a8e9ab5fe 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,4 @@
-option('chost', type: 'string', value: '', description: 'host triple, auto-detect if empty')
+option('target', type: 'string', value: '', description: 'target triple, auto-detect if empty')
option('manpages', type: 'boolean', value: false, description: 'make manpages')
diff --git a/src/or/meson.build b/src/or/meson.build
index 7f0371650..5e8bb12ab 100644
--- a/src/or/meson.build
+++ b/src/or/meson.build
@@ -108,5 +108,5 @@ if use_rust
endif
tor_ldadd = [libtor, libor, libor_ctime, libor_crypto, libkeccak_tiny, libdonna, libor_event, libor_trunnel]
-executable('tor', 'tor_main.c', link_with: tor_ldadd, dependencies: tor_deps)
+executable('tor', 'tor_main.c', link_with: tor_ldadd, dependencies: tor_deps, install: true)
shared_module('tor', build_by_default: true, link_whole: tor_ldadd, dependencies: tor_deps)
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)