From 55cd16312232fd571f1fb406bb2d510351e94a5d Mon Sep 17 00:00:00 2001 From: octorock <79596758+octorock@users.noreply.github.com> Date: Sat, 11 Sep 2021 10:59:03 +0200 Subject: [PATCH] Extract assets to build folder for version --- Makefile | 12 +++++++++--- tools/asset_extractor/asset_extractor.py | 10 +++++----- tools/scaninc/scaninc.cpp | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 563ee3a7..71d9fb86 100644 --- a/Makefile +++ b/Makefile @@ -56,14 +56,16 @@ ASM_SUBDIR = asm DATA_ASM_SUBDIR = data SONG_SUBDIR = sound/songs MID_SUBDIR = sound/songs/midi +ASSET_SUBDIR = assets C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR) ASM_BUILDDIR = $(OBJ_DIR)/$(ASM_SUBDIR) DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR) SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR) MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR) +ASSET_BUILDDIR = $(OBJ_DIR)/$(ASSET_SUBDIR) -ASFLAGS := -mcpu=arm7tdmi --defsym $(GAME_VERSION)=1 --defsym REVISION=$(REVISION) --defsym $(GAME_LANGUAGE)=1 +ASFLAGS := -mcpu=arm7tdmi --defsym $(GAME_VERSION)=1 --defsym REVISION=$(REVISION) --defsym $(GAME_LANGUAGE)=1 -I $(ASSET_BUILDDIR) CC1 := tools/agbcc/bin/agbcc override CFLAGS += -O2 -Wimplicit -Wparentheses -Werror -Wno-multichar @@ -147,7 +149,11 @@ MAKEFLAGS += --no-print-directory AUTO_GEN_TARGETS := -all: extractassets $(ROM) +# TODO do we really need this extra step just so that extractassets always runs at first? +all: extractassets + @$(MAKE) target + +target: $(ROM) @$(SHA1) $(BUILD_NAME).sha1 # kept for backwards compat @@ -157,7 +163,7 @@ compare: $(ROM) setup: $(TOOLDIRS) extractassets: - python tools/asset_extractor/asset_extractor.py $(GAME_VERSION) + python tools/asset_extractor/asset_extractor.py $(GAME_VERSION) $(ASSET_BUILDDIR) $(TOOLDIRS): @$(MAKE) -C $@ diff --git a/tools/asset_extractor/asset_extractor.py b/tools/asset_extractor/asset_extractor.py index 2f095f3d..053be4e3 100644 --- a/tools/asset_extractor/asset_extractor.py +++ b/tools/asset_extractor/asset_extractor.py @@ -6,7 +6,7 @@ import yaml verbose = False -def extract_assets(variant): +def extract_assets(variant, assets_folder): print(f'Extract assets from {variant}.') map = { 'USA': 'baserom.gba', @@ -37,7 +37,7 @@ def extract_assets(variant): # This asset is not used in the current variant continue - path = asset['path'] + path = os.path.join(assets_folder, asset['path']) if os.path.isfile(path): if verbose: print(f'{path} already extracted.') @@ -83,10 +83,10 @@ def extract_tileset(path): def main(): if len(sys.argv) == 1: extract_assets('USA') - elif len(sys.argv) == 2: - extract_assets(sys.argv[1].upper()) + elif len(sys.argv) == 3: + extract_assets(sys.argv[1].upper(), sys.argv[2]) else: - print('Usage: asset_extractor.py VARIANT') + print('Usage: asset_extractor.py VARIANT BUILD_FOLDER') if __name__ == '__main__': main() \ No newline at end of file diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp index b95cbd03..823865af 100755 --- a/tools/scaninc/scaninc.cpp +++ b/tools/scaninc/scaninc.cpp @@ -93,7 +93,8 @@ int main(int argc, char **argv) includeDirs.push_back(file.GetSrcDir()); for (auto incbin : file.GetIncbins()) { - dependencies.insert(incbin); + // TODO add incbin dependencies in correct folder? + //dependencies.insert(incbin); } for (auto include : file.GetIncludes()) {