diff --git a/Makefile b/Makefile index b89d583e..1f73dc3d 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ git-push-ox: git subtree push --prefix=deps/oxlib ox-master master .PHONY: pkg-gba -pkg-gba: build-pack build-gba-player - ${BC_CMD_ENVRUN} ${BC_PY3} ./util/scripts/pkg-gba.py sample_project ${BC_VAR_PROJECT_NAME_CAP} +pkg-gba: build-studio build-gba-player + ${BC_CMD_ENVRUN} ${BC_PY3} ./util/scripts/pkg-gba.py ${PROJECT_STUDIO} sample_project ${BC_VAR_PROJECT_NAME_CAP} .PHONY: pkg-mac pkg-mac: install @@ -47,11 +47,6 @@ build-gba-player: build-player: ${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} ${BC_VAR_PROJECT_NAME_CAP} -.PHONY: build-pack -build-pack: - cmake --build ./build/${BC_VAR_CURRENT_BUILD} --target ${BC_VAR_PROJECT_NAME}-pack - - .PHONY: run run: build-player ${PROJECT_PLAYER} sample_project diff --git a/src/nostalgia/CMakeLists.txt b/src/nostalgia/CMakeLists.txt index 986c3f16..b733f122 100644 --- a/src/nostalgia/CMakeLists.txt +++ b/src/nostalgia/CMakeLists.txt @@ -41,7 +41,6 @@ if(${NOSTALGIA_BUILD_PLAYER}) endif() if(NOT BUILDCORE_TARGET STREQUAL "gba") - add_subdirectory(tools) if(${NOSTALGIA_BUILD_STUDIO_APP}) add_subdirectory(studio) endif() diff --git a/src/nostalgia/tools/CMakeLists.txt b/src/nostalgia/tools/CMakeLists.txt deleted file mode 100644 index d14b7c05..00000000 --- a/src/nostalgia/tools/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -add_executable(nostalgia-pack) - -target_link_libraries( - nostalgia-pack - KeelPack-AppLib - NostalgiaKeelModules - NostalgiaProfile - OlympicApplib -) - -if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT WIN32) - # enable LTO - set_property(TARGET nostalgia-pack PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) -endif() - -install( - TARGETS - nostalgia-pack - RUNTIME DESTINATION - bin -) diff --git a/src/olympic/applib/applib.cpp b/src/olympic/applib/applib.cpp index f3292e5d..fa0d7cb8 100644 --- a/src/olympic/applib/applib.cpp +++ b/src/olympic/applib/applib.cpp @@ -44,6 +44,7 @@ namespace olympic { ox::StringLiteral appVersion{OLYMPIC_APP_VERSION}; ox::StringLiteral appId{OLYMPIC_APP_ID}; +ox::StringLiteral projectName{OLYMPIC_PROJECT_NAME}; } ox::Error run( diff --git a/src/olympic/keel/include/keel/pack-packlib.hpp b/src/olympic/keel/include/keel/pack-packlib.hpp new file mode 100644 index 00000000..7bfe06c4 --- /dev/null +++ b/src/olympic/keel/include/keel/pack-packlib.hpp @@ -0,0 +1,18 @@ +/* + * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include +#include +#include + +namespace keel { + +ox::Error pack( + ox::StringViewCR projectDir, + ox::StringViewCR projectDataDir, + ox::SpanView argv) noexcept; + +} diff --git a/src/olympic/keel/src/CMakeLists.txt b/src/olympic/keel/src/CMakeLists.txt index 8ef7a85f..6a81654e 100644 --- a/src/olympic/keel/src/CMakeLists.txt +++ b/src/olympic/keel/src/CMakeLists.txt @@ -41,20 +41,15 @@ install( if(TURBINE_BUILD_TYPE STREQUAL "Native") add_library( - KeelPack-AppLib - pack-applib.cpp + KeelPack-PackLib + pack-packlib.cpp ) target_include_directories( - KeelPack-AppLib PUBLIC + KeelPack-PackLib PUBLIC ../include ) - target_compile_definitions( - KeelPack-AppLib PUBLIC - OLYMPIC_LOAD_KEEL_MODULES=1 - OLYMPIC_APP_NAME="Keel Pack" - ) target_link_libraries( - KeelPack-AppLib + KeelPack-PackLib Keel OxClArgs OxClaw @@ -62,7 +57,7 @@ if(TURBINE_BUILD_TYPE STREQUAL "Native") ) install( TARGETS - KeelPack-AppLib + KeelPack-PackLib DESTINATION LIBRARY DESTINATION lib ARCHIVE DESTINATION lib diff --git a/src/olympic/keel/src/pack-applib.cpp b/src/olympic/keel/src/pack-packlib.cpp similarity index 89% rename from src/olympic/keel/src/pack-applib.cpp rename to src/olympic/keel/src/pack-packlib.cpp index a76da0bb..b35450d0 100644 --- a/src/olympic/keel/src/pack-applib.cpp +++ b/src/olympic/keel/src/pack-packlib.cpp @@ -92,22 +92,20 @@ static ox::Error pack( return {}; } -ox::Error run( - [[maybe_unused]] ox::StringView const project, - [[maybe_unused]] ox::StringView const appName, - ox::StringView const projectDataDir, +namespace keel { + +ox::Error pack( + ox::StringViewCR projectDir, + ox::StringViewCR projectDataDir, ox::SpanView const argv) noexcept { ox::ClArgs const args(argv); - auto const argSrc = args.getString("src", ""); auto const argRomBin = args.getString("rom-bin", ""); auto const argManifest = args.getString("manifest", ""); - if (argSrc == "") { - oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n"); - return ox::Error(1, "must specify a source directory"); - } if (argRomBin == "") { oxErr("\033[31;1;1merror:\033[0m must specify a path for ROM file\n"); return ox::Error(1, "must specify a path for preload file"); } - return pack(argSrc, argRomBin, argManifest, projectDataDir); + return ::pack(projectDir, argRomBin, argManifest, projectDataDir); } + +} \ No newline at end of file diff --git a/src/olympic/studio/applib/src/app.cpp b/src/olympic/studio/applib/src/app.cpp index 831a03b7..139e9435 100644 --- a/src/olympic/studio/applib/src/app.cpp +++ b/src/olympic/studio/applib/src/app.cpp @@ -15,6 +15,7 @@ #include #include "subcommands/change-format/change-format.hpp" +#include "subcommands/pack/pack.hpp" #include "configfile.hpp" #include "font.hpp" @@ -46,10 +47,8 @@ static struct: Module { ox::Vector commands() const final { return { - { - "change-format", - cmdChangeFormat, - } + { "change-format", cmdChangeFormat, }, + { "pack", cmdPack, }, }; } } constexpr mod; @@ -152,6 +151,7 @@ static ox::Error run( ox::StringView const moduleId = args[3]; ox::StringView const subCmd = args[4]; for (auto const m : modules()) { + oxDebug(m->id()); if (m->id() == moduleId) { for (auto const &c : m->commands()) { if (c.name == subCmd) { diff --git a/src/olympic/studio/applib/src/subcommands/CMakeLists.txt b/src/olympic/studio/applib/src/subcommands/CMakeLists.txt index 737afc34..ae2f88b2 100644 --- a/src/olympic/studio/applib/src/subcommands/CMakeLists.txt +++ b/src/olympic/studio/applib/src/subcommands/CMakeLists.txt @@ -2,9 +2,11 @@ target_sources( StudioAppLib PRIVATE change-format/change-format.cpp + pack/pack.cpp ) target_link_libraries( StudioAppLib PUBLIC OxClArgs + KeelPack-PackLib ) \ No newline at end of file diff --git a/src/olympic/studio/applib/src/subcommands/pack/pack.cpp b/src/olympic/studio/applib/src/subcommands/pack/pack.cpp new file mode 100644 index 00000000..d59fa73b --- /dev/null +++ b/src/olympic/studio/applib/src/subcommands/pack/pack.cpp @@ -0,0 +1,19 @@ +/* + * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +#include "pack.hpp" + +namespace olympic { +extern ox::StringLiteral projectName; +} + +namespace studio { + +ox::Error cmdPack(Project &project, ox::SpanView args) noexcept { + return keel::pack(project.projectPath(), olympic::projectName, args); +} + +} diff --git a/src/olympic/studio/applib/src/subcommands/pack/pack.hpp b/src/olympic/studio/applib/src/subcommands/pack/pack.hpp new file mode 100644 index 00000000..8d64557c --- /dev/null +++ b/src/olympic/studio/applib/src/subcommands/pack/pack.hpp @@ -0,0 +1,13 @@ +/* + * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#pragma once + +#include + +namespace studio { + +ox::Error cmdPack(Project &project, ox::SpanView args) noexcept; + +} diff --git a/util/scripts/pkg-gba.py b/util/scripts/pkg-gba.py index 614faabf..46df7fa5 100755 --- a/util/scripts/pkg-gba.py +++ b/util/scripts/pkg-gba.py @@ -8,36 +8,30 @@ # 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}' def run(args: list[str]): if subprocess.run(args).returncode != 0: sys.exit(1) -# get the current build type -with open(".current_build", "r") as f: - current_build = f.readlines()[0] -if current_build[-1] == '\n': - current_build = current_build[:-1] -project_dir = sys.argv[1] -project_name = sys.argv[2] -bin = f'./build/{host_env}-{current_build}/bin/' +studio_path = sys.argv[1] +project_dir = sys.argv[2] +project_name = sys.argv[3] project_bin = f'build/gba-release/bin/{project_name}.bin' project_gba = f'{project_name}.gba' project_manifest = f'{project_name.lower()}-manifest.json' shutil.copyfile(project_bin, project_gba) run([ - f'{bin}/{project_name.lower()}-pack', - '-src', project_dir, + studio_path, + 'cmd', + project_dir, + 'net.drinkingtea.studio', + 'pack', '-rom-bin', project_gba, '-manifest', project_manifest]) run(['gbafix', project_gba])