forked from xemu-project/xemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·256 lines (235 loc) · 6.8 KB
/
build.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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/usr/bin/env bash
set -e # exit if a command fails
set -o pipefail # Will return the exit status of make if it fails
set -o physical # Resolve symlinks when changing directory
project_source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
package_windows() {
rm -rf dist
mkdir -p dist
cp i386-softmmu/qemu-system-i386.exe dist/xemu.exe
#cp i386-softmmu/qemu-system-i386w.exe dist/xemuw.exe
cp -r "./data" dist/
python3 "./get_deps.py" dist/xemu.exe dist
strip dist/xemu.exe
}
package_macos() {
#
# Create bundle
#
rm -rf dist
# Copy in executable
mkdir -p dist/xemu.app/Contents/MacOS/
cp i386-softmmu/qemu-system-i386 dist/xemu.app/Contents/MacOS/xemu
# Copy in in executable dylib dependencies
mkdir -p dist/xemu.app/Contents/Frameworks
dylibbundler -cd -of -b -x dist/xemu.app/Contents/MacOS/xemu \
-d dist/xemu.app/Contents/Frameworks/ \
-p '@executable_path/../Frameworks/'
# Copy in runtime resources
mkdir -p dist/xemu.app/Contents/Resources
cp -r "${project_source_dir}/data" dist/xemu.app/Contents/Resources
# Generate icon file
mkdir -p xemu.iconset
for r in 16 32 128 256 512; do cp "${project_source_dir}/ui/icons/xemu_${r}x${r}.png" "xemu.iconset/icon_${r}x${r}.png"; done
iconutil --convert icns --output dist/xemu.app/Contents/Resources/xemu.icns xemu.iconset
# Generate Info.plist file
cat <<EOF > dist/xemu.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>xemu</string>
<key>CFBundleIconFile</key>
<string>xemu.icns</string>
<key>CFBundleIdentifier</key>
<string>xemu.app.0</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>xemu</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1</string>
<key>CFBundleSignature</key>
<string>xemu</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
}
package_linux() {
rm -rf dist
mkdir -p dist
cp i386-softmmu/qemu-system-i386 dist/xemu
cp -r "${project_source_dir}/data" dist
}
postbuild=''
debug_opts=''
build_cflags='-O3'
default_job_count='12'
sys_ldflags=''
get_job_count () {
if command -v 'nproc' >/dev/null
then
nproc
else
case "$(uname -s)" in
'Linux')
egrep "^processor" /proc/cpuinfo | wc -l
;;
'FreeBSD')
sysctl -n hw.ncpu
;;
'Darwin')
sysctl -n hw.logicalcpu 2>/dev/null \
|| sysctl -n hw.ncpu
;;
'MSYS_NT-'*|'CYGWIN_NT-'*|'MINGW'*'_NT-'*)
if command -v 'wmic' >/dev/null
then
wmic cpu get NumberOfLogicalProcessors/Format:List \
| grep -m1 '=' | cut -f2 -d'='
else
echo "${NUMBER_OF_PROCESSORS:-${default_job_count}}"
fi
;;
*)
echo "${default_job_count}"
;;
esac
fi
}
job_count="$(get_job_count)" 2>/dev/null
job_count="${job_count:-${default_job_count}}"
while [ ! -z "${1}" ]
do
case "${1}" in
'-j'*)
job_count="${1:2}"
shift
;;
'--debug')
build_cflags='-O0 -g -DXEMU_DEBUG_BUILD=1'
debug_opts='--enable-debug'
shift
;;
*)
break
;;
esac
done
case "$(uname -s)" in # Adjust compilation options based on platform
Linux)
echo 'Compiling for Linux...'
sys_cflags='-Wno-error=redundant-decls -Wno-error=unused-but-set-variable'
sys_opts='--enable-kvm --disable-xen --disable-werror'
postbuild='package_linux'
;;
Darwin)
echo 'Compiling for MacOS...'
sys_cflags='-march=ivybridge'
sys_ldflags='-headerpad_max_install_names'
sys_opts='--disable-cocoa'
# necessary to find libffi, which is required by gobject
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}/usr/local/opt/libffi/lib/pkgconfig"
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig:${PKG_CONFIG_PATH}"
echo $PKG_CONFIG_PATH
postbuild='package_macos'
;;
CYGWIN*|MINGW*|MSYS*)
echo 'Compiling for Windows...'
sys_cflags='-Wno-error'
sys_opts='--python=python3 --disable-cocoa --disable-opengl --disable-fortify-source'
postbuild='package_windows' # set the above function to be called after build
;;
*)
echo "could not detect OS $(uname -s), aborting" >&2
exit -1
;;
esac
# find absolute path (and resolve symlinks) to build out of tree
configure="${project_source_dir}/configure"
build_cflags="${build_cflags} -I${project_source_dir}/ui/imgui"
set -x # Print commands from now on
"${configure}" \
--extra-cflags="-DXBOX=1 -DNDEBUG ${build_cflags} ${sys_cflags} ${CFLAGS}" \
--extra-ldflags="${sys_ldflags}" \
${debug_opts} \
${sys_opts} \
--target-list=i386-softmmu \
--enable-trace-backends="nop" \
--enable-sdl \
--enable-opengl \
--disable-curl \
--disable-vnc \
--disable-vnc-sasl \
--disable-docs \
--disable-tools \
--disable-guest-agent \
--disable-tpm \
--disable-live-block-migration \
--disable-rdma \
--disable-replication \
--disable-capstone \
--disable-fdt \
--disable-libiscsi \
--disable-spice \
--disable-user \
--disable-stack-protector \
--disable-glusterfs \
--disable-gtk \
--disable-curses \
--disable-gnutls \
--disable-nettle \
--disable-gcrypt \
--disable-crypto-afalg \
--disable-virglrenderer \
--disable-vhost-net \
--disable-vhost-crypto \
--disable-vhost-vsock \
--disable-vhost-user \
--disable-virtfs \
--disable-snappy \
--disable-bzip2 \
--disable-vde \
--disable-libxml2 \
--disable-seccomp \
--disable-numa \
--disable-lzo \
--disable-smartcard \
--disable-usb-redir \
--disable-bochs \
--disable-cloop \
--disable-dmg \
--disable-vdi \
--disable-vvfat \
--disable-qcow1 \
--disable-qed \
--disable-parallels \
--disable-sheepdog \
--without-default-devices \
--disable-blobs \
--disable-kvm \
--disable-hax \
--disable-hvf \
--disable-whpx \
"$@"
# Force imgui update now to work around annoying make issue
if ! test -f "${project_source_dir}/ui/imgui/imgui.cpp"; then
./scripts/git-submodule.sh update ui/imgui
fi
time make -j"${job_count}" 2>&1 | tee build.log
"${postbuild}" # call post build functions