From 21718b18502002297cddf91660cdaa70726bfeed Mon Sep 17 00:00:00 2001 From: Tristan <19311462+bluescan@users.noreply.github.com> Date: Sun, 8 Sep 2024 20:41:12 -0700 Subject: [PATCH] PACKAGE_PORTABLE will produce a TGZ on Linux and a ZIP on Windows. For development we now use PACKAGE_DEV which basically means the portable file layout but no archive generated. For all package types the About dialog will display what package type was used (Portable ZIP, Portable TGZ, Snap, Deb, Nix, or Dev). --- CMakeLists.txt | 32 ++++++++------------------------ Src/Dialogs.cpp | 8 +++++++- Src/TacentView.cpp | 4 ++-- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 221fcad..415c263 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,10 +170,15 @@ target_compile_definitions( $<$:CONFIG_RELEASE> $<$:_CRT_SECURE_NO_DEPRECATE> - $<$:PACKAGE_PORTABLE> $<$:PLATFORM_WINDOWS> $<$:PLATFORM_LINUX> + $<$:PACKAGE_PORTABLE> + $<$:PACKAGE_DEV> + $<$,$>:PACKAGE_SNAP> + $<$,$>:PACKAGE_DEB> + $<$,$>:PACKAGE_NIX> + # These shouldn't actually be necessary as there are no direct Windows API calls # in TacentView (they are abstracted away by the Tacent libraries). But just in case # anything in the viewer were to call an OS-level function, these enable the UTF-16 @@ -181,10 +186,6 @@ target_compile_definitions( $<$,$>:UNICODE> # C++ UFF-16 $<$,$>:_UNICODE> # C UTF-16 $<$,$>:TACENT_UTF16_API_CALLS> - - $<$,$>:PACKAGE_SNAP> - $<$,$>:PACKAGE_DEB> - $<$,$>:PACKAGE_NIX> ) # Set compiler option flags based on specific compiler and configuration. @@ -313,29 +314,11 @@ if (CMAKE_SYSTEM_NAME MATCHES Linux) endif() " ) -#[[ - elseif (PACKAGE_NIX) - install(DIRECTORY Linux/ DESTINATION "${VIEWER_PACKAGE_DIR}") - configure_file("Linux/create_nix.sh.in" "${VIEWER_PACKAGE_DIR}/create_nix.sh" @ONLY) - install(CODE - " - execute_process(COMMAND \"chmod\" \"a+x\" \"ViewerInstall/Package/create_nix.sh\") - execute_process( - COMMAND \"ViewerInstall/Package/create_nix.sh\" - RESULT_VARIABLE package_result - ) - if (NOT package_result EQUAL \"0\") - message(FATAL_ERROR \"Viewer -- Nix package creation failed.\") - else() - message(STATUS \"Viewer -- Nix package creation succeeded.\") - endif() - " - ) -]] endif() endif() if (CMAKE_SYSTEM_NAME MATCHES Windows) + # The portable package for Windows generates a zip. if (PACKAGE_PORTABLE) install(DIRECTORY Windows/ DESTINATION "${VIEWER_PACKAGE_DIR}") configure_file("Windows/create_zip.ps1.in" "${VIEWER_PACKAGE_DIR}/create_zip.ps1" @ONLY) @@ -356,6 +339,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Windows) endif() if (CMAKE_SYSTEM_NAME MATCHES Linux) + # The portable package for Linux generates a tgz. if (PACKAGE_PORTABLE) install(DIRECTORY Linux/ DESTINATION "${VIEWER_PACKAGE_DIR}") configure_file("Linux/create_tgz.sh.in" "${VIEWER_PACKAGE_DIR}/create_tgz.sh" @ONLY) diff --git a/Src/Dialogs.cpp b/Src/Dialogs.cpp index b4bb37c..dcb8793 100644 --- a/Src/Dialogs.cpp +++ b/Src/Dialogs.cpp @@ -50,8 +50,14 @@ void Viewer::ShowAboutPopup(bool* popen) package = "Deb"; #elif defined(PACKAGE_NIX) package = "Nix"; + #elif defined(PACKAGE_DEV) + package = "Dev"; #elif defined(PACKAGE_PORTABLE) - package = "Portable"; + #if defined(PLATFORM_WINDOWS) + package = "Portable ZIP"; + #elif defined(PLATFORM_LINUX) + package = "Portable TGZ"; + #endif #endif ImGui::Text("Platform: %s", platform.Chr()); diff --git a/Src/TacentView.cpp b/Src/TacentView.cpp index 8043743..12be3e9 100644 --- a/Src/TacentView.cpp +++ b/Src/TacentView.cpp @@ -4204,12 +4204,12 @@ int main(int argc, char** argv) tString configDir; // Directory will be created if needed. Contains the per-user viewer config file. tString cacheDir; // Directory will be created if needed. Contains cache information that is not required (but can) persist between releases. - #if defined(PLATFORM_WINDOWS) || defined(PACKAGE_PORTABLE) + #if defined(PLATFORM_WINDOWS) || defined(PACKAGE_PORTABLE) || defined(PACKAGE_DEV) { // The portable layout is also what should be set while developing -- Everything relative // to the program executable with separate sub-directories for Assets, Config, and Cache. // This keeps portable/dev out of the way of any installed packages. Windows currently only - // supports portable. + // supports the portable layout. tString progDir = tSystem::tGetProgramDir(); assetsDir = progDir + "Assets/"; configDir = progDir + "Config/";