Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/ci/ensure_deterministic_build.sh
1685 views
1
#!/bin/bash
2
3
# This script makes sure that the meta crate deterministically generate files
4
# with a high probability.
5
# The current directory must be set to the repository's root.
6
#
7
# We set SKIP_ISLE=1 to skip ISLE generation, because it depends on files
8
# in-tree (cranelift/codegen/.../*.isle) but these are not available when we
9
# switch to different working directories during this test.
10
11
set -e
12
13
BUILD_SCRIPT=$(find -wholename "./target/debug/build/cranelift-codegen-*/build-script-build")
14
15
# First, run the script to generate a reference comparison.
16
rm -rf /tmp/reference
17
mkdir /tmp/reference
18
SKIP_ISLE=1 OUT_DIR=/tmp/reference TARGET=x86_64 CARGO_PKG_VERSION=0.1.0 CARGO_MANIFEST_DIR=/tmp $BUILD_SCRIPT
19
20
# To make sure the build script doesn't depend on the current directory, we'll
21
# change the current working directory on every iteration. Make this easy to
22
# reproduce this locally by first copying the target/ directory into an initial
23
# temporary directory (and not move and lose the local clone's content).
24
rm -rf /tmp/src0
25
mkdir /tmp/src0
26
27
echo Copying target directory...
28
cp -r ./target /tmp/src0/target
29
cd /tmp/src0
30
echo "Done, starting loop."
31
32
# Then, repeatedly make sure that the output is the same.
33
for i in {1..20}
34
do
35
# Move to a different directory, as explained above.
36
rm -rf /tmp/src$i
37
mkdir /tmp/src$i
38
mv ./* /tmp/src$i
39
cd /tmp/src$i
40
41
rm -rf /tmp/try
42
mkdir /tmp/try
43
SKIP_ISLE=1 OUT_DIR=/tmp/try TARGET=x86_64 CARGO_PKG_VERSION=0.1.0 CARGO_MANIFEST_DIR=/tmp/src$i $BUILD_SCRIPT
44
diff -qr /tmp/reference /tmp/try
45
done
46
47