-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·119 lines (105 loc) · 3.15 KB
/
build.sh
File metadata and controls
executable file
·119 lines (105 loc) · 3.15 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
LUAU_SOURCES="dependencies/Luau/Analysis/src/*.cpp dependencies/Luau/Ast/src/*.cpp dependencies/Luau/Config/src/*.cpp dependencies/Luau/VM/src/*.cpp"
LUAU_INCLUDE="-Idependencies/Luau/Analysis/include -Idependencies/Luau/Ast/include -Idependencies/Luau/Common/include -Idependencies/Luau/Config/include -Idependencies/Luau/VM/src -Idependencies/Luau/VM/include"
LUAU_SOURCES_BUILD=$(echo $LUAU_SOURCES | sed 's/dependencies\//..\/..\/..\/dependencies\//g')
LUAU_INCLUDE_BUILD=$(echo $LUAU_INCLUDE | sed 's/dependencies\//..\/..\/..\/dependencies\//g')
PLATFORM=linux
RELEASE_FLAGS=
STATIC_FLAGS=-static
ASAN_FLAGS=
TEST_DEFINES=
while [[ $# -gt 0 ]]; do
case $1 in
linux)
PLATFORM=linux
shift
;;
windows)
PLATFORM=windows
shift
;;
--release)
RELEASE_FLAGS=-O2
shift
;;
--nostatic)
STATIC_FLAGS=
shift
;;
--test)
TEST=true
shift
;;
--failtests)
TEST_DEFINES=-DFAILTESTS
shift
;;
--asan)
ASAN_FLAGS=-fsanitize=address
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
if [[ $TEST ]]; then
outname=test-luau-format
else
outname=luau-format
fi
outfile=build/$outname
if [[ "$PLATFORM" == "linux" ]]; then
compiler=g++
builddir=build/linux
elif [[ "$PLATFORM" == "windows" ]]; then
compiler=x86_64-w64-mingw32-g++-posix
if ! command -v $compiler >/dev/null 2>&1; then
compiler="x86_64-w64-mingw32-g++"
fi
outfile=$outfile.exe
builddir=build/windows
else
echo "unknown platform"
exit 1
fi
if [ ! -d "build" ]; then
mkdir build
fi
if [ ! -d "$builddir" ]; then
mkdir $builddir
fi
luaubuilddir=$builddir/Luau
if [ ! -d "$luaubuilddir" ]; then
mkdir $luaubuilddir
cd $luaubuilddir
echo "building luau..."
$compiler -std=c++17 -g -O2 -c $LUAU_SOURCES_BUILD $LUAU_INCLUDE_BUILD
ar rcs libluau.a *.o
echo "luau built!"
cd ../../..
fi
luauformatbuilddir=$builddir/luau-format
if [ -d $luauformatbuilddir ]; then
rm -r $luauformatbuilddir
fi
mkdir $luauformatbuilddir
echo "building luau-format..."
pushd $luauformatbuilddir
$compiler -std=c++17 -g -Wall $RELEASE_FLAGS $ASAN_FLAGS -c ../../../src/* -I../../../include $LUAU_INCLUDE_BUILD -L../Luau -lluau
ar rcs libluau-format.a *.o
popd
echo "luau-format built"
if [[ $TEST ]]; then
echo "building test-luau-format..."
if [[ ! $TEST_DEFINES = "" ]]; then
echo "NOTE: tests will fail due to --failtests being passed"
fi
$compiler -std=c++17 $ASAN_FLAGS $STATIC_FLAGS -o $outfile -g -Wall tests/* -Itests -Iinclude $LUAU_INCLUDE $TEST_DEFINES -L$luauformatbuilddir -lluau-format -L$luaubuilddir -lluau
echo "tests built to $outfile"
exit
fi
echo "buildling cli..."
$compiler -std=c++17 -g -Wall $RELEASE_FLAGS $ASAN_FLAGS $STATIC_FLAGS -o $outfile main.cpp -Iinclude $LUAU_INCLUDE -L$luauformatbuilddir -lluau-format -L$luaubuilddir -lluau
echo "cli built to $outfile"