-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcejs_build
executable file
·144 lines (114 loc) · 3.04 KB
/
pcejs_build
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
set -e
set -u
declare -a ARCHS=("macplus" "ibmpc" "atarist")
pcejs_load_config () {
if [[ ! -f ./pcejs_build_conf.sh ]]; then
# no existing config file, copy from default
cp ./scripts/pcejs_build_conf_default.sh ./pcejs_build_conf.sh
fi
set -a # all sourced vars are exported
source ./pcejs_build_conf.sh
set +a # restore default behaviour
}
pcejs_save_config () {
(set -o posix; set) | grep "PCEJS_conf_" > ./pcejs_build_conf.sh
}
# ensure cwd is project root dir
repo_root=$(git rev-parse --show-toplevel)
cd "$repo_root"
pcejs_load_config
source ./scripts/pcejs_build_env.sh # initialise build env from config
pcejs_build=$0
taskname=$1
case "$taskname" in
"env") # Print build environment variables
(set -o posix; set) | grep "PCEJS_"
;;
"configure") # Configure emulator build"
platform=$2
if [[ $platform == "native" ]]; then
export PCEJS_conf_emscripten=""
export PCEJS_conf_prefix="build-native/"
fi
if [[ $platform == "em" ]]; then
export PCEJS_conf_emscripten="yes"
export PCEJS_conf_prefix="build/"
fi
./scripts/10-configure.sh
pcejs_save_config
;;
"make") # Compile emulator source to LLVM bitcode
./scripts/20-make.sh
;;
"remake") # Recompile only changed files of emulator source to LLVM bitcode
./scripts/21-remake.sh
;;
"clean") # Clean source tree
cleanall=$2
if [[ -n $cleanall ]]; then
./scripts/a0-clean.sh
else
make clean
fi
;;
"afterbuild") # Convert LLVM bitcode to JS
target=$2
if [[ -n $target ]]; then
export PCEJS_conf_target=$target
fi
./scripts/30-afterbuild.sh
;;
"build") # Configure build and compile emulator to JS
target_or_platform=$2
if [[ $target_or_platform == "native" ]]; then
$pcejs_build configure native
$pcejs_build make
else
if [[ -n $target_or_platform ]]; then
export PCEJS_conf_target=$target_or_platform
fi
$pcejs_build configure em
$pcejs_build make
afterbuild "$PCEJS_conf_target"
fi
pcejs_save_config
;;
"rebuild") # Build last again
target_or_platform=$2
if [[ $target_or_platform == "native" ]]; then
$pcejs_build remake
elif [[ -n $target_or_platform ]]; then
export PCEJS_conf_target=$target_or_platform
$pcejs_build remake
$pcejs_build afterbuild "$PCEJS_conf_target"
else
$pcejs_build remake
for arch in "${ARCHS[@]}"; do
$pcejs_build afterbuild "$arch"
done
fi
;;
"module") # Build commonjs module"
target=$2
if [[ -n $target ]]; then
echo "building commonjs module for target $target";
else
echo "target not specified";
exit 1;
fi
./scripts/module_build.sh "$target"
;;
*)
if [[ -n $PCEJS_conf_emscripten ]]; then
$pcejs_build remake
else
$pcejs_build configure em
$pcejs_build make
fi
for arch in "${ARCHS[@]}"; do
$pcejs_build afterbuild "$arch"
$pcejs_build module "$arch"
done
;;
esac