2323 exit 1
2424fi
2525
26+ libpath=" target/$profile /$libname .$libsuffix "
27+
2628checksum () {
2729 # Determine whether to use md5sum or md5
2830 if command -v md5sum > /dev/null 2>&1 ; then
@@ -36,20 +38,22 @@ checksum() {
3638
3739 echo " $features_arg " | $hash_cmd | awk ' {print $1}'
3840
39- find Cargo.toml Cargo.lock native-engine target/ $profile / $libname . " $libsuffix " | \
41+ find Cargo.toml Cargo.lock native-engine " $libpath " | \
4042 xargs $hash_cmd 2>&1 | \
4143 sort -k1 | \
4244 $hash_cmd
4345}
4446
4547checksum_cache_file=" ./.build-checksum_$profile -" $libsuffix " .cache"
46- old_checksum=" $( cat " $checksum_cache_file " 2>&1 || true) "
47- new_checksum=" $( checksum) "
48+ if [ -f " $libpath " ]; then
49+ old_checksum=" $( cat " $checksum_cache_file " 2>&1 || true) "
50+ new_checksum=" $( checksum) "
4851
49- echo -e " old build-checksum: \n$old_checksum \n========"
50- echo -e " new build-checksum: \n$new_checksum \n========"
52+ echo -e " old build-checksum: \n$old_checksum \n========"
53+ echo -e " new build-checksum: \n$new_checksum \n========"
54+ fi
5155
52- if [ " $new_checksum " != " $old_checksum " ]; then
56+ if [ ! -f " $libpath " ] || [ " $new_checksum " != " $old_checksum " ]; then
5357 export RUSTFLAGS=${RUSTFLAGS:- " -C target-cpu=native" }
5458 echo " Running cargo fix..."
5559 cargo fix --all --allow-dirty --allow-staged --allow-no-vcs
6569
6670mkdir -p native-engine/_build/$profile
6771rm -rf native-engine/_build/$profile /*
68- cp target/ $profile / $libname . " $libsuffix " native-engine/_build/$profile
72+ cp " $libpath " native-engine/_build/$profile
6973
7074new_checksum=" $( checksum) "
7175echo " build-checksum updated: $new_checksum "
0 commit comments