Use a shell script to run postinstall stuff.

This commit is contained in:
casey langen 2023-01-08 18:10:56 -08:00
parent 71d468e8fa
commit fa55035de0
3 changed files with 43 additions and 30 deletions

View File

@ -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()

View File

@ -131,6 +131,16 @@ add_plugin("src/plugins/stockencoders" "stockencoders")
# dsps # dsps
add_plugin("src/plugins/supereqdsp" "supereqdsp") 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(InstallFiles)
include(GeneratePackage) include(GeneratePackage)
include(PostBuild)

32
script/post-build.sh Executable file
View File

@ -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"