@@ -19,16 +19,17 @@ ARG_FEATURES=""
1919run_tests=true
2020
2121usage () {
22-     echo  " Usage: ` basename " $0 " ` " 
22+     echo  " Usage: ` basename " $0 " ` t TRIPLET] [- T] dest-dir" 
2323    echo 
2424    echo  " Options:" 
2525    echo  "   -h          This help text" 
2626    echo  "   -f FEATURES Enable specified features (comma separated if more than one)" 
27+     echo  "   -t TRIPLET  Target triplet to build for, defaults to host triplet" 
2728    echo  "   -T          Skip checks after building" 
2829    exit  $1 
2930}
3031
31- while  getopts  f:hT  flag
32+ while  getopts  f:ht:T  flag
3233do 
3334    case  " ${flag} " in 
3435        f)
3940        h)
4041            usage 0
4142            ;;
43+         t)
44+             target=${OPTARG} 
45+             shift 
46+             shift 
47+             ;;
4248        T)
4349            run_tests=false
4450            shift 
5965mkdir -v -p " $destdir /include/datadog" " $destdir /lib/pkgconfig" " $destdir /cmake" 
6066
6167version=$( awk -F\"  ' $1 ~ /^version/ { print $2 }' <  profiling-ffi/Cargo.toml) 
62- target=" $( rustc -vV |  awk ' /^host:/ { print $2 }' ) " 
68+ if  [ -z  ${target+x}  ];  then 
69+     target=" $( rustc -vV |  awk ' /^host:/ { print $2 }' ) " 
70+ fi 
6371shared_library_suffix=" .so" 
6472static_library_suffix=" .a" 
6573library_prefix=" lib" 
@@ -77,7 +85,7 @@ symbolizer=0
7785#  provided. At least on Alpine, libgcc_s may not even exist in the users'
7886#  images, so -static-libgcc is recommended there.
7987case  " $target " in 
80-      " x86_64-alpine-linux-musl" " aarch64-alpine-linux-musl" 
88+   " x86_64-alpine-linux-musl" " aarch64-alpine-linux-musl " | " i686 -alpine-linux-musl" 
8189        expected_native_static_libs="  -lssp_nonshared -lgcc_s -lc" 
8290        native_static_libs="  -lssp_nonshared -lc" 
8391        #  on alpine musl, Rust adds some weird runpath to cdylibs
@@ -94,7 +102,7 @@ case "$target" in
94102        fix_macos_rpath=1
95103        ;;
96104
97-     " x86_64-unknown-linux-gnu" " aarch64-unknown-linux-gnu" 
105+     " x86_64-unknown-linux-gnu" " aarch64-unknown-linux-gnu" | " i686-unknown-linux-gnu " 
98106        expected_native_static_libs="  -ldl -lrt -lpthread -lgcc_s -lc -lm -lrt -lpthread -lutil -ldl -lutil" 
99107        native_static_libs="  -ldl -lrt -lpthread -lc -lm -lrt -lpthread -lutil -ldl -lutil" 
100108        symbolizer=1
@@ -246,7 +254,7 @@ if [[ "$symbolizer" -eq 1 ]]; then
246254    #  Copy the blazesym header separately because The blazesym header isn't auto-generated by cbindgen
247255    #  so we don't need to remove definitions that are already present in `common.h` using dedup_headers
248256    cp " $CARGO_TARGET_DIR /include/datadog/blazesym.h" " $destdir /include/datadog/blazesym.h" 
249- fi   
257+ fi 
250258
251259
252260#  Don't build the crashtracker on windows
@@ -260,7 +268,13 @@ if [[ "$target" != "x86_64-pc-windows-msvc" ]]; then
260268    [ -d  $CRASHTRACKER_BUILD_DIR  ] &&  rm -r $CRASHTRACKER_BUILD_DIR 
261269    mkdir -p $CRASHTRACKER_BUILD_DIR 
262270    cd  $CRASHTRACKER_BUILD_DIR 
263-     cmake -S $CRASHTRACKER_SRC_DIR  -DDatadog_ROOT=$ABS_DESTDIR 
271+ 
272+     if  [[ " $target " =~  ^i686 ]];  then 
273+         CFLAGS=-m32 CXXFLAGS=-m32 cmake -S $CRASHTRACKER_SRC_DIR  -DDatadog_ROOT=$ABS_DESTDIR 
274+     else 
275+         cmake -S $CRASHTRACKER_SRC_DIR  -DDatadog_ROOT=$ABS_DESTDIR 
276+     fi 
277+ 
264278    cmake --build . 
265279    mkdir -p $ABS_DESTDIR /bin
266280    cp libdatadog-crashtracking-receiver $ABS_DESTDIR /bin
0 commit comments