Skip to content
Snippets Groups Projects
Commit 07582002 authored by BtbN's avatar BtbN
Browse files

Improve bundle fixup

parent 2451b80e
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,8 @@ if(NOT INSTALLER_RUN) ...@@ -76,6 +76,8 @@ if(NOT INSTALLER_RUN)
add_subdirectory(obs) add_subdirectory(obs)
add_subdirectory(plugins) add_subdirectory(plugins)
add_subdirectory(test) add_subdirectory(test)
add_subdirectory(cmake/helper_subdir)
else() else()
obs_generate_multiarch_installer() obs_generate_multiarch_installer()
endif() endif()
......
...@@ -70,29 +70,15 @@ else() ...@@ -70,29 +70,15 @@ else()
add_definitions(-DOBS_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}/") add_definitions(-DOBS_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}/")
endif() endif()
function(obs_fixup_install_target target type) function(obs_finish_bundle)
if(NOT APPLE OR NOT BUILD_REDISTRIBUTABLE) if(NOT APPLE OR UNIX_STRUCTURE)
return() return()
endif() endif()
foreach(data ${ARGN}) install(CODE
if(type STREQUAL "TARGET") "if(DEFINED ENV{FIXUP_BUNDLE})
get_property(fullpath TARGET "${data}" PROPERTY LOCATION) execute_process(COMMAND \"${CMAKE_SOURCE_DIR}/cmake/osxbundle/fixup_bundle.sh\" . bin WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}\")
else() endif()")
set(fullpath "${data}")
endif()
execute_process(COMMAND otool -D "${fullpath}" OUTPUT_VARIABLE otool_out)
string(REGEX REPLACE "(\r?\n)+$" "" otool_out "${otool_out}")
string(REGEX REPLACE ".*\n" "" otool_out "${otool_out}")
string(REGEX REPLACE ".*/" "@rpath/" newpath "${otool_out}")
add_custom_command(TARGET ${target} POST_BUILD
COMMAND
install_name_tool -change "${otool_out}" "${newpath}" "$<TARGET_FILE:${target}>"
VERBATIM)
endforeach()
endfunction() endfunction()
function(obs_generate_multiarch_installer) function(obs_generate_multiarch_installer)
......
obs_finish_bundle()
#!/bin/bash
if [ "$#" != 2 ]; then
echo "usage: $0 /path/to/install/root relative/lib/destination"
exit 1
fi
cd "$1"
function buildlist() {
otool -L "$@" |
grep -E "(opt|Users)" |
perl -pe 's|^\s+(/.*)\s\(.*$|$1|' |
grep -vE ":$" |
sort -u
}
export -f buildlist
DEST="$2"
LDEST="@rpath"
TARGETS="$(find . \( -perm +111 -and -type f \))"
FOUNDLIBS="$(buildlist $TARGETS)"
PFOUNDLIBS=""
while [ "$FOUNDLIBS" != "$PFOUNDLIBS" ]; do
PFOUNDLIBS="$FOUNDLIBS"
FOUNDLIBS="$(buildlist $TARGETS $PFOUNDLIBS)"
done
INTOOL_CALL=()
for lib in $FOUNDLIBS; do
libname="$(basename "$lib")"
INTOOL_CALL+=(-change "$lib" "$LDEST/$libname")
cp "$lib" "$DEST/$libname"
echo "Fixing up dependency: $libname"
done
for lib in $FOUNDLIBS; do
libname="$(basename "$lib")"
lib="$DEST/$libname"
install_name_tool ${INTOOL_CALL[@]} -id "$LDEST/$libname" "$lib"
done
for target in $TARGETS; do
install_name_tool ${INTOOL_CALL[@]} "$target"
done
...@@ -231,4 +231,3 @@ target_link_libraries(libobs ...@@ -231,4 +231,3 @@ target_link_libraries(libobs
install_obs_core(libobs) install_obs_core(libobs)
install_obs_data(libobs ../build/data/libobs libobs) install_obs_data(libobs ../build/data/libobs libobs)
obs_fixup_install_target(libobs PATH ${Libswscale_LIBRARIES} ${Libswresample_LIBRARIES} ${Libavutil_LIBRARIES})
...@@ -113,6 +113,3 @@ target_link_libraries(obs ...@@ -113,6 +113,3 @@ target_link_libraries(obs
install_obs_core(obs) install_obs_core(obs)
install_obs_data(obs ../build/data/obs-studio obs-studio) install_obs_data(obs ../build/data/obs-studio obs-studio)
obs_fixup_install_target(obs TARGET Qt5::Widgets)
obs_fixup_install_target(obs TARGET Qt5::Gui)
obs_fixup_install_target(obs TARGET Qt5::Core)
...@@ -40,8 +40,3 @@ target_link_libraries(obs-ffmpeg ...@@ -40,8 +40,3 @@ target_link_libraries(obs-ffmpeg
install_obs_plugin(obs-ffmpeg) install_obs_plugin(obs-ffmpeg)
obs_fixup_install_target(obs-ffmpeg PATH ${Libavcodec_LIBRARIES})
obs_fixup_install_target(obs-ffmpeg PATH ${Libavutil_LIBRARIES})
obs_fixup_install_target(obs-ffmpeg PATH ${Libswscale_LIBRARIES})
obs_fixup_install_target(obs-ffmpeg PATH ${Libavformat_LIBRARIES})
obs_fixup_install_target(obs-ffmpeg PATH ${Libswresample_LIBRARIES})
...@@ -16,4 +16,3 @@ target_link_libraries(obs-x264 ...@@ -16,4 +16,3 @@ target_link_libraries(obs-x264
install_obs_plugin(obs-x264) install_obs_plugin(obs-x264)
obs_fixup_install_target(obs-x264 PATH ${Libx264_LIBRARIES})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment