@ -2,48 +2,38 @@
set -euo pipefail
set -euo pipefail
cd " $( dirname " ${ BASH_SOURCE [0] } " ) /../.. "
source Packaging/OpenDingux/targets.sh
source Packaging/OpenDingux/package-opk.sh
usage( ) {
usage( ) {
echo "Usage: build.sh [target]"
echo "Usage: build.sh [target]"
echo " target: target platform: rg350, gkd350h, or retrofw"
usage_target
}
}
if [ [ $# -ne 1 ] ] ; then
if ! check_target " $@ " ; then
echo "Error: target is missing"
usage
usage
exit 64
exit 1
fi
if [ [ $1 != rg350 ] ] && [ [ $1 != retrofw ] ] && [ [ $1 != gkd350h ] ] ; then
echo "Error: invalid target"
usage
exit 1
fi
fi
cd " $( dirname " ${ BASH_SOURCE [0] } " ) /../.. "
declare -r TARGET = " $1 "
declare -r TARGET = " ${ 1 } "
declare -r BUILD_DIR = " build- ${ TARGET } "
declare -r BUILD_DIR = " build- ${ TARGET } "
declare -rA BUILDROOT_REPOS = (
declare -rA BUILDROOT_REPOS = (
[ retrofw] = https://github.com/retrofw/buildroot.git
[ retrofw] = https://github.com/retrofw/buildroot.git
[ rg350] = https://github.com/tonyjih/RG350_buildroot.git
[ rg350] = https://github.com/tonyjih/RG350_buildroot.git
)
)
declare -rA BUILDROOT_DEFCONFIGS = (
[ retrofw] = 'RetroFW_defconfig BR2_EXTERNAL=retrofw'
[ rg350] = 'rg350_defconfig BR2_EXTERNAL=board/opendingux'
)
declare BUILDROOT_DEFCONFIG
declare BUILDROOT_TARGET = " $TARGET "
declare BUILDROOT_REPO
set_buildroot_vars( ) {
BUILDROOT_DEFCONFIG = " $1 _devilutionx_defconfig "
BUILDROOT_REPO = " ${ BUILDROOT_REPOS [ $1 ] } "
BUILDROOT = " ${ BUILDROOT :- $HOME /buildroot- $1 -devilutionx } "
}
# Use the rg350 buildroot for gkd350h because gkd350h buildroot is not open-source.
if [ [ $TARGET = = gkd350h ] ] ; then
if [ [ $TARGET = = gkd350h ] ] ; then
set_buildroot_vars rg350
# Use the rg350 buildroot for gkd350h because gkd350h buildroot is not open-source.
else
BUILDROOT_TARGET = rg350
set_buildroot_vars " $TARGET "
fi
fi
BUILDROOT = " ${ BUILDROOT :- $HOME /devilutionx-buildroots/ $BUILDROOT_TARGET } "
main( ) {
main( ) {
>& 2 echo " Building for target ${ TARGET } in ${ BUILD_DIR } "
>& 2 echo " Building for target ${ TARGET } in ${ BUILD_DIR } "
@ -51,20 +41,21 @@ main() {
prepare_buildroot
prepare_buildroot
make_buildroot
make_buildroot
build
build
package
package_opk
}
}
prepare_buildroot( ) {
prepare_buildroot( ) {
if [ [ -d $BUILDROOT ] ] ; then
if [ [ -d $BUILDROOT ] ] ; then
return
return
fi
fi
git clone --depth= 1 " ${ BUILDROOT_REPOS [ $TARGET ] } " " $BUILDROOT "
git clone --depth= 1 " ${ BUILDROOT_REPOS [ $BUILDROOT_TARGET ] } " " $BUILDROOT "
cd " $BUILDROOT "
make ${ BUILDROOT_DEFCONFIGS [ $BUILDROOT_TARGET ] }
cd -
}
}
make_buildroot( ) {
make_buildroot( ) {
cp " Packaging/OpenDingux/ $BUILDROOT_DEFCONFIG " " $BUILDROOT /configs/ "
cd " $BUILDROOT "
cd " $BUILDROOT "
make " $BUILDROOT_DEFCONFIG "
BR2_JLEVEL = 0 make toolchain libzip sdl sdl_mixer sdl_ttf
BR2_JLEVEL = 0 make toolchain libzip sdl sdl_mixer sdl_ttf
cd -
cd -
}
}
@ -79,21 +70,4 @@ build() {
cd -
cd -
}
}
package( ) {
local ext = gcw0
if [ [ $TARGET = = retrofw ] ] ; then
ext = retrofw
fi
local -r tmp = " ${ BUILD_DIR } /opk "
rm -rf " $tmp "
mkdir -p " $tmp "
cp " Packaging/OpenDingux/ ${ TARGET } .desktop " " ${ tmp } /default. ${ ext } .desktop "
cp " Packaging/OpenDingux/ ${ TARGET } -manual.txt " " ${ tmp } /readme. ${ ext } .txt "
mksquashfs " ${ BUILD_DIR } /devilutionx " \
" ${ tmp } /default. ${ ext } .desktop " " ${ tmp } /readme. ${ ext } .txt " \
Packaging/resources/Diablo_32.png Packaging/resources/CharisSILB.ttf \
" ${ BUILD_DIR } /devilutionx- ${ TARGET } .opk " \
-all-root -no-xattrs -noappend -no-exports
}
main
main