From 4c9278a927f6210542fc445945f4f07731bd0d13 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Wed, 25 Sep 2024 19:51:39 +0300 Subject: [PATCH] changed how building is triggered, now there is a [twn] shell script that is exptected to be in PATH. also physfs and libxm cmake targets no longer recompiled per every target, but shared --- CMakeLists.txt | 4 ++-- apps/platformer/CMakeLists.txt | 5 +---- apps/scenery/CMakeLists.txt | 5 +---- apps/scenery/build.sh | 7 ------- apps/template/CMakeLists.txt | 5 +---- apps/template/build.sh | 3 --- {apps/platformer => tools}/build.sh | 2 +- tools/twn | 15 +++++++++++++++ 8 files changed, 21 insertions(+), 25 deletions(-) delete mode 100755 apps/scenery/build.sh delete mode 100755 apps/template/build.sh rename {apps/platformer => tools}/build.sh (84%) create mode 100755 tools/twn diff --git a/CMakeLists.txt b/CMakeLists.txt index b183690..a260110 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,8 +51,8 @@ set(PHYSFS_ARCHIVE_QPAK OFF) set(PHYSFS_ARCHIVE_SLB OFF) set(PHYSFS_ARCHIVE_ISO9660 OFF) set(PHYSFS_ARCHIVE_VDF OFF) -add_subdirectory(third-party/physfs SYSTEM) -add_subdirectory(third-party/libxm SYSTEM) +add_subdirectory(third-party/physfs ${CMAKE_CURRENT_BINARY_DIR}/third-party/physfs SYSTEM) +add_subdirectory(third-party/libxm ${CMAKE_CURRENT_BINARY_DIR}/third-party/libxm SYSTEM) if(LINUX) diff --git a/apps/platformer/CMakeLists.txt b/apps/platformer/CMakeLists.txt index 1c3d3ec..9298f7a 100644 --- a/apps/platformer/CMakeLists.txt +++ b/apps/platformer/CMakeLists.txt @@ -6,10 +6,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -# add root townengine cmake file -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) - add_subdirectory(../../ ../../../.build) -endif() +add_subdirectory($ENV{TWNROOT} $ENV{TWNBUILDDIR}) set(SOURCE_FILES game.c diff --git a/apps/scenery/CMakeLists.txt b/apps/scenery/CMakeLists.txt index 2151142..7f7e4bb 100644 --- a/apps/scenery/CMakeLists.txt +++ b/apps/scenery/CMakeLists.txt @@ -6,10 +6,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -# add root townengine cmake file -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) - add_subdirectory(../../ ../../../.build) -endif() +add_subdirectory($ENV{TWNROOT} $ENV{TWNBUILDDIR}) set(SOURCE_FILES game.c diff --git a/apps/scenery/build.sh b/apps/scenery/build.sh deleted file mode 100755 index aefa755..0000000 --- a/apps/scenery/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/env sh - -if [ $1 = "web" ]; then - emcmake cmake -B .build-web "${@:2}" && cmake --build .build-web -else - cmake -B .build "$@" && cmake --build .build -fi diff --git a/apps/template/CMakeLists.txt b/apps/template/CMakeLists.txt index 3a34666..b8110d3 100644 --- a/apps/template/CMakeLists.txt +++ b/apps/template/CMakeLists.txt @@ -6,10 +6,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -# add root townengine cmake file -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) - add_subdirectory(../../ ../../../.build) -endif() +add_subdirectory($ENV{TWNROOT} $ENV{TWNBUILDDIR}) set(SOURCE_FILES game.c diff --git a/apps/template/build.sh b/apps/template/build.sh deleted file mode 100755 index 45ab8a7..0000000 --- a/apps/template/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/env sh - -cmake -B .build "$@" && cmake --build .build diff --git a/apps/platformer/build.sh b/tools/build.sh similarity index 84% rename from apps/platformer/build.sh rename to tools/build.sh index aefa755..d7f57c9 100755 --- a/apps/platformer/build.sh +++ b/tools/build.sh @@ -1,6 +1,6 @@ #!/bin/env sh -if [ $1 = "web" ]; then +if [ "$1" = "web" ]; then emcmake cmake -B .build-web "${@:2}" && cmake --build .build-web else cmake -B .build "$@" && cmake --build .build diff --git a/tools/twn b/tools/twn new file mode 100755 index 0000000..cb70d7f --- /dev/null +++ b/tools/twn @@ -0,0 +1,15 @@ +#!/bin/env sh +# townengine tooling interface + +set +e + +toolpath="$(dirname -- "${BASH_SOURCE[0]}")" +export TWNROOT=$(realpath "$toolpath"/../) +export TWNBUILDDIR=$(realpath "$toolpath"/../.build) + +case "$1" in + build ) "$toolpath"/build.sh + ;; + * ) echo "Unknown command." + ;; +esac