1
1
#! /bin/bash
2
2
set -ueo pipefail
3
3
4
- # Top-level test runner. Usage is "run.sh" to run tests in compile-only mode,
5
- # or "run.sh <runwasi>" where <runwasi> is a WASI-capable runtime to run the
6
- # tests in full compile and execute mode.
4
+ # Top-level test runner. Usage is "run.sh <path to wasi-sdk>" to run tests
5
+ # in compile-only mode, or "run.sh <path to wasi-sdk> <runwasi>" where
6
+ # <runwasi> is a WASI-capable runtime to run the tests in full compile and
7
+ # execute mode.
7
8
#
8
9
# By default this script will look for `clang` and `clang++` in $PATH and
9
10
# assume that they are correctly configured with the sysroot in the default
@@ -12,10 +13,16 @@ set -ueo pipefail
12
13
# export CXX="<wasi-sdk>/bin/clang++ --sysroot <wasi-sdk>/share/wasi-sysroot"
13
14
# export CC="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
14
15
#
16
+ if [ $# -lt 1 ]; then
17
+ echo " Path to WASI SDK is required"
18
+ exit 1
19
+ fi
20
+
21
+ wasi_sdk=" $1 "
15
22
16
23
# Determine the wasm runtime to use, if one is provided.
17
- if [ $# -gt 0 ]; then
18
- runwasi=" $1 "
24
+ if [ $# -gt 1 ]; then
25
+ runwasi=" $2 "
19
26
else
20
27
runwasi=" "
21
28
fi
@@ -26,6 +33,7 @@ CXX=${CXX:=clang++}
26
33
27
34
echo $CC
28
35
echo $CXX
36
+ echo " SDK: $wasi_sdk "
29
37
30
38
cd $testdir /compile-only
31
39
for options in -O0 -O2 " -O2 -flto" ; do
@@ -54,3 +62,27 @@ for options in -O0 -O2 "-O2 -flto"; do
54
62
done
55
63
done
56
64
cd - > /dev/null
65
+
66
+ # Test cmake build system for wasi-sdk
67
+ test_cmake () {
68
+ local option
69
+ for option in Debug Release; do
70
+ rm -rf " $testdir /cmake/build/$option "
71
+ mkdir -p " $testdir /cmake/build/$option "
72
+ cd " $testdir /cmake/build/$option "
73
+ cmake \
74
+ -G " Unix Makefiles" \
75
+ -DCMAKE_BUILD_TYPE=" $option " \
76
+ -DRUNWASI=" $runwasi " \
77
+ -DWASI_SDK_PREFIX=" $wasi_sdk " \
78
+ -DCMAKE_TOOLCHAIN_FILE=" $wasi_sdk /share/cmake/wasi-sdk.cmake" \
79
+ ../..
80
+ make
81
+ if [[ -n " $runwasi " ]]; then
82
+ ctest --output-on-failure
83
+ fi
84
+ cd - > /dev/null
85
+ done
86
+ }
87
+
88
+ test_cmake
0 commit comments