option('clang-coverage-format', type: 'boolean', value: false, description: 'Whether to generate coverage data in clang format')
option('tls-gnutls', type: 'feature', value: 'auto', description: 'GnuTLS-based TLS')
option('man-pages', type: 'boolean', value: true, description: 'Generate man pages')
+option('rust-args', type: 'string', description: 'Rust compile arguments to use')
+option('rust-lto', type: 'boolean', value: true, description: 'Enable LTO for Rust according to b_lto, b_lto_mode settings')
mytarget=${CARGO_TARGET_DIR-target}
#echo "mytarget=${mytarget}"
-CARGO_PROFILE="--release"
+CARGO_PROFILE="release"
if [ -n "${CARGO_USE_DEV}" ]; then
- CARGO_PROFILE=""
+ CARGO_PROFILE="dev"
if [ -n "${CARGO_USE_CLIPPY}" ]; then
$CARGO clippy --manifest-path $srcdir/Cargo.toml
fi
fi
-$CARGO build ${CARGO_PROFILE} $RUST_TARGET --target-dir=$builddir/target --manifest-path $srcdir/Cargo.toml $features
+case "${CARGO_LTO_MODE:-unspecified}" in
+ "fat" | "thin")
+ CARGO_CONFIG="--config profile.${CARGO_PROFILE}.lto=\"${CARGO_LTO_MODE}\""
+ ;;
+esac
+
+# echo "RUSTFLAGS = ${RUSTFLAGS}"
+# echo "CARGO_PROFILE = ${CARGO_PROFILE}"
+# echo "CARGO_LTO_MODE = ${CARGO_LTO_MODE}"
+# echo "CARGO_CONFIG = ${CARGO_CONFIG}"
+
+$CARGO build --profile ${CARGO_PROFILE} ${CARGO_CONFIG} $RUST_TARGET --target-dir=$builddir/target --manifest-path $srcdir/Cargo.toml --locked $features
if [ -n "${CARGO_USE_DEV}" ]; then
cp -p target/$RUSTC_TARGET_ARCH/debug/librecrust.a $builddir/rec-rust-lib/rust/librecrust.a
env.set('features', '--features pkcs12')
endif
+opt_rust_args = get_option('rust-args')
+if opt_rust_args != ''
+ env.set('RUSTFLAGS', opt_rust_args)
+endif
+
+if get_option('rust-lto') and get_option('b_lto') and get_option('b_lto_mode') == 'default'
+ env.set('CARGO_LTO_MODE', 'fat')
+ summary('LTO', true, bool_yn: true, section: 'Rust')
+ summary('LTO mode', 'fat', section: 'Rust')
+elif get_option('rust-lto') and get_option('b_lto') and get_option('b_lto_mode') == 'thin'
+ env.set('CARGO_LTO_MODE', 'thin')
+ summary('LTO', true, bool_yn: true, section: 'Rust')
+ summary('LTO mode', 'thin', section: 'Rust')
+else
+ summary('LTO', false, bool_yn: true, section: 'Rust')
+endif
+
lib_recrust = custom_target('librecrust.a',
output: [outfile, 'cxx.h', 'lib.rs.h', 'misc.rs.h', 'web.rs.h'],
input: infile,