/
compile.sh
125 lines (81 loc) · 2.88 KB
/
compile.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
#!/usr/bin/env bash
set -ex
# Parameters
threads="${1:-$(nproc)}"
electron="${2:-v22.3.27}"
# Paths
script_dir="$(dirname "$0")"
toplvl_dir="$(realpath "$script_dir")"
build_dir="$toplvl_dir/build"
cmake_dir="$build_dir/CMake"
emg_dir="$build_dir/EMG"
rsc_dir="$emg_dir/resources"
ico_dir="$rsc_dir/icon"
m64p_dir="$rsc_dir/m64p"
plugin_dir="$m64p_dir/plugin"
# Platform specific settings
exe=""
ext=".so"
gca="libmupen64plus_input_gca.so"
platform="linux"
if [[ "$OSTYPE" == "msys"* ]]; then
exe=".exe"
ext=".dll"
gca="mupen64plus_input_gca.dll"
platform="win32"
fi
# Remove previous build files
if [ -d "$cmake_dir" ] || [ -d "$emg_dir" ] ; then
echo "Build directories (CMake, EMG) already exist. Delete folders to proceed?"
select yn in "Continue" "Exit"; do
case $yn in
Continue ) rm -rf $cmake_dir $emg_dir; break;;
Exit ) exit;;
esac
done
fi
# Initial directories
mkdir -p "$build_dir" "$cmake_dir" "$emg_dir"
cp -R resources $emg_dir/resources
cp -R source/* $cmake_dir
# Fix script file permissions
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
pushd "$cmake_dir"
chmod u+x mupen64plus-video-GLideN64/src/getRevision.sh
fi
# Download binary files
pushd "$build_dir"
[ ! -f electron-$electron-$platform-x64.zip ] && wget https://github.com/electron/electron/releases/download/$electron/electron-$electron-$platform-x64.zip
7z x electron-$electron-$platform-x64.zip -oEMG '-x!LICENSE' '-x!LICENSES.chromium.html' '-x!version' '-x!resources/default_app.asar' '-x!locales/*.pak' -y
7z x electron-$electron-$platform-x64.zip -oEMG '-i!locales/en-US.pak' -y
if [[ "$OSTYPE" == "msys"* ]]; then
[ ! -f rcedit-x64.exe ] && wget https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe
fi
# Build
pushd "$cmake_dir"
cmake "$toplvl_dir" -G "Ninja"
cmake --build "$cmake_dir" --parallel "$threads"
cmake --install "$cmake_dir"
if [[ "$OSTYPE" == "msys"* ]]; then
cmake --build "$cmake_dir" --target=bundle_dependencies
fi
# Rename files
pushd "$emg_dir"
mv electron$exe EMG$exe
pushd "$plugin_dir"
mv $gca mupen64plus-input-gca$ext
# Fix executable file permissions
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
pushd "$m64p_dir"
chmod u+x mupen64plus
chmod u+x sdl2-jstest
fi
# rcedit
pushd "$toplvl_dir"
if [[ "$OSTYPE" == "msys"* ]]; then
cmd //c $build_dir/rcedit-x64 $m64p_dir/mupen64plus.exe --set-icon $ico_dir/mupen64plus.ico
cmd //c $build_dir/rcedit-x64 $emg_dir/EMG.exe --set-icon $ico_dir/emg.ico --set-version-string LegalCopyright "(C) 2024 EvilGames.eu" --set-version-string OriginalFilename "electron.exe" --set-version-string FileDescription "EMG" --set-version-string ProductName "EMG" --set-version-string CompanyName "EvilGames.eu"
fi
# Strip binaries
for f in $m64p_dir/*$ext; do strip --strip-unneeded $f; done
for f in $plugin_dir/*$ext; do strip --strip-unneeded $f; done