Debian Codegraph @

dnsdist-rust-lib/rust/build_dnsdist_rust_library

raw
1 #!/bin/sh -e
2
3 export CARGO="${CARGO:-$_defaultCARGO}"
4
5 #echo "PWD=$PWD"
6 #echo "srcdir=$srcdir"
7 #echo "builddir=$builddir"
8 # cxx/cxxbridge generate the files lib.rs.h and cxx.h inside $CARGO_TARGET_DIR if it is set
9 # otherwise it uses target
10 #echo "CARGO_TARGET_DIR=${CARGO_TARGET_DIR}"
11 mytarget=${CARGO_TARGET_DIR-target}
12 #echo "mytarget=${mytarget}"
13
14 CARGO_PROFILE="release"
15 if [ -n "${CARGO_USE_DEV}" ]; then
16 CARGO_PROFILE="dev"
17 if [ -n "${CARGO_USE_CLIPPY}" ]; then
18 $CARGO clippy --manifest-path $srcdir/Cargo.toml
19 fi
20 fi
21
22 case "${CARGO_LTO_MODE:-unspecified}" in
23 "fat" | "thin")
24 CARGO_CONFIG="--config profile.${CARGO_PROFILE}.lto=\"${CARGO_LTO_MODE}\""
25 ;;
26 esac
27
28 # echo "RUSTFLAGS = ${RUSTFLAGS}"
29 # echo "CARGO_PROFILE = ${CARGO_PROFILE}"
30 # echo "CARGO_LTO_MODE = ${CARGO_LTO_MODE}"
31 # echo "CARGO_CONFIG = ${CARGO_CONFIG}"
32
33 $CARGO build --profile ${CARGO_PROFILE} ${CARGO_CONFIG} $RUST_TARGET --target-dir=$builddir/target --manifest-path $srcdir/Cargo.toml --locked
34
35 if [ -n "${CARGO_USE_DEV}" ]; then
36 cp -p target/$RUSTC_TARGET_ARCH/debug/libdnsdist_rust.a $builddir/dnsdist-rust-lib/rust/libdnsdist_rust.a
37 else
38 cp -p target/$RUSTC_TARGET_ARCH/release/libdnsdist_rust.a $builddir/dnsdist-rust-lib/rust/libdnsdist_rust.a
39 fi
40
41 cp -p $mytarget/$RUSTC_TARGET_ARCH/cxxbridge/dnsdist-rust/src/lib.rs.h $srcdir/lib.rs.h
42 cp -p $mytarget/$RUSTC_TARGET_ARCH/cxxbridge/dnsdist-rust/src/lib.rs.h $builddir/dnsdist-rust-lib/rust/lib.rs.h
43 cp -p $mytarget/$RUSTC_TARGET_ARCH/cxxbridge/rust/cxx.h $srcdir/cxx.h
44 cp -p $mytarget/$RUSTC_TARGET_ARCH/cxxbridge/rust/cxx.h $builddir/dnsdist-rust-lib/rust/cxx.h