forked from codeforboston/anypia-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_buildscripts.sh
executable file
·120 lines (101 loc) · 6.98 KB
/
generate_buildscripts.sh
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
120
# this script requires yq and mac? sed / pip3 install yq
for i in `yq '.matrix.include[] | .name' .travis.yml | tr -d '"'`
do
filename="./installbuild-$i"
buildfilename="./onlybuild-$i"
# write the pre-script case-by-case
if test "$i" = 'windows'; then
extension="bat"
echo ":: ** This file was automatically generated by generate_buildscripts.sh **" > "$filename.$extension"
echo "SET MSBUILD_PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" >> "$filename.$extension"
echo "SET PATH=%PATH%;%MSBUILD_PATH%" >> "$filename.$extension"
cat "$filename.$extension" > "$buildfilename.$extension"
echo "choco install curl" >> "$filename.$extension"
echo "choco install 7zip" >> "$filename.$extension"
elif test "$i" = 'emscripten-anypiab-windows'; then
extension="bat"
echo ":: ** This file was automatically generated by generate_buildscripts.sh **" > "$filename.$extension"
echo "SET MSBUILD_PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;C:\Program Files\CMake\bin" >> "$filename.$extension"
echo "SET PATH=%PATH%;%MSBUILD_PATH%" >> "$filename.$extension"
cat "$filename.$extension" > "$buildfilename.$extension"
echo "choco install curl" >> "$filename.$extension"
echo "choco install 7zip" >> "$filename.$extension"
echo "choco install cmake" >> "$filename.$extension"
elif test "$i" = 'mac-anypiab'; then
extension="sh"
echo "# ** This file was automatically generated by generate_buildscripts.sh **" > "$filename.$extension"
echo "brew install " `yq -c --raw-output ".matrix.include[] | select(.name == \"mac-anypiab\") | .addons.homebrew.packages | @sh" .travis.yml | tr -d "\'"` >> "$filename.$extension"
echo "" > "$buildfilename.$extension"
elif test "$i" = 'emscripten-anypiab-mac'; then
extension="sh"
echo "# ** This file was automatically generated by generate_buildscripts.sh **" > "$filename.$extension"
echo "brew install " `yq -c --raw-output ".matrix.include[] | select(.name == \"emscripten-anypiab-mac\") | .addons.homebrew.packages | @sh" .travis.yml | tr -d "\'"` >> "$filename.$extension"
echo "" > "$buildfilename.$extension"
elif test "$i" = 'linux-anypiab'; then
extension="sh"
echo "# ** This file was automatically generated by generate_buildscripts.sh **" > "$filename.$extension"
echo "apt install " `yq -c --raw-output ".matrix.include[] | select(.name == \"linux-anypiab\") | .addons.apt.packages | @sh" .travis.yml` >> "$filename.$extension"
echo "" > "$buildfilename.$extension"
else
extension="sh"
echo "# ** This file was automatically generated by generate_buildscripts.sh **" > "$filename.$extension"
echo "" >> "$filename.$extension"
echo "" > "$buildfilename.$extension"
fi
# write the rest of the script
yq -c --raw-output ".matrix.include[] | select(.name == \"$i\") | .script[]" .travis.yml >> "$filename.$extension"
# write the rest of the script for the "only build" script
yq -c --raw-output ".matrix.include[] | select(.name == \"$i\") | .script[]" .travis.yml >> "$buildfilename.$extension"
# make modifications for batch files from the travis-ci environment
if test "$i" = 'windows'; then
# If you don't use call, the batch file stops after the other batch file.
sed 's/\.\/bootstrap.bat/call bootstrap.bat/g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
# do not run bootstrap on only-build
sed 's/\.\/bootstrap.bat//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
elif test "$i" = 'emscripten-anypiab-windows'; then
# If you don't use call, the batch file stops after the other batch file.
sed 's/\.\/bootstrap.bat/call bootstrap.bat/g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
# If you don't use call, the batch file stops after the other batch file.
sed 's/\.\/emsdk.bat/call emsdk.bat/g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
#emsdk wipes out our MSBUILD_PATH from PATH
sed 's/export PATH=$MSBUILD_PATH:$PATH/SET PATH=%PATH%;%MSBUILD_PATH%/g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
#fix boost paths
sed 's/export BOOST_INCL="`pwd`"/SET BOOST_INCL="%cd%"/g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
sed 's/export BOOST_LIB="`pwd`\\stage\\lib"/SET BOOST_LIB="%cd%\\stage\\lib"/g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
#fix emcmake
sed 's/..\/..\/emsdk\/upstream\/emscripten\/emcmake cmake -DBOOST_ROOT=$BOOST_INCL -DBOOST_LIBRARYDIR=$BOOST_LIB -G "NMake Makefiles" ../call emcmake cmake -DBOOST_ROOT=%BOOST_INCL% -DBOOST_LIBRARYDIR=%BOOST_LIB% -G "NMake Makefiles" ../g' "$filename.$extension" > "$filename.$extension.tmp"
mv "$filename.$extension.tmp" "$filename.$extension"
# SPECIAL FOR ONLY-BUILD
# do not clone emsdk on only-build
sed 's/git clone.*//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
# do not run bootstrap on only-build
sed 's/\.\/bootstrap.bat//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
# do not run emsdk on only-build
sed 's/\.\/emsdk.bat/call emsdk_env.bat/g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
# do not run choco on only-build
sed 's/choco.*//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
# do not run curl on only-build
sed 's/curl.*//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
# do not run 7z on only-build
sed 's/7z.*//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
fi
# do not run b2 for boost on only-build on any version
sed 's/\.\/b2.*//g' "$buildfilename.$extension" > "$buildfilename.$extension.tmp"
mv "$buildfilename.$extension.tmp" "$buildfilename.$extension"
# make executable
chmod +x "$filename.$extension"
chmod +x "$buildfilename.$extension"
done