| 1 |
#!/bin/bash |
| 2 |
set -eux -o pipefail |
| 3 |
|
| 4 |
unset outdir zip_filename |
| 5 |
|
| 6 |
while getopts o:z: OPTNAME; do |
| 7 |
case "$OPTNAME" in |
| 8 |
o) |
| 9 |
outdir="$OPTARG" |
| 10 |
;; |
| 11 |
z) |
| 12 |
zip_filename="$OPTARG" |
| 13 |
;; |
| 14 |
esac |
| 15 |
done |
| 16 |
|
| 17 |
[[ -v outdir ]] || outdir='tmp' |
| 18 |
|
| 19 |
build_app() { |
| 20 |
local name prettyname |
| 21 |
name="$1" |
| 22 |
prettyname="$2" |
| 23 |
|
| 24 |
# Create a subdirectory for each app at the top level |
| 25 |
mkdir -p "${outdir}/${prettyname}/Demos" |
| 26 |
mkdir -p "${outdir}/${prettyname}/Missions" |
| 27 |
mkdir -p "${outdir}/${prettyname}/Screenshots" |
| 28 |
|
| 29 |
# Copy executable to the respective app directory |
| 30 |
cp --link "build/${name}/${name}.exe" "${outdir}/${prettyname}/" |
| 31 |
|
| 32 |
# Copy libraries to the respective app directory |
| 33 |
copy_lib() { |
| 34 |
ldd "$1" | grep mingw64 | sort | cut -d' ' -f3 | while read dll; do cp "${dll}" "${outdir}/${prettyname}/"; done |
| 35 |
} |
| 36 |
copy_lib "${outdir}/${prettyname}/${name}.exe" |
| 37 |
|
| 38 |
# ogg support is dynamically loaded, so manually copy this (and its libs) too |
| 39 |
# TODO FLAC support? Missing libflac-8.dll but unable to find mingw64 package |
| 40 |
cp "/mingw64/bin/libvorbisfile-3.dll" "${outdir}/${prettyname}/" |
| 41 |
copy_lib "/mingw64/bin/libvorbisfile-3.dll" |
| 42 |
|
| 43 |
# Copy other resources to the respective app directory |
| 44 |
cp --link "${name}/"*.ini "${outdir}/${prettyname}/" |
| 45 |
cp --link "COPYING.txt" "${outdir}/${prettyname}/" |
| 46 |
cp --link "GPL-3.txt" "${outdir}/${prettyname}/" |
| 47 |
cp --link "README.md" "${outdir}/${prettyname}/" |
| 48 |
cp --link "INSTALL.markdown" "${outdir}/${prettyname}/" |
| 49 |
} |
| 50 |
|
| 51 |
# Build each app |
| 52 |
build_app "d1x-rebirth" "D1X-Rebirth" |
| 53 |
build_app "d2x-rebirth" "D2X-Rebirth" |
| 54 |
|
| 55 |
if ! [[ -v zip_filename ]]; then |
| 56 |
zip_filename="../DXX-Rebirth-Windows-$(uname -m).zip" |
| 57 |
fi |
| 58 |
|
| 59 |
if [[ -n "$zip_filename" ]]; then |
| 60 |
# Consolidate both apps into a single zip file |
| 61 |
cd "${outdir}" |
| 62 |
zip -r -X "$zip_filename" "D1X-Rebirth" "D2X-Rebirth" |
| 63 |
fi |