Skip to content

Commit

Permalink
[emapp] fixed a bug release build of plugin_ffmpeg is corrupted (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkrn authored Apr 1, 2023
1 parent b4e616c commit 5209acf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
10 changes: 5 additions & 5 deletions emapp/plugins/ffmpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
option(${PROJECT_NAME_PREFIX}_INSTALL_FFMPEG_PLUGIN OFF)
if(${PROJECT_NAME_PREFIX}_INSTALL_FFMPEG_PLUGIN)
nanoem_cmake_get_install_path("ffmpeg" FFMPEG_BASE_PATH FFMPEG_INSTALL_PATH_DEBUG FFMPEG_INSTALL_PATH_RELEASE)
find_library(AVCODEC_LIBRARY NAMES avcodec PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(AVFORMAT_LIBRARY NAMES avformat PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(AVUTIL_LIBRARY NAMES avutil PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(SWRESAMPLE_LIBRARY NAMES swresample PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(SWSCALE_LIBRARY NAMES swscale PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(AVCODEC_LIBRARY NAMES avcodec.58 avcodec PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(AVFORMAT_LIBRARY NAMES avformat.58 avformat PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(AVUTIL_LIBRARY NAMES avutil.56 avutil PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(SWRESAMPLE_LIBRARY NAMES swresample.3 swresample PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_library(SWSCALE_LIBRARY NAMES swscale.5 swscale PATH_SUFFIXES lib bin PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_path(AVCODEC_INCLUDE_PATH NAMES libavcodec/avcodec.h PATH_SUFFIXES include PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_path(AVFORMAT_INCLUDE_PATH NAMES libavformat/avformat.h PATH_SUFFIXES include PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
find_path(AVUTIL_INCLUDE_PATH NAMES libavutil/avutil.h PATH_SUFFIXES include PATHS ${FFMPEG_INSTALL_PATH_RELEASE} NO_DEFAULT_PATH)
Expand Down
11 changes: 5 additions & 6 deletions macos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ install(CODE "
endfunction()
# construct app
set(app_path \"\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app\")
file(REMOVE_RECURSE \"\${CMAKE_CURRENT_BINARY_DIR}/Contents/PlugIns\")
file(GLOB_RECURSE INSTALLED_PLUGINS \"\${app_path}/Contents/PlugIns/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
fixup_bundle(\"\${app_path}\" \"\${INSTALLED_PLUGINS}\" \"${LIBRARY_PATHS}\")
file(GLOB_RECURSE installed_plugins \"\${app_path}/Contents/PlugIns/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
fixup_bundle(\"\${app_path}\" \"\${installed_plugins}\" \"${LIBRARY_PATHS}\")
# generate debug info
set(NANOEM_ENABLE_SENTRY_SDK ${NANOEM_ENABLE_SENTRY_SDK})
if(NANOEM_ENABLE_SENTRY_SDK AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sentry.touch)
message(STATUS \"Generating \${app_path}/Contents/MacOS/${PROJECT_NAME} to ${PROJECT_NAME}.app.dSYM\")
execute_process(COMMAND dsymutil \${app_path}/Contents/MacOS/${PROJECT_NAME} -o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.app.dSYM)
foreach(item \${INSTALLED_PLUGINS})
foreach(item \${installed_plugins})
message(STATUS \"Generating \${item} to ${PROJECT_NAME}.app.dSYM\")
execute_process(COMMAND dsymutil \${item} -o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.app.dSYM)
endforeach()
Expand All @@ -179,11 +178,11 @@ install(CODE "
if(CMAKE_INSTALL_DO_STRIP)
execute_process(COMMAND xcrun strip \${app_path}/Contents/MacOS/nanoem)
execute_process(COMMAND xcrun strip \${app_path}/Contents/PlugIns/crashpad_handler)
foreach(item \${INSTALLED_PLUGINS})
foreach(item \${installed_plugins})
execute_process(COMMAND xcrun strip \${item})
endforeach()
endif()
" COMPONENT Runtime)
" COMPONENT Unspecified)

set(CPACK_GENERATOR "DragNDrop")
set(CPACK_STRIP_FILES ON)
Expand Down
22 changes: 18 additions & 4 deletions scripts/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ function(compile_ffmpeg _cmake_build_type _generator _toolset_option _arch_optio
list(APPEND _ffmpeg_build_options "--disable-devices")
list(APPEND _ffmpeg_build_options "--disable-protocols")
list(APPEND _ffmpeg_build_options "--enable-shared")
list(APPEND _ffmpeg_build_options "--enable-rpath")
list(APPEND _ffmpeg_build_options "--enable-small")
list(APPEND _ffmpeg_build_options "--enable-swresample")
list(APPEND _ffmpeg_build_options "--enable-swscale")
Expand Down Expand Up @@ -498,14 +497,29 @@ function(compile_ffmpeg _cmake_build_type _generator _toolset_option _arch_optio
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${_interm_arm64_path}/include ${_build_path}/install-root/include)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${_interm_arm64_path}/share ${_build_path}/install-root/share)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_build_path}/install-root/lib)
file(GLOB _libraries ${_interm_arm64_path}/lib/lib*.dylib)
foreach(_item ${_libraries})
get_filename_component(_filename ${_item} NAME)
set(_avcodec "libavcodec.58.dylib")
set(_avformat "libavformat.58.dylib")
set(_avutil "libavutil.56.dylib")
set(_swresample "libswresample.3.dylib")
set(_swscale "libswscale.5.dylib")
foreach(_filename ${_avcodec};${_avformat};${_avutil};${_swresample};${_swscale})
execute_process(COMMAND lipo -create -output
"${_build_path}/install-root/lib/${_filename}"
"${_interm_arm64_path}/lib/${_filename}"
"${_interm_x86_64_path}/lib/${_filename}")
endforeach()
set(_source "${_interm_x86_64_path}/lib")
set(_dest "${_build_path}/install-root/lib")
execute_process(COMMAND install_name_tool -id "${_dest}/${_avutil}" "${_dest}/${_avutil}")
execute_process(COMMAND install_name_tool -id "${_dest}/${_avcodec}" "${_dest}/${_avcodec}")
execute_process(COMMAND install_name_tool -change "${_source}/${_avutil}" "${_dest}/${_avutil}" "${_dest}/${_avcodec}")
execute_process(COMMAND install_name_tool -id "${_dest}/${_avformat}" "${_dest}/${_avformat}")
execute_process(COMMAND install_name_tool -change "${_source}/${_avcodec}" "${_dest}/${_avcodec}" "${_dest}/${_avformat}")
execute_process(COMMAND install_name_tool -change "${_source}/${_avutil}" "${_dest}/${_avutil}" "${_dest}/${_avformat}")
execute_process(COMMAND install_name_tool -id "${_dest}/${_swresample}" "${_dest}/${_swresample}")
execute_process(COMMAND install_name_tool -change "${_source}/${_avutil}" "${_dest}/${_avutil}" "${_dest}/${_swresample}")
execute_process(COMMAND install_name_tool -id "${_dest}/${_swscale}" "${_dest}/${_swscale}")
execute_process(COMMAND install_name_tool -change "${_source}/${_avutil}" "${_dest}/${_avutil}" "${_dest}/${_swscale}")
endif()
else()
file(MAKE_DIRECTORY ${_build_path})
Expand Down

0 comments on commit 5209acf

Please sign in to comment.