new file mode 100644
@@ -0,0 +1,2 @@
+[workspace]
+members = []
@@ -446,6 +446,8 @@ meson=""
ninja=""
skip_meson=no
gettext=""
+with_rust="auto"
+with_rust_target=""
bogus_os="no"
malloc_trim="auto"
@@ -1519,6 +1521,12 @@ for opt do
;;
--disable-libdaxctl) libdaxctl=no
;;
+ --with-rust) with_rust=yes
+ ;;
+ --without-rust) with_rust=no
+ ;;
+ --with-rust-target=*) with_rust_target="$optarg"
+ ;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
@@ -1666,6 +1674,8 @@ Advanced options (experts only):
--extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
--cross-cc-ARCH=CC use compiler when building ARCH guest test cases
--cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
+ --with-rust enable Rust compilation
+ --with-rust-target=RTT use the given Rust target triple
--make=MAKE use specified make [$make]
--python=PYTHON use specified python [$python]
--sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
@@ -1918,6 +1928,10 @@ if test -z "$ninja"; then
done
fi
+if test "$with_rust" = auto && has cargo; then
+ with_rust=yes
+fi
+
# Check that the C compiler works. Doing this here before testing
# the host CPU ensures that we had a valid CC to autodetect the
# $cpu var (and we should bail right here if that's not the case).
@@ -7046,6 +7060,10 @@ fi
if test "$safe_stack" = "yes"; then
echo "CONFIG_SAFESTACK=y" >> $config_host_mak
fi
+if test "$with_rust" = "yes" ; then
+ echo "CONFIG_WITH_RUST=y" >> $config_host_mak
+ echo "CONFIG_WITH_RUST_TARGET=$with_rust_target" >> $config_host_mak
+fi
# If we're using a separate build tree, set it up now.
# DIRS are directories which we simply mkdir in the build tree;
@@ -73,6 +73,28 @@ if cpu in ['x86', 'x86_64']
}
endif
+with_rust = 'CONFIG_WITH_RUST' in config_host
+cargo = find_program('cargo', required: with_rust)
+
+if with_rust
+ rs_target_triple = config_host['CONFIG_WITH_RUST_TARGET']
+ if meson.is_cross_build()
+ # more default target mappings may be added over time
+ if rs_target_triple == '' and targetos == 'windows'
+ rs_target_triple = host_machine.cpu() + '-pc-windows-gnu'
+ endif
+ if rs_target_triple == ''
+ error('cross-compiling, but no Rust target-triple defined.')
+ endif
+ endif
+endif
+
+if get_option('optimization') in ['0', '1', 'g']
+ rs_build_type = 'debug'
+else
+ rs_build_type = 'release'
+endif
+
##################
# Compiler flags #
##################
@@ -1770,6 +1792,7 @@ endif
if targetos == 'darwin'
summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
endif
+summary_info += {'Rust support': with_rust}
summary_info += {'ARFLAGS': config_host['ARFLAGS']}
summary_info += {'CFLAGS': ' '.join(get_option('c_args')
+ ['-O' + get_option('optimization')]