-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·94 lines (71 loc) · 1.69 KB
/
build.sh
File metadata and controls
executable file
·94 lines (71 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
CC=gcc
mkdir -p dist
echo -n > dist/wasmu.h
function include {
(
echo "// $1"
echo
cat $1
echo
echo
) >> dist/wasmu.h
}
cp src/config.h dist/wasmu-config.h
tee -a dist/wasmu.h > /dev/null << EOF
#ifndef WASMU_H_
#define WASMU_H_
EOF
include src/config.h
include src/common.h
include src/opcodes.h
include src/declarations.h
include src/subjects.h
include src/contexts.h
include src/modules.h
include src/parser.h
include src/memory.h
include src/stacks.h
include src/functions.h
include src/maths.h
include src/interpreter.h
tee -a dist/wasmu.h > /dev/null << EOF
#endif
EOF
sed -i "s/\(^[a-zA-Z_][a-zA-Z0-9_]*.*(.*{\)/WASMU_FN_PREFIX \1/g" dist/wasmu.h
for testPath in test/*/; do
test=$(basename $testPath)
mkdir -p test/$test/build
DEBUG_FLAG=-DWASMU_DEBUG
if [ -f test/$test/no-debug ]; then
DEBUG_FLAG=
fi
$CC -Idist/ test/$test/$test.c $DEBUG_FLAG -DTEST_NAME=\"$test\" -o test/$test/build/$test
if [ -f test/$test/script.sh ]; then
chmod +x test/$test/script.sh
pushd test/$test
./script.sh
popd
fi
done
if [ "$1" == "--test" ]; then
allTestsPassed=true
for testPath in test/*/; do
test=$(basename $testPath)
test/$test/build/$test > test/$test/build/test.log
if [ $? == 0 ]; then
echo "Test passed: $test"
else
echo "Test failed: $test"
echo "---------"
cat test/$test/build/test.log
echo "---------"
allTestsPassed=false
fi
done
if [ $allTestsPassed == true ]; then
echo "All tests passed"
else
exit 1
fi
fi