diff --git a/.cmake/PostBuild.cmake b/.cmake/PostBuild.cmake deleted file mode 100644 index b8d221b16..000000000 --- a/.cmake/PostBuild.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# run `cmake .` again to pick up build plugin build artifacts that we need -# to file glob in. these won't be picked up on the initial build because -# they don't yet exist! -add_custom_target(postbuild ALL DEPENDS musikcube musikcubed) -add_custom_command(TARGET postbuild POST_BUILD COMMAND cmake .) - -# ensure the binaries can find libmusikcore.so, which lives in the same directory. -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - message(STATUS "[post-build] patching macOS rpath...") - add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/patch-rpath.sh") -endif() - -# copy boost and ffmpeg libraries (which can't be statically linked) to bin/ -# note this step also ensures libraries we depend upon have their rpath values -# so libraries are resolved to the local directory. -if (${BUILD_STANDALONE} MATCHES "true") - message(STATUS "[post-build] copying vendor'd libs...") - add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/stage-vendor-libraries.sh") -endif() - -# strip binaries in release mode -if (CMAKE_BUILD_TYPE MATCHES Release) - if ((NOT DEFINED DISABLE_STRIP) OR (NOT ${DISABLE_STRIP} MATCHES "true")) - message(STATUS "[post-build] binary stripping enabled for ${CMAKE_CURRENT_SOURCE_DIR}") - add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/strip-nix.sh" ${CMAKE_CURRENT_SOURCE_DIR}) - else() - message(STATUS "[post-build] DISABLE_STRIP=true, *NOT* stripping binaries.") - endif() -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index ca484090b..fc33497df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,16 @@ add_plugin("src/plugins/stockencoders" "stockencoders") # dsps add_plugin("src/plugins/supereqdsp" "supereqdsp") +add_custom_target(postbuild ALL DEPENDS musikcube musikcubed) +add_custom_command( + TARGET postbuild + POST_BUILD + COMMAND + "${CMAKE_CURRENT_SOURCE_DIR}/script/post-build.sh" + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SYSTEM_NAME} + ${CMAKE_BUILD_TYPE} + ${BUILD_STANDALONE}) + include(InstallFiles) include(GeneratePackage) -include(PostBuild) diff --git a/script/post-build.sh b/script/post-build.sh new file mode 100755 index 000000000..0d7a6fa25 --- /dev/null +++ b/script/post-build.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +CMAKE_CURRENT_SOURCE_DIR=$1 +CMAKE_SYSTEM_NAME=$2 +CMAKE_BUILD_TYPE=$3 +BUILD_STANDALONE=$4 +DISABLE_STRIP=$5 + +echo "[post-build] started..." + +if [[ "$BUILD_TYPE" == 'Release' ]]; then + echo "[post-build] BUILD_TYPE=${BUILD_TYPE}, stripping binaries" + $SCRIPT_DIR/strip-binaries.sh $DIR +else + echo "[post-build] BUILD_TYPE=${BUILD_TYPE}, not stripping" +fi + +echo "[post-build] patching library rpath entries..." +$SCRIPT_DIR/patch-rpath.sh $DIR + +echo "[post-build] staging static assets..." +mkdir -p "$CMAKE_CURRENT_SOURCE_DIR/bin/themes" +cp -rfp "$CMAKE_CURRENT_SOURCE_DIR/src/musikcube/data/themes/"*.json "$CMAKE_CURRENT_SOURCE_DIR/bin/themes" + +mkdir -p "$CMAKE_CURRENT_SOURCE_DIR/bin/locales" +cp -rfp "$CMAKE_CURRENT_SOURCE_DIR/src/musikcube/data/locales/"*.json "$CMAKE_CURRENT_SOURCE_DIR/bin/locales" + +echo "[post-build] re-running 'cmake .' to re-index compiled artifacts" +cmake . + +echo "[post-build] finished"