From 016f567c04beb6442bb22ee032159edb19412cc5 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 1 Jul 2023 19:58:57 -0500 Subject: [PATCH] [nostalgia] Rewrite pkg-gba in Python --- Makefile | 2 +- scripts/pkg-gba | 16 ---------------- scripts/pkg-gba.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 17 deletions(-) delete mode 100755 scripts/pkg-gba create mode 100755 scripts/pkg-gba.py diff --git a/Makefile b/Makefile index 12642499..b6754e02 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif .PHONY: pkg-gba pkg-gba: install - ${ENV_RUN} ./scripts/pkg-gba sample_project + ${ENV_RUN} ${PYTHON3} ./scripts/pkg-gba.py sample_project .PHONY: run run: build diff --git a/scripts/pkg-gba b/scripts/pkg-gba deleted file mode 100755 index 3f7d1ba6..00000000 --- a/scripts/pkg-gba +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env bash - -set -e -set -u - -OS=$(uname | tr [:upper:] [:lower:]) -HOST_ENV=${OS}-$(uname -m) - -BIN=./dist/${HOST_ENV}-$(cat .current_build)/bin/ -NOSTALGIA_BIN=build/gba-*/bin/nostalgia.bin -NOSTALGIA_PROJECT=$1 -NOSTALGIA_GBA=nostalgia.gba - -cp $NOSTALGIA_BIN $NOSTALGIA_GBA -${BIN}/nost-pack -src $NOSTALGIA_PROJECT -rom-bin $NOSTALGIA_GBA -gbafix $NOSTALGIA_GBA diff --git a/scripts/pkg-gba.py b/scripts/pkg-gba.py new file mode 100755 index 00000000..7fe4f802 --- /dev/null +++ b/scripts/pkg-gba.py @@ -0,0 +1,32 @@ +#! /usr/bin/env python3 + +# +# Copyright 2016 - 2023 gary@drinkingtea.net +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import platform +import shutil +import subprocess +import sys + +os = platform.system().lower() +arch = platform.machine() +host_env = f'{os}-{arch}' + +# get current build type +with open(".current_build","r") as f: + current_build = f.readlines()[0] + +bin = f'./dist/{host_env}-{current_build}/bin/' +nostalgia_bin = 'build/gba-release/bin/nostalgia.bin' +nostalgia_project = sys.argv[1] +nostalgia_gba = 'nostalgia.gba' + +shutil.copyfile(nostalgia_bin, nostalgia_gba) +subprocess.run([ + f'{bin}/nost-pack', '-src', nostalgia_project, '-rom-bin', nostalgia_gba]) +subprocess.run(['gbafix', nostalgia_gba])