Browse Source
* Refactor OpenDingux build scripts Created a common build.sh script that takes the target architecture as a command line argument. Updated existing build scripts, now they call build.sh with the matching target. This avoids code duplication and should help maintaining the build script. * Split the buildroot prepare and build steps If the buildroot compilation fails, it will be run again the next time the script is called. This was not the case before, as the buildroot step was skipped when the buildroot folder existed. * minor fixespull/389/head
5 changed files with 107 additions and 145 deletions
@ -1,55 +1,2 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
set -euo pipefail |
||||
|
||||
declare -r DIR="$(dirname "${BASH_SOURCE[0]}")" |
||||
cd "$DIR" |
||||
declare -r ABSDIR="$(pwd)" |
||||
|
||||
declare -r BUILDROOT_VER=buildroot-2018.02.9 |
||||
BUILDROOT="${BUILDROOT:-$HOME/${BUILDROOT_VER}-retrofw}" |
||||
|
||||
declare -r BUILDROOT_ARCHIVE="$HOME/${BUILDROOT_VER}.tar.gz" |
||||
|
||||
set -x |
||||
|
||||
main() { |
||||
set -x |
||||
prepare_buildroot |
||||
build |
||||
package |
||||
} |
||||
|
||||
prepare_buildroot() { |
||||
if [[ -d $BUILDROOT ]]; then |
||||
return |
||||
fi |
||||
if [[ ! -f $BUILDROOT_ARCHIVE ]]; then |
||||
\curl https://buildroot.org/downloads/${BUILDROOT_VER}.tar.gz -o "$BUILDROOT_ARCHIVE" |
||||
fi |
||||
|
||||
tar xf "$BUILDROOT_ARCHIVE" -C "$(dirname "$BUILDROOT_ARCHIVE")" |
||||
mv "${BUILDROOT_ARCHIVE%.tar.gz}" "$BUILDROOT" |
||||
cp buildroot_retrofw_defconfig "$BUILDROOT/configs/retrofw_defconfig" |
||||
cd "$BUILDROOT" |
||||
echo 'LIBSODIUM_CONF_OPTS += --enable-static' >> package/libsodium/libsodium.mk |
||||
make retrofw_defconfig |
||||
BR2_JLEVEL=0 make toolchain libsodium libzip sdl sdl_mixer sdl_ttf |
||||
cd - |
||||
} |
||||
|
||||
build() { |
||||
mkdir -p ../../build |
||||
cd ../../build |
||||
rm -f CMakeCache.txt |
||||
cmake .. -DDINGUX=ON -DRETROFW=ON -DUSE_SDL1=ON -DBINARY_RELEASE=ON \ |
||||
-DCMAKE_TOOLCHAIN_FILE="$BUILDROOT/output/host/share/buildroot/toolchainfile.cmake" |
||||
make -j $(nproc) |
||||
cd - |
||||
} |
||||
|
||||
package() { |
||||
./package-ipk.sh ../../build/devilutionx-retrofw.ipk |
||||
} |
||||
|
||||
main |
||||
./build.sh retrofw |
||||
|
||||
@ -1,46 +1,2 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
set -euo pipefail |
||||
|
||||
declare -r DIR="$(dirname "${BASH_SOURCE[0]}")" |
||||
cd "$DIR" |
||||
declare -r ABSDIR="$(pwd)" |
||||
|
||||
BUILDROOT="${BUILDROOT:-$HOME/buildroot-rg350-devilutionx}" |
||||
|
||||
set -x |
||||
|
||||
main() { |
||||
set -x |
||||
prepare_buildroot |
||||
build |
||||
package |
||||
} |
||||
|
||||
prepare_buildroot() { |
||||
if [[ -d $BUILDROOT ]]; then |
||||
return |
||||
fi |
||||
git clone --depth=1 https://github.com/tonyjih/RG350_buildroot.git "$BUILDROOT" |
||||
cp buildroot_rg350_defconfig "$BUILDROOT/configs/rg350_devilutionx_defconfig" |
||||
cd "$BUILDROOT" |
||||
make rg350_devilutionx_defconfig |
||||
BR2_JLEVEL=0 make |
||||
cd - |
||||
} |
||||
|
||||
build() { |
||||
mkdir -p ../../build |
||||
cd ../../build |
||||
rm -f CMakeCache.txt |
||||
cmake .. -DDINGUX=ON -DBINARY_RELEASE=ON -DNONET=ON \ |
||||
-DCMAKE_TOOLCHAIN_FILE="$BUILDROOT/output/host/usr/share/buildroot/toolchainfile.cmake" |
||||
make -j $(nproc) |
||||
cd - |
||||
} |
||||
|
||||
package() { |
||||
./package-opk.sh ../../build/devilutionx-rg350.opk |
||||
} |
||||
|
||||
main |
||||
./build.sh rg350 |
||||
|
||||
@ -1,47 +1,2 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
set -euo pipefail |
||||
|
||||
declare -r DIR="$(dirname "${BASH_SOURCE[0]}")" |
||||
cd "$DIR" |
||||
declare -r ABSDIR="$(pwd)" |
||||
|
||||
BUILDROOT="${BUILDROOT:-$HOME/buildroot-rs90-devilutionx}" |
||||
|
||||
set -x |
||||
|
||||
main() { |
||||
set -x |
||||
prepare_buildroot |
||||
build |
||||
package |
||||
} |
||||
|
||||
prepare_buildroot() { |
||||
if [[ -d $BUILDROOT ]]; then |
||||
return |
||||
fi |
||||
git clone --depth=1 -b od-rs90 https://github.com/OpenDingux/buildroot.git "$BUILDROOT" |
||||
cp buildroot_rs90_defconfig "$BUILDROOT/configs/rs90_devilutionx_defconfig" |
||||
cd "$BUILDROOT" |
||||
echo 'LIBSODIUM_CONF_OPTS += --enable-static' >> package/libsodium/libsodium.mk |
||||
make rs90_devilutionx_defconfig |
||||
BR2_JLEVEL=0 make toolchain libsodium libzip sdl sdl_mixer sdl_ttf |
||||
cd - |
||||
} |
||||
|
||||
build() { |
||||
mkdir -p ../../build |
||||
cd ../../build |
||||
rm -f CMakeCache.txt |
||||
cmake .. -DDINGUX=ON -DUSE_SDL1=ON -DBINARY_RELEASE=ON \ |
||||
-DCMAKE_TOOLCHAIN_FILE="$BUILDROOT/output/host/share/buildroot/toolchainfile.cmake" |
||||
make -j $(nproc) |
||||
cd - |
||||
} |
||||
|
||||
package() { |
||||
./package-opk.sh ../../build/devilutionx-rs90.opk |
||||
} |
||||
|
||||
main |
||||
./build.sh rs90 |
||||
|
||||
@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
set -euo pipefail |
||||
|
||||
usage() { |
||||
echo "Usage: build.sh [target]" |
||||
echo " target: target architecture. Either rs90, rg350 or retrofw" |
||||
} |
||||
|
||||
if [[ $# -ne 1 ]]; then |
||||
echo "Error: target is missing" |
||||
usage |
||||
exit 1 |
||||
fi |
||||
|
||||
if [[ "$1" != "rs90" ]] && [[ "$1" != "rg350" ]] && [[ "$1" != "retrofw" ]]; then |
||||
echo "Error: invalid target" |
||||
usage |
||||
exit 1 |
||||
fi |
||||
|
||||
declare -r TARGET="${1}" |
||||
echo "Building for target: ${TARGET}" |
||||
|
||||
declare -r DIR="$(dirname "${BASH_SOURCE[0]}")" |
||||
cd "$DIR" |
||||
declare -r ABSDIR="$(pwd)" |
||||
|
||||
if [[ "$TARGET" == "retrofw" ]]; then |
||||
declare -r BUILDROOT_VER=buildroot-2018.02.9 |
||||
declare -r BUILDROOT_ARCHIVE="$HOME/${BUILDROOT_VER}.tar.gz" |
||||
fi |
||||
|
||||
BUILDROOT="${BUILDROOT:-$HOME/buildroot-${TARGET}-devilutionx}" |
||||
|
||||
set -x |
||||
|
||||
main() { |
||||
set -x |
||||
prepare_buildroot |
||||
make_buildroot |
||||
build |
||||
package |
||||
} |
||||
|
||||
prepare_buildroot() { |
||||
if [[ -d $BUILDROOT ]]; then |
||||
return |
||||
fi |
||||
if [[ "$TARGET" == "rg350" ]]; then |
||||
git clone --depth=1 https://github.com/tonyjih/RG350_buildroot.git "$BUILDROOT" |
||||
elif [[ "$TARGET" == "rs90" ]]; then |
||||
git clone --depth=1 -b od-rs90 https://github.com/OpenDingux/buildroot.git "$BUILDROOT" |
||||
else |
||||
if [[ ! -f $BUILDROOT_ARCHIVE ]]; then |
||||
\curl https://buildroot.org/downloads/${BUILDROOT_VER}.tar.gz -o "$BUILDROOT_ARCHIVE" |
||||
fi |
||||
tar xf "$BUILDROOT_ARCHIVE" -C "$(dirname "$BUILDROOT_ARCHIVE")" |
||||
mv "${BUILDROOT_ARCHIVE%.tar.gz}" "$BUILDROOT" |
||||
fi |
||||
cp buildroot_${TARGET}_defconfig "$BUILDROOT/configs/${TARGET}_devilutionx_defconfig" |
||||
} |
||||
|
||||
make_buildroot() { |
||||
cd "$BUILDROOT" |
||||
if [[ "$TARGET" != "rg350" ]]; then |
||||
echo 'LIBSODIUM_CONF_OPTS += --enable-static' >> package/libsodium/libsodium.mk |
||||
fi |
||||
make ${TARGET}_devilutionx_defconfig |
||||
if [[ "$TARGET" == "rg350" ]]; then |
||||
BR2_JLEVEL=0 make |
||||
else |
||||
BR2_JLEVEL=0 make toolchain libsodium libzip sdl sdl_mixer sdl_ttf |
||||
fi |
||||
cd - |
||||
} |
||||
|
||||
build() { |
||||
mkdir -p ../../build |
||||
cd ../../build |
||||
rm -f CMakeCache.txt |
||||
if [[ "$TARGET" == "rg350" ]]; then |
||||
TARGET_DEFINES="-DNONET=ON" |
||||
elif [[ "$TARGET" == "rs90" ]]; then |
||||
TARGET_DEFINES="-DUSE_SDL1=ON" |
||||
else |
||||
TARGET_DEFINES="-DRETROFW=ON -DUSE_SDL1=ON" |
||||
fi |
||||
cmake .. -DDINGUX=ON -DBINARY_RELEASE=ON ${TARGET_DEFINES} \ |
||||
-DCMAKE_TOOLCHAIN_FILE="$BUILDROOT/output/host/usr/share/buildroot/toolchainfile.cmake" |
||||
make -j $(nproc) |
||||
cd - |
||||
} |
||||
|
||||
package() { |
||||
if [[ "$TARGET" == "retrofw" ]]; then |
||||
./package-ipk.sh ../../build/devilutionx-retrofw.ipk |
||||
else |
||||
./package-opk.sh ../../build/devilutionx-${TARGET}.opk |
||||
fi |
||||
} |
||||
|
||||
main |
||||
Loading…
Reference in new issue