forked from voorhees1979/PUAE
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build_native_client.sh
executable file
·240 lines (194 loc) · 7.85 KB
/
build_native_client.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
###########################################################################
# Set up. Adjust these as necessary.
###########################################################################
# Path to the NaCl SDK to use. Should be pepper_31 or later.
export NACL_SDK_ROOT=${HOME}/nacl_sdk/pepper_31
# Check out naclports and point this to the folder with 'src/'.
export NACL_PORTS_ROOT=${HOME}/work/naclports
# Staging dir on local web server.
export WEB_SERVER_DESTINATION_DIR=${HOME}/work/puae/staging
# URL to access the staging dir via the web server.
export WEB_SERVER="http://localhost:8080"
# The OS you're building this on.
# Note: Building on Windows has not been tried.
export OS=mac # Should be mac, linux, or win.
# Set the Chrome/Chromium to use.
export CHROME_EXE='/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
# Any extra CPPFLAGS.
export NACL_CPPFLAGS="-DDEBUG"
export NACL_CFLAGS=""
# Enable build key (yes or no/empty).
# This generates a random key that is used to apply naive XOR encryption
# on all UAE data files (ROMs, ADFs, etc.) fetched from the web server.
export ENABLE_BUILD_KEY=yes
export DATA_FILES_TO_DEPLOY_DIR=${HOME}/work/puae/data_files_to_deploy
# Choose SDL or Pepper for graphics, sound, and input.
# TODO(cstefansen): Fix NaCl SDL build.
#export UAE_CONFIGURE_FLAGS_NACL="--enable-drvsnd \
# --with-sdl --with-sdl-gfx --with-sdl-gl --with-sdl-sound"
export UAE_CONFIGURE_FLAGS_NACL="--enable-drvsnd --with-pepper --enable-serial-port"
# (Serial port emulation is needed for debugging AROS ROMs.)
###########################################################################
# You shouldn't need to change anything below this point.
###########################################################################
export UAE_ROOT=`cd \`dirname $0\` && pwd`
############################################################################
# Do a clean build for PNaCl.
############################################################################
if [ "$1" = "pnacl" ]; then
export NACL_TOOLCHAIN_ROOT=${NACL_SDK_ROOT}/toolchain/${OS}_pnacl
export CC=${NACL_TOOLCHAIN_ROOT}/bin/pnacl-clang++
export CXX=$CC
export RANLIB=${NACL_TOOLCHAIN_ROOT}/bin/pnacl-ranlib
export AR=${NACL_TOOLCHAIN_ROOT}/bin/pnacl-ar
export NACL_INCLUDE=${NACL_SDK_ROOT}/include
export NACL_LIB=${NACL_SDK_ROOT}/lib/pnacl/Release
export CPPFLAGS="-I${NACL_INCLUDE} ${NACL_CPPFLAGS}"
export CFLAGS="${NACL_CFLAGS} -O2 -g -Wno-unused-parameter -Wno-missing-field-initializers"
export CXXFLAGS="-O2 -g -Wno-unused-parameter -Wno-missing-field-initializers"
export LDFLAGS="-L${NACL_LIB}"
# Build zlib.
cd ${NACL_PORTS_ROOT}/src/libraries/zlib
if [ "$OS" = "mac" ]; then
# TODO(cstefansen): Upstream this fix, so it builds on Mac without
# patching.
patch -p0 -N <<EOF
index fe99ed0..2a45383 100755
--- nacl-zlib.sh
+++ nacl-zlib.sh
@@ -91,7 +91,7 @@ PackageInstall() {
ConfigureStep
BuildStep
ValidateStep
- TestStep
+# TestStep
DefaultInstallStep
if [ "${NACL_GLIBC}" = "1" ]; then
ConfigureStep shared
EOF
fi # "$OS" = "mac"
NACL_ARCH=pnacl NACL_GLIBC=0 ./nacl-zlib.sh
# Generate build key.
cd ${UAE_ROOT}/src
if [ "$ENABLE_BUILD_KEY" = "yes" ]; then
time dd if=/dev/urandom of=build.key bs=1 count=4096
xxd -i build.key build.key.c
export CPPFLAGS="${CPPFLAGS} -DENABLE_BUILD_KEY"
fi # ENABLE_BUILD_KEY
# Build PUAE.
cd ${UAE_ROOT}
make clean
./bootstrap.sh
./configure --host=le32-unknown-nacl ${UAE_CONFIGURE_FLAGS_NACL}
make
exit $?
fi # "pnacl"
###########################################################################
# Incremental
###########################################################################
if [ "$1" = "incremental" ]; then
make
exit $?
fi # incremental
############################################################################
# Build for desktop.
# This is left in for convenience to aid debugging/profiling.
############################################################################
if [ "$1" = "desktop" ]; then
CPPFLAGS=""
CFLAGS="-m32 -g"
CXXFLAGS="-m32 -g"
LDFLAGS=""
cd ${UAE_ROOT}
make clean
./bootstrap.sh
./configure --disable-ui --disable-jit \
--with-sdl --with-sdl-gfx --without-sdl-gl --with-sdl-sound \
--disable-autoconfig
if [ "$?" -ne "0" ]; then
echo "./configure failed for desktop UAE."
exit 1
fi
make
if [ "$?" -ne "0" ]; then
echo "make failed for desktop UAE."
exit 1
fi
exit 0
fi # "desktop"
###########################################################################
# Running/debugging
###########################################################################
if [ "$1" = "run" ] || [ "$1" = "debug" ]; then
# Encrypt if requested and then stage data files.
cd ${DATA_FILES_TO_DEPLOY_DIR}
if [ "$ENABLE_BUILD_KEY" = "yes" ]; then
for f in *
do
${UAE_ROOT}/src/xor_encryption.py $f ${UAE_ROOT}/src/build.key
mv $f.encrypted ${WEB_SERVER_DESTINATION_DIR}/$f
done
else
cp * ${WEB_SERVER_DESTINATION_DIR}/
fi # ENABLE_BUILD_KEY
# Copy stuff to web server.
cd ${UAE_ROOT}
echo "Copying files to web server directory."
mkdir -p ${WEB_SERVER_DESTINATION_DIR}/img
cp src/gui-html/img/amiga500_128x128.png \
src/gui-html/img/amiga_pointer.png \
src/gui-html/img/first_demos.png \
src/gui-html/img/read_me.png \
src/gui-html/img/loading.gif \
${WEB_SERVER_DESTINATION_DIR}/img/
cp src/gui-html/uae.html src/gui-html/uae_faq.html src/gui-html/uae.css \
src/gui-html/uae.js src/gui-html/uae.nmf src/gui-html/default.uaerc \
src/gui-html/img/favicon.ico \
${WEB_SERVER_DESTINATION_DIR}/
# TODO(cstefansen): Put the pnacl-finalize step in a make rule instead.
${NACL_SDK_ROOT}/toolchain/${OS}_pnacl/bin/pnacl-finalize src/uae \
-o ${WEB_SERVER_DESTINATION_DIR}/uae.pexe
# Make sure the files are readable.
chmod -R 0755 ${WEB_SERVER_DESTINATION_DIR}
# Have Chrome navigate to the app.
CHROME_APP_LOCATION="$WEB_SERVER/uae.html"
# Chrome flags.
# Add the flag --disable-gpu to simulate system without OpenGLES support.
CHROME_FLAGS='--user-data-dir=../chrome-profile \
--no-first-run'
# Some other convenient command-line flags to use:
# --show-fps-counter --incognito
# Clean the user profile. We don't want cached files.
rm -fR ../chrome-profile
if [ "$1" = "debug" ]; then
CHROME_FLAGS+=' --enable-nacl-debug'
echo "*** Starting Chrome in NaCl debug mode. ***"
echo "Start nacl-gdb and connect with 'target remote localhost 4010'."
else
${NACL_SDK_ROOT}/toolchain/${OS}_pnacl/bin/pnacl-strip \
${WEB_SERVER_DESTINATION_DIR}/uae.pexe
fi
echo "${CHROME_EXE}" ${CHROME_FLAGS} ${CHROME_APP_LOCATION}
"${CHROME_EXE}" ${CHROME_FLAGS} ${CHROME_APP_LOCATION}
exit 0
fi # "run" || "debug"
###########################################################################
# Didn't find anything useful to do; print usage message.
###########################################################################
cat <<EOF
Usage: $0 (pnacl | desktop | incremental | run | debug)
How to use this script:
1. Adjust the variables in the beginning of the script.
2. To make a clean PNaCl build of UAE, execute
./build_native_client.sh pnacl
3. Start the web server, e.g., by executing
python -m SimpleHTTPServer 8080
from the web server destination dir.
4. To stage the files and run Chrome do
./build_native_client.sh run
5. Do incremental builds with
./build_native_client.sh incremental
6. To run and make Chrome/PNaCl wait until a NaCl debugger is attached use
./build_native_client.sh run
EOF