3 # Configure files into packaging environment.
4 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/Makefile.in
5 ${CMAKE_BINARY_DIR}/tools/android/packaging/Makefile @ONLY)
6 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/gradle.properties
7 ${CMAKE_BINARY_DIR}/tools/android/packaging/gradle.properties COPYONLY)
8 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/build.gradle
9 ${CMAKE_BINARY_DIR}/tools/android/packaging/build.gradle COPYONLY)
10 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/gradlew
11 ${CMAKE_BINARY_DIR}/tools/android/packaging/gradlew COPYONLY)
12 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/settings.gradle
13 ${CMAKE_BINARY_DIR}/tools/android/packaging/settings.gradle COPYONLY)
14 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/gradle/wrapper/gradle-wrapper.jar
15 ${CMAKE_BINARY_DIR}/tools/android/packaging/gradle/wrapper/gradle-wrapper.jar COPYONLY)
16 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/gradle/wrapper/gradle-wrapper.properties
17 ${CMAKE_BINARY_DIR}/tools/android/packaging/gradle/wrapper/gradle-wrapper.properties COPYONLY)
18 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/xbmc/jni/Android.mk
19 ${CMAKE_BINARY_DIR}/tools/android/packaging/xbmc/jni/Android.mk COPYONLY)
20 file(WRITE ${CMAKE_BINARY_DIR}/tools/depends/Makefile.include
21 "$(PREFIX)/lib/${APP_NAME_LC}/lib${APP_NAME_LC}.so: ;\n")
23 string(REPLACE "." ";" APP_VERSION_CODE_LIST ${APP_VERSION_CODE})
24 list(GET APP_VERSION_CODE_LIST 0 major)
25 list(GET APP_VERSION_CODE_LIST 1 minor)
26 list(GET APP_VERSION_CODE_LIST 2 patch)
27 unset(APP_VERSION_CODE_LIST)
28 math(EXPR APP_VERSION_CODE_ANDROID "(${major} * 100 + ${minor}) * 1000 + ${patch}")
33 set(package_files strings.xml
40 src/XBMCBroadcastReceiver.java
41 src/XBMCInputDeviceListener.java
44 src/XBMCMediaSession.java
45 src/XBMCRecommendationBuilder.java
46 src/XBMCSearchableActivity.java
47 src/XBMCSettingsContentObserver.java
48 src/XBMCProperties.java
49 src/XBMCVideoView.java
52 src/channels/SyncChannelJobService.java
53 src/channels/SyncProgramsJobService.java
54 src/channels/model/XBMCDatabase.java
55 src/channels/model/Subscription.java
56 src/channels/util/SharedPreferencesHelper.java
57 src/channels/util/TvUtil.java
58 src/interfaces/XBMCAudioManagerOnAudioFocusChangeListener.java
59 src/interfaces/XBMCSurfaceTextureOnFrameAvailableListener.java
60 src/interfaces/XBMCNsdManagerResolveListener.java
61 src/interfaces/XBMCNsdManagerRegistrationListener.java
62 src/interfaces/XBMCNsdManagerDiscoveryListener.java
63 src/interfaces/XBMCMediaDrmOnEventListener.java
64 src/interfaces/XBMCDisplayManagerDisplayListener.java
65 src/interfaces/XBMCSpeechRecognitionListener.java
66 src/interfaces/XBMCConnectivityManagerNetworkCallback.java
67 src/model/TVEpisode.java
73 src/model/MusicVideo.java
75 src/content/XBMCFileContentProvider.java
76 src/content/XBMCMediaContentProvider.java
77 src/content/XBMCContentProvider.java
78 src/content/XBMCYTDLContentProvider.java
80 foreach(file IN LISTS package_files)
81 configure_file(${CMAKE_SOURCE_DIR}/tools/android/packaging/xbmc/${file}.in
82 ${CMAKE_BINARY_DIR}/tools/android/packaging/xbmc/${file} @ONLY)
85 # Copy files to the location expected by the Android packaging scripts.
86 add_custom_target(bundle
87 COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tools/android/packaging/media
88 ${CMAKE_BINARY_DIR}/tools/android/packaging/media
89 COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tools/android/packaging/xbmc/res
90 ${CMAKE_BINARY_DIR}/tools/android/packaging/xbmc/res
91 COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPENDS_PATH}/lib/python${PYTHON_VERSION} ${libdir}/python${PYTHON_VERSION}
92 COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPENDS_PATH}/share/${APP_NAME_LC} ${datadir}/${APP_NAME_LC}
93 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${APP_NAME_LC}>
94 ${libdir}/${APP_NAME_LC}/$<TARGET_FILE_NAME:${APP_NAME_LC}>)
95 add_dependencies(bundle ${APP_NAME_LC})
97 # This function is used to prepare a prefix expected by the Android packaging
98 # scripts. It creates a bundle_files command that is added to the bundle target.
99 function(add_bundle_file file destination relative)
100 if(NOT TARGET bundle_files)
101 file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake)
102 add_custom_target(bundle_files COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake)
103 add_dependencies(bundle bundle_files)
104 add_dependencies(bundle_files ${APP_NAME_LC})
108 # Add support for IMPORTED lib targets
109 # If we need specific properties from other target types later, we can add them
110 # here with some validity checks
111 get_target_property(imploc_file ${file} IMPORTED_LOCATION)
113 set(file ${imploc_file})
119 string(REPLACE "${relative}/" "" outfile ${file})
120 get_filename_component(file ${file} REALPATH)
121 get_filename_component(outdir ${outfile} DIRECTORY)
122 file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake
123 "file(COPY \"${file}\" DESTINATION \"${destination}/${outdir}\")\n")
124 if(file MATCHES "\\.so\\..+$")
125 get_filename_component(srcfile "${file}" NAME)
126 string(REGEX REPLACE "\\.so\\..+$" "\.so" destfile ${srcfile})
127 file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake
128 "file(RENAME \"${destination}/${outdir}/${srcfile}\" \"${destination}/${outdir}/${destfile}\")\n")
132 # Copy files into prefix
133 foreach(file IN LISTS XBT_FILES install_data)
134 string(REPLACE "${CMAKE_BINARY_DIR}/" "" file ${file})
135 add_bundle_file(${CMAKE_BINARY_DIR}/${file} ${datarootdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR})
138 # libdvdnav is currently the only LIBRARY_FILES item remaining for android
139 foreach(library IN LISTS LIBRARY_FILES)
140 add_bundle_file(${library} ${libdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR})
143 if(TARGET Shairplay::Shairplay)
144 add_bundle_file(Shairplay::Shairplay ${libdir} "")
147 # Main targets from Makefile.in
151 foreach(target apk apk-clean)
152 add_custom_target(${target}
153 COMMAND env PATH=${NATIVEPREFIX}/bin:$ENV{PATH} ${CMAKE_MAKE_PROGRAM} -j1
154 -C ${CMAKE_BINARY_DIR}/tools/android/packaging
155 CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
156 CC=${CMAKE_C_COMPILER}
159 TOOLCHAIN=${TOOLCHAIN}
161 DEPENDS_PATH=${DEPENDS_PATH}
166 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tools/android/packaging
169 if(NOT target STREQUAL apk-clean)
170 add_dependencies(${target} bundle)