[video] Fix bookmark thumbnails of rotated videos
[xbmc.git] / cmake / scripts / android / Install.cmake
blobf88957cc9febad2d512b4fb2fe728222c247bda9
1 # Android packaging
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}")
29 unset(major)
30 unset(minor)
31 unset(patch)
33 set(package_files strings.xml
34                   colors.xml
35                   searchable.xml
36                   AndroidManifest.xml
37                   build.gradle
38                   src/Splash.java
39                   src/Main.java
40                   src/XBMCBroadcastReceiver.java
41                   src/XBMCInputDeviceListener.java
42                   src/XBMCJsonRPC.java
43                   src/XBMCMainView.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
50                   src/XBMCFile.java
51                   src/XBMCURIUtils.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
68                   src/model/Movie.java
69                   src/model/TVShow.java
70                   src/model/File.java
71                   src/model/Album.java
72                   src/model/Song.java
73                   src/model/MusicVideo.java
74                   src/model/Media.java
75                   src/content/XBMCFileContentProvider.java
76                   src/content/XBMCMediaContentProvider.java
77                   src/content/XBMCContentProvider.java
78                   src/content/XBMCYTDLContentProvider.java
79                   )
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)
83 endforeach()
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})
105   endif()
107   if(TARGET ${file})
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)
112     if(imploc_file)
113       set(file ${imploc_file})
114     else()
115       return()
116     endif()
117   endif()
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")
129   endif()
130 endfunction()
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})
136 endforeach()
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})
141 endforeach()
143 if(TARGET Shairplay::Shairplay)
144   add_bundle_file(Shairplay::Shairplay ${libdir} "")
145 endif()
147 # Main targets from Makefile.in
148 if(CPU MATCHES i686)
149   set(CPU x86)
150 endif()
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}
157               CPU=${CPU}
158               HOST=${HOST}
159               TOOLCHAIN=${TOOLCHAIN}
160               PREFIX=${prefix}
161               DEPENDS_PATH=${DEPENDS_PATH}
162               NDKROOT=${NDKROOT}
163               SDKROOT=${SDKROOT}
164               STRIP=${CMAKE_STRIP}
165               ${target}
166       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tools/android/packaging
167       VERBATIM
168   )
169   if(NOT target STREQUAL apk-clean)
170     add_dependencies(${target} bundle)
171   endif()
172 endforeach()