blob: 0d418d1852ba293c03ad1f2673ba756fe6d60d22 (
plain)
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
|
#!/bin/bash
########## Helper functions ##########
# Message prefix
_msg_prefix () {
echo "[$(date +%H:%M:%S)]$(hostname):"
}
# Report a message
msg () {
echo "$(_msg_prefix):MSG: $*"
}
# Report an error and terminate the script
err () {
echo "$(_msg_prefix):ERR: $*"
exit 1
}
# Verbose-debug message
dbg () {
# Don't print debug message if CI_DEBUG is 'false'.
if [ "$CI_DEBUG" = "false" ]; then
return
fi
echo "$(_msg_prefix):DBG: $*"
}
# run [command] [args ...]
run () {
dbg Running : "$@"
"$@"
}
# 'safe [command]' executes [command] and terminates if the exit code is
# nonzero. An alternative to "set -e"
safe () {
run "$@"
local err_num=$?
if [ $err_num -ne 0 ]; then
err "Error [$err_num] while doing [$*]"
fi
}
# Suggested number of parallel tasks
njobs () {
local cpus=$(nproc)
if [ $cpus -le 1 ]; then
echo 1
else
echo $(($cpus - 1))
fi
}
########## LuaJIT build and test ##########
# Build and install
safe make CCDEBUG="-DUSE_LUA_ASSERT" PREFIX="${WORKSPACE}"/install install -j "$(njobs)"
safe export LUA_PATH="$(ls -d "${WORKSPACE}"/install/share/luajit*)/?.lua;;"
# Run a simple test
safe ./src/luajit -jdump -e "x=0; for i=1,100 do x=x+i end; print(x)"
# Additional internal test which doesn't exist everywhere
if make -n test > /dev/null; then
safe make test
fi
|