diff options
author | Christian Fetzer <fetzer.ch@gmail.com> | 2016-06-06 07:16:02 +0200 |
---|---|---|
committer | Christian Fetzer <fetzer.ch@gmail.com> | 2016-06-06 07:16:02 +0200 |
commit | 3655a5335aecc48dad9b9427b3b7e86a2468a4f0 (patch) | |
tree | 2620810f85ee941cbbdcf2232eece8f4d74990a7 /project/cmake | |
parent | c350625964c161fe90df73c21c06a3ac4ddfc117 (diff) | |
parent | e25f62732f84d9ac6e11f64d0a83738808879fd3 (diff) |
Merge pull request #9895 from fetzerch/cmake_android_packaging
[cmake] Android Packaging
Diffstat (limited to 'project/cmake')
-rw-r--r-- | project/cmake/CMakeLists.txt | 22 | ||||
-rw-r--r-- | project/cmake/modules/FindBreakpad.cmake | 44 | ||||
-rw-r--r-- | project/cmake/modules/FindFFMPEG.cmake | 3 | ||||
-rw-r--r-- | project/cmake/modules/FindLibDvd.cmake | 23 | ||||
-rw-r--r-- | project/cmake/scripts/android/ArchSetup.cmake | 7 | ||||
-rw-r--r-- | project/cmake/scripts/android/Install.cmake | 118 | ||||
-rw-r--r--[l---------] | project/cmake/scripts/android/PathSetup.cmake | 34 |
7 files changed, 236 insertions, 15 deletions
diff --git a/project/cmake/CMakeLists.txt b/project/cmake/CMakeLists.txt index 3d92e8b2b7..45d9a05749 100644 --- a/project/cmake/CMakeLists.txt +++ b/project/cmake/CMakeLists.txt @@ -202,6 +202,10 @@ if(ENABLE_CCACHE) core_optional_dep(CCache) endif() +if(CORE_SYSTEM_NAME STREQUAL android) + core_optional_dep(Breakpad) +endif() + # Compile Info add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp ${CMAKE_BINARY_DIR}/addons/xbmc.addon/addon.xml @@ -311,16 +315,23 @@ add_subdirectory(${CORE_SOURCE_DIR}/xbmc/interfaces/swig build/swig) set(OTHER_FILES README.md) # main binary -add_executable(${APP_NAME_LC} ${CORE_MAIN_SOURCE} $<TARGET_OBJECTS:compileinfo> "${RESOURCES}" ${OTHER_FILES}) +if(NOT CORE_SYSTEM_NAME STREQUAL android) + add_executable(${APP_NAME_LC} ${CORE_MAIN_SOURCE} $<TARGET_OBJECTS:compileinfo> "${RESOURCES}" ${OTHER_FILES}) +else() + add_library(${APP_NAME_LC} SHARED ${CORE_MAIN_SOURCE} $<TARGET_OBJECTS:compileinfo> "${RESOURCES}" ${OTHER_FILES}) +endif() whole_archive(_MAIN_LIBRARIES ${core_DEPENDS}) target_link_libraries(${APP_NAME_LC} ${SYSTEM_LDFLAGS} ${_MAIN_LIBRARIES} ${DEPLIBS} ${CMAKE_DL_LIBS}) unset(_MAIN_LIBRARIES) add_dependencies(${APP_NAME_LC} export-files) -if(NOT WIN32) - set_target_properties(${APP_NAME_LC} PROPERTIES SUFFIX ".bin") -else() + +if(WIN32) set_target_properties(${APP_NAME_LC} PROPERTIES WIN32_EXECUTABLE ON) copy_main_dlls_to_buildtree() +elseif(CORE_SYSTEM_NAME STREQUAL android) + # Nothing +else() + set_target_properties(${APP_NAME_LC} PROPERTIES SUFFIX ".bin") endif() # testing @@ -347,6 +358,9 @@ endif() if(FFMPEG_LINK_EXECUTABLE) set(CMAKE_CXX_LINK_EXECUTABLE "${FFMPEG_LINK_EXECUTABLE}") endif() +if(FFMPEG_CREATE_SHARED_LIBRARY) + set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${FFMPEG_CREATE_SHARED_LIBRARY}") +endif() # randr if(ENABLE_X11 AND XRANDR_FOUND) diff --git a/project/cmake/modules/FindBreakpad.cmake b/project/cmake/modules/FindBreakpad.cmake new file mode 100644 index 0000000000..f56177b230 --- /dev/null +++ b/project/cmake/modules/FindBreakpad.cmake @@ -0,0 +1,44 @@ +#.rst: +# FindBreakpad +# ------------ +# Finds the Breakpad library +# +# This will will define the following variables:: +# +# BREAKPAD_FOUND - system has Breakpad +# BREAKPAD_INCLUDE_DIRS - the Breakpad include directory +# BREAKPAD_LIBRARIES - the Breakpad libraries +# +# and the following imported targets:: +# +# Breakpad::Breakpad - The Breakpad library + +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_BREAKPAD breakpad-client QUIET) +endif() + +find_path(BREAKPAD_INCLUDE_DIR google_breakpad/common/breakpad_types.h + PATH_SUFFIXES breakpad + PATHS ${PC_BREAKPAD_INCLUDEDIR}) +find_library(BREAKPAD_LIBRARY NAMES breakpad_client + PATHS ${PC_BREAKPAD_LIBDIR}) +set(BREAKPAD_VERSION ${PC_BREAKPAD_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Breakpad + REQUIRED_VARS BREAKPAD_LIBRARY BREAKPAD_INCLUDE_DIR + VERSION_VAR BREAKPAD_VERSION) + +if(BREAKPAD_FOUND) + set(BREAKPAD_LIBRARIES ${BREAKPAD_LIBRARY}) + set(BREAKPAD_INCLUDE_DIRS ${BREAKPAD_INCLUDE_DIR}) + + if(NOT TARGET Breakpad::Breakpad) + add_library(Breakpad::Breakpad UNKNOWN IMPORTED) + set_target_properties(Breakpad::Breakpad PROPERTIES + IMPORTED_LOCATION "${BREAKPAD_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${BREAKPAD_INCLUDE_DIR}") + endif() +endif() + +mark_as_advanced(BREAKPAD_INCLUDE_DIR BREAKPAD_LIBRARY) diff --git a/project/cmake/modules/FindFFMPEG.cmake b/project/cmake/modules/FindFFMPEG.cmake index caa70536bd..1c600cd09e 100644 --- a/project/cmake/modules/FindFFMPEG.cmake +++ b/project/cmake/modules/FindFFMPEG.cmake @@ -44,7 +44,7 @@ if(ENABLE_INTERNAL_FFMPEG) file(WRITE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ffmpeg/ffmpeg-link-wrapper "#!/bin/bash -if [[ $@ == *${APP_NAME_LC}.bin* || $@ == *${APP_NAME_LC}-test* ]] +if [[ $@ == *${APP_NAME_LC}.bin* || $@ == *${APP_NAME_LC}.so* || $@ == *${APP_NAME_LC}-test* ]] then avformat=`PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/lib/pkgconfig ${PKG_CONFIG_EXECUTABLE} --libs --static libavcodec` avcodec=`PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/lib/pkgconfig ${PKG_CONFIG_EXECUTABLE} --libs --static libavformat` @@ -61,6 +61,7 @@ fi") DESTINATION ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) set(FFMPEG_LINK_EXECUTABLE "${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ffmpeg-link-wrapper <CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" PARENT_SCOPE) + set(FFMPEG_CREATE_SHARED_LIBRARY "${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ffmpeg-link-wrapper <CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" PARENT_SCOPE) set(FFMPEG_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/include) list(APPEND FFMPEG_DEFINITIONS -DFFMPEG_VER_SHA=\"${FFMPEG_VER}\" -DUSE_STATIC_FFMPEG=1) diff --git a/project/cmake/modules/FindLibDvd.cmake b/project/cmake/modules/FindLibDvd.cmake index d7e8d25845..b999063941 100644 --- a/project/cmake/modules/FindLibDvd.cmake +++ b/project/cmake/modules/FindLibDvd.cmake @@ -21,15 +21,24 @@ if(NOT WIN32) endif() if(APPLE) - set(CMAKE_LD_FLAGS "-framework IOKit -framework CoreFoundation") + set(CMAKE_LD_FLAGS "-framework IOKit -framework CoreFoundation") + endif() + + set(HOST_ARCH ${ARCH}) + if(CORE_SYSTEM_NAME STREQUAL android) + if(ARCH STREQUAL arm) + set(HOST_ARCH arm-linux-androideabi) + elseif(ARCH STREQUAL i486-linux) + set(HOST_ARCH i686-linux-android) + endif() endif() if(ENABLE_DVDCSS) ExternalProject_Add(dvdcss URL ${libdvdcss_BASE_URL}/archive/${libdvdcss_VER}.tar.gz PREFIX ${CORE_BUILD_DIR}/libdvd CONFIGURE_COMMAND ac_cv_path_GIT= <SOURCE_DIR>/configure - --target=${ARCH} - --host=${ARCH} + --target=${HOST_ARCH} + --host=${HOST_ARCH} --disable-doc --enable-static --disable-shared @@ -56,8 +65,8 @@ if(NOT WIN32) ExternalProject_Add(dvdread URL ${libdvdread_BASE_URL}/archive/${libdvdread_VER}.tar.gz PREFIX ${CORE_BUILD_DIR}/libdvd CONFIGURE_COMMAND ac_cv_path_GIT= <SOURCE_DIR>/configure - --target=${ARCH} - --host=${ARCH} + --target=${HOST_ARCH} + --host=${HOST_ARCH} --enable-static --disable-shared --with-pic @@ -84,8 +93,8 @@ if(NOT WIN32) ExternalProject_Add(dvdnav URL ${libdvdnav_BASE_URL}/archive/${libdvdnav_VER}.tar.gz PREFIX ${CORE_BUILD_DIR}/libdvd CONFIGURE_COMMAND ac_cv_path_GIT= <SOURCE_DIR>/configure - --target=${ARCH} - --host=${ARCH} + --target=${HOST_ARCH} + --host=${HOST_ARCH} --enable-static --disable-shared --with-pic diff --git a/project/cmake/scripts/android/ArchSetup.cmake b/project/cmake/scripts/android/ArchSetup.cmake index 86c0f6ac46..c2a4489e5e 100644 --- a/project/cmake/scripts/android/ArchSetup.cmake +++ b/project/cmake/scripts/android/ArchSetup.cmake @@ -1,5 +1,7 @@ if(NOT CMAKE_TOOLCHAIN_FILE) message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for android. See ${PROJECT_SOURCE_DIR}/README.md") +elseif(NOT SDK_PLATFORM) + message(FATAL_ERROR "Toolchain did not define SDK_PLATFORM. Possibly outdated depends.") endif() set(ARCH_DEFINES -DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID) @@ -10,9 +12,9 @@ if(WITH_ARCH) set(ARCH ${WITH_ARCH}) else() if(CPU STREQUAL armeabi-v7a) - set(ARCH arm-linux-androideabi) + set(ARCH arm) elseif(CPU STREQUAL i686) - set(ARCH i686-linux-android) + set(ARCH i486-linux) else() message(SEND_ERROR "Unknown CPU: ${CPU}") endif() @@ -26,5 +28,6 @@ set(ENABLE_X11 OFF) set(ENABLE_EGL ON) set(ENABLE_AML ON) set(ENABLE_OPTICAL OFF) +set(ENABLE_BREAKPAD ON) list(APPEND DEPLIBS android log jnigraphics) diff --git a/project/cmake/scripts/android/Install.cmake b/project/cmake/scripts/android/Install.cmake index e69de29bb2..f0fd5662c2 100644 --- a/project/cmake/scripts/android/Install.cmake +++ b/project/cmake/scripts/android/Install.cmake @@ -0,0 +1,118 @@ +# Android packaging + +find_program(AAPT_EXECUTABLE aapt PATHS ${SDK_BUILDTOOLS_PATH}) +if(NOT AAPT_EXECUTABLE) + message(FATAL_ERROR "Could NOT find aapt executable") +endif() +find_program(DX_EXECUTABLE dx PATHS ${SDK_BUILDTOOLS_PATH}) +if(NOT DX_EXECUTABLE) + message(FATAL_ERROR "Could NOT find dx executable") +endif() +find_program(ZIPALIGN_EXECUTABLE zipalign PATHS ${SDK_BUILDTOOLS_PATH}) +if(NOT ZIPALIGN_EXECUTABLE) + message(FATAL_ERROR "Could NOT find zipalign executable") +endif() + +# Configure files into packaging environment. +if(BREAKPAD_FOUND) + set(USE_BREAKPAD 1) +endif() +configure_file(${CORE_SOURCE_DIR}/tools/android/packaging/Makefile.in + ${CMAKE_BINARY_DIR}/tools/android/packaging/Makefile @ONLY) +configure_file(${CORE_SOURCE_DIR}/tools/android/packaging/apksign + ${CMAKE_BINARY_DIR}/tools/android/packaging/apksign COPYONLY) +configure_file(${CORE_SOURCE_DIR}/tools/android/packaging/make_symbols.sh + ${CMAKE_BINARY_DIR}/tools/android/packaging/make_symbols.sh COPYONLY) +file(WRITE ${CMAKE_BINARY_DIR}/tools/depends/Makefile.include + "$(PREFIX)/lib/${APP_NAME_LC}/lib${APP_NAME_LC}.so: ;\n") + +set(package_files strings.xml + activity_main.xml + AndroidManifest.xml + src/org/xbmc/kodi/XBMCOnAudioFocusChangeListener.java + src/org/xbmc/kodi/XBMCInputDeviceListener.java + src/org/xbmc/kodi/Main.java + src/org/xbmc/kodi/XBMCSettingsContentObserver.java + src/org/xbmc/kodi/XBMCOnFrameAvailableListener.java + src/org/xbmc/kodi/XBMCVideoView.java + src/org/xbmc/kodi/Splash.java + src/org/xbmc/kodi/XBMCBroadcastReceiver.java) +foreach(file IN LISTS package_files) + configure_file(${CORE_SOURCE_DIR}/tools/android/packaging/xbmc/${file}.in + ${CMAKE_BINARY_DIR}/tools/android/packaging/xbmc/${file} @ONLY) +endforeach() + +# Copy files to the location expected by the Android packaging scripts. +add_custom_target(bundle + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CORE_SOURCE_DIR}/tools/android/packaging/media + ${CMAKE_BINARY_DIR}/tools/android/packaging/media + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CORE_SOURCE_DIR}/tools/android/packaging/xbmc/res + ${CMAKE_BINARY_DIR}/tools/android/packaging/xbmc/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPENDS_PATH}/lib/python2.7 ${libdir}/python2.7 + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${APP_NAME_LC}> + ${libdir}/${APP_NAME_LC}/$<TARGET_FILE_NAME:${APP_NAME_LC}>) +add_dependencies(bundle ${APP_NAME_LC}) + +# This function is used to prepare a prefix expected by the Android packaging +# scripts. It creates a bundle_files command that is added to the bundle target. +function(add_bundle_file file destination relative) + if(NOT TARGET bundle_files) + file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake) + add_custom_target(bundle_files COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake) + add_dependencies(bundle bundle_files) + add_dependencies(bundle_files export-files pack-skins wrap-libraries generate_json_header) + endif() + + string(REPLACE "${relative}/" "" outfile ${file}) + get_filename_component(outdir ${outfile} DIRECTORY) + file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake + "file(COPY \"${file}\" DESTINATION \"${destination}/${outdir}\")\n") +endfunction() + +# Copy files into prefix +foreach(file IN LISTS XBT_FILES install_data) + string(REPLACE "${CMAKE_BINARY_DIR}/" "" file ${file}) + add_bundle_file(${CMAKE_BINARY_DIR}/${file} ${datarootdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR}) +endforeach() + +foreach(file IN LISTS WRAP_FILES) + add_bundle_file(${CMAKE_BINARY_DIR}/${file} ${libdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR}) +endforeach() + +foreach(lib IN LISTS required_dyload dyload_optional ITEMS Shairplay) + string(TOUPPER ${lib} lib_up) + set(lib_so ${${lib_up}_SONAME}) + if(lib_so AND EXISTS ${DEPENDS_PATH}/lib/${lib_so}) + add_bundle_file(${DEPENDS_PATH}/lib/${lib_so} ${libdir} "") + endif() +endforeach() +add_bundle_file(${SMBCLIENT_LIBRARY} ${libdir} "") + +# Main targets from Makefile.in +if(CPU MATCHES i686) + set(CPU x86) + set(ARCH x86) +endif() +foreach(target apk obb apk-unsigned apk-obb apk-obb-unsigned apk-noobb apk-clean apk-sign) + add_custom_target(${target} + COMMAND PATH=${NATIVEPREFIX}/bin:$ENV{PATH} ${CMAKE_MAKE_PROGRAM} + -C ${CMAKE_BINARY_DIR}/tools/android/packaging + XBMCROOT=${CORE_SOURCE_DIR} + CC=${CMAKE_C_COMPILER} + CPU=${CPU} + ARCH=${ARCH} + PREFIX=${prefix} + NDKROOT=${NDKROOT} + SDKROOT=${SDKROOT} + SDK_PLATFORM=${SDK_PLATFORM} + STRIP=${CMAKE_STRIP} + AAPT=${AAPT_EXECUTABLE} + DX=${DX_EXECUTABLE} + ZIPALIGN=${ZIPALIGN_EXECUTABLE} + ${target} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tools/android/packaging + ) + if(NOT target STREQUAL apk-clean) + add_dependencies(${target} bundle) + endif() +endforeach() diff --git a/project/cmake/scripts/android/PathSetup.cmake b/project/cmake/scripts/android/PathSetup.cmake index 6786c1c131..69de88318e 120000..100644 --- a/project/cmake/scripts/android/PathSetup.cmake +++ b/project/cmake/scripts/android/PathSetup.cmake @@ -1 +1,33 @@ -../linux/PathSetup.cmake
\ No newline at end of file +if(NOT prefix) + set(prefix ${CMAKE_BINARY_DIR}/install) +endif() +set(CMAKE_INSTALL_PREFIX ${prefix}) +if(NOT exec_prefix) + set(exec_prefix ${prefix}) +endif() +if(NOT libdir) + set(libdir ${prefix}/lib) +endif() +if(NOT bindir) + set(bindir ${prefix}/bin) +endif() +if(NOT includedir) + set(includedir ${prefix}/include) +endif() +if(NOT datarootdir) + set(datarootdir ${prefix}/share) +endif() +if(NOT datadir) + set(datadir ${datarootdir}) +endif() + +list(APPEND final_message "-- PATH config --") +list(APPEND final_message "Prefix: ${prefix}") +list(APPEND final_message "Libdir: ${libdir}") +list(APPEND final_message "Bindir: ${bindir}") +list(APPEND final_message "Includedir: ${includedir}") +list(APPEND final_message "Datarootdir: ${datarootdir}") +list(APPEND final_message "Datadir: ${datadir}") + +set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/kodi\" + -DINSTALL_PATH=\"${datarootdir}/kodi\") |