From e17a65b2fed25b4db48f3128cc88ef7c77beee01 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 13 Feb 2022 18:02:38 -0800 Subject: [PATCH] Bundle `terminfo` for standalone builds. --- script/archive-standalone-nix.sh | 2 ++ script/stage-vendor-libraries.sh | 3 +++ src/musikcube/CMakeLists.txt | 5 +++++ src/musikcube/Main.cpp | 8 ++++++++ 4 files changed, 18 insertions(+) diff --git a/script/archive-standalone-nix.sh b/script/archive-standalone-nix.sh index 5835039e3..52bbfd48c 100755 --- a/script/archive-standalone-nix.sh +++ b/script/archive-standalone-nix.sh @@ -57,6 +57,7 @@ mkdir -p $OUTDIR/lib mkdir -p $OUTDIR/plugins mkdir -p $OUTDIR/locales mkdir -p $OUTDIR/themes +mkdir -p $OUTDIR/share/terminfo cp bin/musikcube $OUTDIR cp bin/musikcubed $OUTDIR @@ -65,6 +66,7 @@ cp bin/lib/* $OUTDIR/lib cp bin/plugins/*.${DLL_EXT} $OUTDIR/plugins cp bin/locales/*.json $OUTDIR/locales cp bin/themes/*.json $OUTDIR/themes +cp -rfp bin/share/terminfo/* $OUTDIR/share/terminfo/ strip $OUTDIR/musikcube strip $OUTDIR/musikcubed diff --git a/script/stage-vendor-libraries.sh b/script/stage-vendor-libraries.sh index dcfbb8265..9c68d7d90 100755 --- a/script/stage-vendor-libraries.sh +++ b/script/stage-vendor-libraries.sh @@ -39,6 +39,9 @@ if [[ "$PLATFORM" == 'Darwin' ]]; then cp vendor/lame-bin/lib/libmp3lame.0.dylib ./bin/lib + mkdir -p ./bin/share/terminfo + cp -rfp /opt/homebrew/Cellar/ncurses/6.3/share/terminfo/* ./bin/share/terminfo + elif [[ "$PLATFORM" == 'Linux' ]]; then echo "[stage-static-vendor-libraries] staging Linux .so files..." diff --git a/src/musikcube/CMakeLists.txt b/src/musikcube/CMakeLists.txt index 66d39fdc6..b29091c8c 100644 --- a/src/musikcube/CMakeLists.txt +++ b/src/musikcube/CMakeLists.txt @@ -78,6 +78,11 @@ configure_file("musikcube.in" "musikcube" @ONLY) add_executable(musikcube ${CUBE_SRCS}) add_definitions(-DNCURSES_WIDECHAR) +if (${BUILD_STANDALONE} MATCHES "true") + # ensures the curses app uses our local copy of `terminfo` + add_definitions(-DBUILD_STANDALONE) +endif() + target_include_directories(musikcube BEFORE PRIVATE ${VENDOR_INCLUDE_DIRECTORIES}) # figure out if we have a "w" suffix or not... diff --git a/src/musikcube/Main.cpp b/src/musikcube/Main.cpp index cc574961f..e6fc3a605 100644 --- a/src/musikcube/Main.cpp +++ b/src/musikcube/Main.cpp @@ -122,6 +122,14 @@ int main(int argc, char* argv[]) { LibraryFactory::Initialize(Window::MessageQueue()); auto library = std::make_shared(); +#ifdef BUILD_STANDALONE + /* when we build a standalone binary we make sure to also package the terminfo used + by the version of ncurses we compile against. if the target system has ncurses5, the + terminfo format will not be compatible and the app will not run */ + const std::string terminfo = core::GetApplicationDirectory() + "/share/terminfo/"; + setenv("TERMINFO", terminfo.c_str(), 1); +#endif + { auto prefs = Preferences::ForComponent(core::prefs::components::Settings);