Browse Source

Proper segregation between Gradle modules.

Yao Wei Tjong 姚伟忠 7 years ago
parent
commit
d827f5ebfb

+ 9 - 9
.travis.yml

@@ -318,14 +318,14 @@ env:
     - CCACHE_COMPRESS=1
     - CCACHE_MAXSIZE=100M
   matrix:
-    - ORG_GRADLE_PROJECT_abi=x86 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-28 PLATFORM=android-17
-    - ORG_GRADLE_PROJECT_abi=x86 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-28 PLATFORM=android-17
-    - ORG_GRADLE_PROJECT_abi=x86_64 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-28 PLATFORM=android-21
-    - ORG_GRADLE_PROJECT_abi=x86_64 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-28 PLATFORM=android-21
-    - ORG_GRADLE_PROJECT_abi=armeabi-v7a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-25 PLATFORM=android-17
-    - ORG_GRADLE_PROJECT_abi=armeabi-v7a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-25 PLATFORM=android-17
-    - ORG_GRADLE_PROJECT_abi=arm64-v8a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-25 PLATFORM=android-21
-    - ORG_GRADLE_PROJECT_abi=arm64-v8a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-25 PLATFORM=android-21
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=x86 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-28 PLATFORM=android-17
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=x86 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-28 PLATFORM=android-17
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=x86_64 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-28 PLATFORM=android-21
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=x86_64 ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-28 PLATFORM=android-21
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=armeabi-v7a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-25 PLATFORM=android-17
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=armeabi-v7a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-25 PLATFORM=android-17
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=arm64-v8a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=STATIC SYS_IMG=android-25 PLATFORM=android-21
+    - ORG_GRADLE_PROJECT_ANDROID_ABI=arm64-v8a ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE=SHARED SYS_IMG=android-25 PLATFORM=android-21
 stage: split ABI build configuration
 before_script:
   - rake ci_timer
@@ -333,7 +333,7 @@ before_script:
   - export COMMIT_MESSAGE=$(git log --format=%B -n1 $TRAVIS_COMMIT)
   - export TAG=$(git describe --exact-match $TRAVIS_COMMIT 2>/dev/null); if [[ $TAG =~ [[:digit:]]+\.[[:digit:]]+ ]]; then export RELEASE_TAG=$TAG; fi
   - if [[ $RELEASE_TAG ]] || (! [[ $TRAVIS_BRANCH =~ [^-]+-[^-]+-CI ]] && echo $COMMIT_MESSAGE |grep -cq '\[ci package\]'); then export PACKAGE_UPLOAD=1; fi
-  - touch $HOME/.android/repositories.cfg && (while :; do echo 'y'; sleep 1; done) |sdkmanager 'tools' 'platform-tools' 'build-tools;28.0.1' "platforms;$PLATFORM" 'ndk-bundle' 'cmake;3.6.4111459' "system-images;$SYS_IMG;google_apis;$ORG_GRADLE_PROJECT_abi"
+  - touch $HOME/.android/repositories.cfg && (while :; do echo 'y'; sleep 1; done) |sdkmanager 'tools' 'platform-tools' 'build-tools;28.0.1' "platforms;$PLATFORM" 'ndk-bundle' 'cmake;3.6.4111459' "system-images;$SYS_IMG;google_apis;$ORG_GRADLE_PROJECT_ANDROID_ABI"
   - export PATH=$(whereis -b ccache |grep -o '\S*lib\S*'):$PATH ANDROID_CCACHE=$(which ccache)
   - if [[ "$ORG_GRADLE_PROJECT_URHO3D_LIB_TYPE" == "STATIC" ]]; then export EXTRA_PROPS='-P URHO3D_SAMPLES=0'; fi
   - rake ci_setup_cache

+ 15 - 19
CMake/Modules/FindUrho3D.cmake

@@ -20,8 +20,9 @@
 # THE SOFTWARE.
 #
 
-# Find Urho3D include directories and libraries in the Urho3D SDK installation or build tree
-# This module should be able to find Urho3D automatically when the SDK is installed in a system-wide default location
+# Find Urho3D include directories and libraries in the Urho3D SDK installation or build tree or in Android library
+# This module should be able to find Urho3D automatically when the SDK is installed in a system-wide default location or
+# when the Urho3D Android library has been correctly declared as project dependency
 # If the SDK installation location is non-default or the Urho3D library is not installed at all (i.e. still in its build tree) then
 #   use URHO3D_HOME environment variable or build option to specify the location of the non-default SDK installation or build tree
 # When setting URHO3D_HOME variable, it should be set to a parent directory containing both the "include" and "lib" subdirectories
@@ -32,7 +33,7 @@
 #  URHO3D_INCLUDE_DIRS
 #  URHO3D_LIBRARIES
 #  URHO3D_VERSION
-#  URHO3D_64BIT (may be used as input variable for multilib-capable compilers; must be anyway specified as input variable for MSVC due to CMake/VS generator limitation)
+#  URHO3D_64BIT (may be used as input variable for multilib-capable compilers; must always be specified as input variable for MSVC due to CMake/VS generator limitation)
 #  URHO3D_LIB_TYPE (may be used as input variable as well to limit the search of library type)
 #  URHO3D_OPENGL
 #  URHO3D_SSE
@@ -72,8 +73,11 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D AND TARGET Urho3D)
     set (FOUND_MESSAGE "Found Urho3D: as CMake target")
     set (URHO3D_COMPILE_RESULT TRUE)
 else ()
-    # Library location would be searched (based on URHO3D_HOME variable if provided and in system-wide default location)
-    if (NOT URHO3D_HOME AND DEFINED ENV{URHO3D_HOME})
+    if (ANDROID AND GRADLE_BUILD_DIR)
+        # Urho3D AAR is a universal library
+        set (URHO3D_HOME ${GRADLE_BUILD_DIR}/tree/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
+    elseif (NOT URHO3D_HOME AND DEFINED ENV{URHO3D_HOME})
+        # Library location would be searched (based on URHO3D_HOME variable if provided and in system-wide default location)
         file (TO_CMAKE_PATH "$ENV{URHO3D_HOME}" URHO3D_HOME)
     endif ()
     # Convert to integer literal to match it with our internal cache representation; it also will be used as foreach loop control variable
@@ -151,7 +155,7 @@ else ()
         if (URHO3D_LUA)
             list (APPEND URHO3D_INCLUDE_DIRS ${URHO3D_BASE_INCLUDE_DIR}/ThirdParty/Lua${JIT})
         endif ()
-        # Intentionally do no cache the URHO3D_VERSION as it has potential to change frequently
+        # Intentionally do not cache the URHO3D_VERSION as it has potential to change frequently
         file (STRINGS ${URHO3D_BASE_INCLUDE_DIR}/librevision.h URHO3D_VERSION REGEX "^const char\\* revision=\"[^\"]*\".*$")
         string (REGEX REPLACE "^const char\\* revision=\"([^\"]*)\".*$" \\1 URHO3D_VERSION "${URHO3D_VERSION}")      # Stringify to guard against empty variable
         # The library type is baked into export header only for MSVC as it has no other way to differentiate them, fortunately both types cannot coexist for MSVC anyway unlike other compilers
@@ -159,14 +163,6 @@ else ()
             file (STRINGS ${URHO3D_BASE_INCLUDE_DIR}/Urho3D.h MSVC_STATIC_LIB REGEX "^#define URHO3D_STATIC_DEFINE$")
         endif ()
     endif ()
-    # For Android platform, search in path based on the chosen Android ABI
-    if (ANDROID)
-        if (URHO3D_HOME)
-            set (URHO3D_LIB_SEARCH_HINT HINTS ${URHO3D_HOME}/libs/${ANDROID_NDK_ABI_NAME})
-        else ()
-            set (URHO3D_LIB_SEARCH_HINT HINTS /usr/local/libs/${ANDROID_NDK_ABI_NAME})
-        endif ()
-    endif ()
     if (URHO3D_64BIT AND MINGW AND CMAKE_CROSSCOMPILING)
         # For 64-bit MinGW on Linux host system, force to search in 'lib64' path even when the Windows platform is not defaulted to use it
         set_property (GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
@@ -175,10 +171,10 @@ else ()
     foreach (ABI_64BIT RANGE ${URHO3D_64BIT} 0)
         # Set to search in 'lib' or 'lib64' based on the ABI being tested
         set_property (GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${ABI_64BIT})    # Leave this global property setting afterwards, do not restore it to its previous value
-        find_library (URHO3D_LIBRARIES NAMES Urho3D ${URHO3D_LIB_SEARCH_HINT} PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT} DOC "Urho3D library directory")
+        find_library (URHO3D_LIBRARIES NAMES Urho3D PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT} DOC "Urho3D library directory")
         if (WIN32)
             # For Windows platform, give a second chance to search for a debug version of the library
-            find_library (URHO3D_LIBRARIES_DBG NAMES Urho3D_d ${URHO3D_LIB_SEARCH_HINT} PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT})
+            find_library (URHO3D_LIBRARIES_DBG NAMES Urho3D_d PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT})
             set (URHO3D_LIBRARIES_REL ${URHO3D_LIBRARIES})
             if (NOT URHO3D_LIBRARIES)
                 set (URHO3D_LIBRARIES ${URHO3D_LIBRARIES_DBG})
@@ -301,7 +297,7 @@ else ()
     if (URHO3D_LIBRARIES_REL AND URHO3D_LIBRARIES_DBG)
         set (URHO3D_LIBRARIES ${URHO3D_LIBRARIES_REL} ${URHO3D_LIBRARIES_DBG})
     endif ()
-    # Ensure auto-discovered variables always prefail over user settings in all the subsequent cmake rerun (even without redoing try_compile)
+    # Ensure auto-discovered variables always prevail over user settings in all the subsequent cmake rerun (even without redoing try_compile)
     foreach (VAR ${AUTO_DISCOVER_VARS})
         if (DEFINED ${VAR} AND DEFINED AUTO_DISCOVERED_${VAR})  # Cannot combine these two ifs due to variable expansion error when it is not defined
             if ((${VAR} AND NOT ${AUTO_DISCOVERED_${VAR}}) OR (NOT ${VAR} AND ${AUTO_DISCOVERED_${VAR}}))
@@ -338,13 +334,13 @@ if (URHO3D_INCLUDE_DIRS AND URHO3D_LIBRARIES AND URHO3D_LIB_TYPE AND URHO3D_COMP
     set (URHO3D_FOUND_LIB_TYPE ${URHO3D_LIB_TYPE} CACHE INTERNAL "Lib type (if specified) when Urho3D library was last found")
 elseif (Urho3D_FIND_REQUIRED)
     if (ANDROID)
-        set (NOT_FOUND_MESSAGE "For Android platform, double check if you have specified to use the same ANDROID_ABI as the Urho3D library in the build tree or SDK.")
+        set (NOT_FOUND_MESSAGE "For Android platform, double check if you have specified to use the same ANDROID_ABI as the Urho3D Android Library, especially when you are not using universal AAR.")
     endif ()
     if (URHO3D_LIB_TYPE)
         set (NOT_FOUND_MESSAGE "Ensure the specified location contains the Urho3D library of the requested library type. ${NOT_FOUND_MESSAGE}")
     endif ()
     message (FATAL_ERROR
-        "Could NOT find compatible Urho3D library in Urho3D SDK installation or build tree. "
+        "Could NOT find compatible Urho3D library in Urho3D SDK installation or build tree or in Android library. "
         "Use URHO3D_HOME environment variable or build option to specify the location of the non-default SDK installation or build tree. ${NOT_FOUND_MESSAGE} ${TRY_COMPILE_OUT}")
 endif ()
 

+ 23 - 7
CMake/Modules/UrhoCommon.cmake

@@ -197,6 +197,7 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
         set (DEFAULT_LUA_RAW TRUE)
     endif ()
     cmake_dependent_option (URHO3D_LUA_RAW_SCRIPT_LOADER "Prefer loading raw script files from the file system before falling back on Urho3D resource cache. Useful for debugging (e.g. breakpoints), but less performant (Lua/LuaJIT only)" "${DEFAULT_LUA_RAW}" URHO3D_LUA FALSE)
+    option (URHO3D_PLAYER "Build Urho3D script player" TRUE)
     option (URHO3D_SAMPLES "Build sample applications" TRUE)
     option (URHO3D_UPDATE_SOURCE_TREE "Enable commands to copy back some of the generated build artifacts from build tree to source tree to facilitate devs to push them as part of a commit (for library devs with push right only)")
     option (URHO3D_BINDINGS "Enable API binding generation support for script subystems")
@@ -790,6 +791,7 @@ endmacro ()
 
 # Macro for setting symbolic link on platform that supports it
 macro (create_symlink SOURCE DESTINATION)
+    cmake_parse_arguments (ARG "FALLBACK_TO_COPY" "BASE" "" ${ARGN})
     # Make absolute paths so they work more reliably on cmake-gui
     if (IS_ABSOLUTE ${SOURCE})
         set (ABS_SOURCE ${SOURCE})
@@ -799,7 +801,11 @@ macro (create_symlink SOURCE DESTINATION)
     if (IS_ABSOLUTE ${DESTINATION})
         set (ABS_DESTINATION ${DESTINATION})
     else ()
-        set (ABS_DESTINATION ${CMAKE_BINARY_DIR}/${DESTINATION})
+        if (ARG_BASE)
+            set (ABS_DESTINATION ${ARG_BASE}/${DESTINATION})
+        else ()
+            set (ABS_DESTINATION ${CMAKE_BINARY_DIR}/${DESTINATION})
+        endif ()
     endif ()
     if (CMAKE_HOST_WIN32)
         if (IS_DIRECTORY ${ABS_SOURCE})
@@ -814,7 +820,7 @@ macro (create_symlink SOURCE DESTINATION)
                 string (REPLACE / \\ BACKWARD_ABS_SOURCE ${ABS_SOURCE})
                 execute_process (COMMAND cmd /C mklink ${SLASH_D} ${BACKWARD_ABS_DESTINATION} ${BACKWARD_ABS_SOURCE} OUTPUT_QUIET ERROR_QUIET)
             endif ()
-        elseif (${ARGN} STREQUAL FALLBACK_TO_COPY)
+        elseif (ARG_FALLBACK_TO_COPY)
             if (SLASH_D)
                 set (COMMAND COMMAND ${CMAKE_COMMAND} -E copy_directory ${ABS_SOURCE} ${ABS_DESTINATION})
             else ()
@@ -1033,7 +1039,12 @@ macro (define_resource_dirs)
         endforeach ()
         set (GLOB_DIRS ${GLOB_DIRS_WITH_SENTINEL})      # Convert strings back to lists, extra sentinels are harmless
     endif ()
-    list (APPEND RESOURCE_DIRS ${GLOB_DIRS} ${ARG_EXTRA_DIRS})
+    list (APPEND RESOURCE_DIRS ${GLOB_DIRS})
+    foreach (DIR ${ARG_EXTRA_DIRS})
+        if (EXISTS ${DIR})
+            list (APPEND RESOURCE_DIRS ${DIR})
+        endif ()
+    endforeach ()
     source_group ("Resource Dirs" FILES ${RESOURCE_DIRS})
     # Populate all the variables required by resource packaging, if the build option is enabled
     if (URHO3D_PACKAGING AND RESOURCE_DIRS)
@@ -1357,7 +1368,12 @@ macro (install_header_files)
 
         # Reparse the arguments for the create_symlink macro to "install" the header files in the build tree
         if (NOT ARG_BASE)
-            set (ARG_BASE ${CMAKE_BINARY_DIR})  # Use build tree as base path
+            # Use build tree as base path
+            if (ANDROID AND GRADLE_BUILD_DIR)
+                set (ARG_BASE ${GRADLE_BUILD_DIR}/tree/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
+            else ()
+                set (ARG_BASE ${CMAKE_BINARY_DIR})
+            endif ()
         endif ()
         foreach (INSTALL_SOURCE ${INSTALL_SOURCES})
             if (NOT IS_ABSOLUTE ${INSTALL_SOURCE})
@@ -1385,7 +1401,7 @@ macro (install_header_files)
                         if (NOT EXISTS ${ARG_BASE}/${PATH})
                             file (MAKE_DIRECTORY ${ARG_BASE}/${PATH})
                         endif ()
-                        create_symlink (${INSTALL_SOURCE}${NAME} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
+                        create_symlink (${INSTALL_SOURCE}${NAME} ${ARG_DESTINATION}/${NAME} BASE ${ARG_BASE} FALLBACK_TO_COPY)
                         if (ARG_ACCUMULATE)
                             list (APPEND ${ARG_ACCUMULATE} ${ARG_DESTINATION}/${NAME})
                         endif ()
@@ -1395,12 +1411,12 @@ macro (install_header_files)
                     if (NOT IS_SYMLINK ${ARG_DESTINATION} AND NOT CMAKE_HOST_WIN32)
                         execute_process (COMMAND ${CMAKE_COMMAND} -E remove_directory ${ARG_DESTINATION})
                     endif ()
-                    create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION} FALLBACK_TO_COPY)
+                    create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION} BASE ${ARG_BASE} FALLBACK_TO_COPY)
                 endif ()
             else ()
                 # Source is a file (it could also be actually a directory to be treated as a "file", i.e. for creating symlink pointing to the directory)
                 get_filename_component (NAME ${INSTALL_SOURCE} NAME)
-                create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
+                create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION}/${NAME} BASE ${ARG_BASE} FALLBACK_TO_COPY)
                 if (ARG_ACCUMULATE)
                     list (APPEND ${ARG_ACCUMULATE} ${ARG_DESTINATION}/${NAME})
                 endif ()

+ 6 - 1
CMakeLists.txt

@@ -188,7 +188,12 @@ if (URHO3D_MACOSX_BUNDLE OR (APPLE AND ARM))
 endif ()
 
 # Setup SDK-like include dir in the build tree for building the Urho3D library
-file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
+if (ANDROID AND GRADLE_BUILD_DIR)
+    set (THIRD_PARTY_INCLUDE_DIR ${GRADLE_BUILD_DIR}/tree/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}/${DEST_INCLUDE_DIR}/ThirdParty)
+else ()
+    set (THIRD_PARTY_INCLUDE_DIR ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
+endif ()
+file (MAKE_DIRECTORY ${THIRD_PARTY_INCLUDE_DIR})
 
 # Urho3D source
 add_subdirectory (Source)

+ 1 - 0
Docs/GettingStarted.dox

@@ -115,6 +115,7 @@ A number of build options can be defined when invoking the build scripts or when
 |URHO3D_PHYSICS       |1|Enable Physics support|
 |URHO3D_NAVIGATION    |1|Enable Navigation support|
 |URHO3D_URHO2D        |1|Enable 2D rendering & physics support|
+|URHO3D_PLAYER        |1|Build Urho3D script player|
 |URHO3D_SAMPLES       |1|Build sample applications|
 |URHO3D_TOOLS         |1|Build tools (native, RPI, and ARM on Linux only)|
 |URHO3D_EXTRAS        |0|Build extras (native, RPI, and ARM on Linux only)|

+ 1 - 5
Source/CMakeLists.txt

@@ -143,11 +143,7 @@ endif ()
 add_subdirectory (Tools)
 
 # Urho3D samples
-# Samples are built on iOS/tvOS platform too when enabled. Currently there is no available mechanism to package each sample apps into individual *.apk
-# for Android platform, so we deploy all samples into one apk and use a simple list view activity launcher to select the sample to run
-if (URHO3D_SAMPLES)
-    add_subdirectory (Samples)
-endif ()
+add_subdirectory (Samples)
 
 # Urho3D extras
 if (URHO3D_EXTRAS)

+ 1 - 1
Source/Clang-Tools/CMakeLists.txt

@@ -55,7 +55,7 @@ else ()
     file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
 endif ()
 
-# LLVM/Clang is assumed to be installed in a system-wide location when not explicitily defined using env-var
+# LLVM/Clang is assumed to be installed in a system-wide location when not explicitly defined using env-var
 if (DEFINED ENV{LLVM_CLANG_ROOT})
     set (CMAKE_SYSROOT $ENV{LLVM_CLANG_ROOT})
 endif ()

+ 4 - 0
Source/Samples/CMakeLists.txt

@@ -20,6 +20,10 @@
 # THE SOFTWARE.
 #
 
+if (NOT URHO3D_SAMPLES)
+    return ()
+endif ()
+
 # Set project name
 project (Urho3D-Samples)
 

+ 1 - 1
Source/Tools/CMakeLists.txt

@@ -33,7 +33,7 @@ include_directories (${URHO3D_INCLUDE_DIRS})
 # In order to test the player on Web platform built using Emscripten, the request parameters need to be parsed into Module['argument'] (see https://github.com/kripken/emscripten/blob/master/src/emrun_prejs.js for inspiration)
 # The CTest could "run" the Urho3DPlayer.html with script name as parameter, thanks to emrun performing this parsing automatically
 # In a production environment, however, the request parameters parsing has to be done by the application itself one way or another
-if (URHO3D_ANGELSCRIPT OR URHO3D_LUA${JIT})
+if (URHO3D_ANGELSCRIPT OR URHO3D_LUA)
     # Add Urho3DPlayer as target only when one of the supported scripting subsystems is enabled
     add_subdirectory (Urho3DPlayer)
 endif ()

+ 4 - 0
Source/Tools/Urho3DPlayer/CMakeLists.txt

@@ -20,6 +20,10 @@
 # THE SOFTWARE.
 #
 
+if (NOT URHO3D_PLAYER)
+    return ()
+endif ()
+
 # Define target name
 set (TARGET_NAME Urho3DPlayer)
 

+ 12 - 10
Source/Urho3D/CMakeLists.txt

@@ -296,21 +296,21 @@ endif ()
 list (APPEND SOURCE_FILES ${GEN_CPP_FILES} ${ALL_OBJ_FILES} librevision.h Urho3D.h ${SYMBOLIC_SOURCES})
 
 # Define dependency libs
-# Add include directories to find the precompiled header, export header, and installed headers from thirdparty libs
-set (INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
+# Add include directories to find the precompiled header, export header, and installed headers from third-party libs
+set (INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${THIRD_PARTY_INCLUDE_DIR})
 if (URHO3D_PHYSICS)
     # Bullet library depends on its own include dir to be added in the header search path
     # This is more practical than patching its header files in many places to make them work with relative path
-    list (APPEND INCLUDE_DIRS ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty/Bullet)
+    list (APPEND INCLUDE_DIRS ${THIRD_PARTY_INCLUDE_DIR}/Bullet)
 endif ()
 if (URHO3D_NAVIGATION)
     # DetourTileCache and DetourCrowd libraries depend on Detour's include dir to be added in the header search path
-    list (APPEND INCLUDE_DIRS ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty/Detour)
+    list (APPEND INCLUDE_DIRS ${THIRD_PARTY_INCLUDE_DIR}/Detour)
 endif ()
 if (URHO3D_LUA)
     # Lua/LuaJIT library depends on its own include dir to be added in the header search path
     # This is more practical than patching its header files in many places to make them work with relative path
-    list (APPEND INCLUDE_DIRS ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty/Lua${JIT})
+    list (APPEND INCLUDE_DIRS ${THIRD_PARTY_INCLUDE_DIR}/Lua${JIT})
 endif ()
 # Workaround for GCC 5.4 and above when building a SHARED lib type for Linux platform to fix the undefined symbol "__cpu_model" issue (see #1519)
 if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.3.1 AND CMAKE_SYSTEM_NAME STREQUAL Linux AND URHO3D_LIB_TYPE STREQUAL SHARED)  # 5.3.1 was the last known good version
@@ -551,11 +551,13 @@ endif ()
 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Urho3D.pc DESTINATION ${DEST_PKGCONFIG_DIR} ${RENAME})
 
 # Define post build steps
-if (ANDROID_NDK_GDB)
-    # Copy the library while it still has debug symbols for ndk-gdb
-    add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${TARGET_NAME}> ${NDK_GDB_SOLIB_PATH}
-        COMMENT "Copying Urho3D library with debug symbols to ${NDK_GDB_SOLIB_PATH} directory")
-    add_make_clean_files (${NDK_GDB_SOLIB_PATH}/$<TARGET_FILE_NAME:${TARGET_NAME}>)
+if (ANDROID AND GRADLE_BUILD_DIR)
+    # Copy the library to URHO3D_HOME directory
+    set (ABI_LIB_DIR ${GRADLE_BUILD_DIR}/tree/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}/lib)
+    file (MAKE_DIRECTORY ${ABI_LIB_DIR})
+    add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${TARGET_NAME}> ${ABI_LIB_DIR}
+        COMMENT "Copying Urho3D library to URHO3D_HOME directory")
+    add_make_clean_files (${ABI_LIB_DIR}/$<TARGET_FILE_NAME:${TARGET_NAME}>)
 endif ()
 if (URHO3D_LIB_TYPE STREQUAL SHARED AND (ANDROID OR ARM))
     # Strip the output shared library for embedded devices

+ 48 - 0
android/launcher-app/CMakeLists.txt

@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2008-2018 the Urho3D project.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+# Set CMake minimum version and CMake policy required by UrhoCommon module
+cmake_minimum_required (VERSION 3.2.3)
+if (COMMAND cmake_policy)
+    # Libraries linked via full path no longer produce linker search paths
+    cmake_policy (SET CMP0003 NEW)
+    # INTERFACE_LINK_LIBRARIES defines the link interface
+    cmake_policy (SET CMP0022 NEW)
+    # Disallow use of the LOCATION target property - so we set to OLD as we still need it
+    cmake_policy (SET CMP0026 OLD)
+    # MACOSX_RPATH is enabled by default
+    cmake_policy (SET CMP0042 NEW)
+    # Honor the visibility properties for SHARED target types only
+    cmake_policy (SET CMP0063 OLD)
+endif ()
+
+# Set project name
+project (Launcher)
+
+# Set CMake modules search path
+set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../CMake/Modules)
+
+# Include UrhoCommon.cmake module after setting project name
+include (UrhoCommon)
+
+add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/../../Source/Tools/Urho3DPlayer Urho3DPlayer)
+add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/../../Source/Samples Samples)

+ 47 - 4
android/launcher-app/build.gradle.kts

@@ -35,8 +35,39 @@ android {
         targetSdkVersion(27)
         applicationId = "com.github.urho3d.launcher"
         versionCode = 1
-        versionName = "1.0"
+        versionName = "1.8-SNAPSHOT"
         testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
+        externalNativeBuild {
+            cmake {
+                arguments.apply {
+                    add("-DANDROID_CCACHE=${System.getenv("ANDROID_CCACHE")}")
+                    add("-DGRADLE_BUILD_DIR=${findProject(":android:urho3d-lib")?.buildDir}")
+                    addAll(listOf(
+                            "URHO3D_LIB_TYPE",
+                            // TODO: "URHO3D_PACKAGING",
+                            "URHO3D_ANGELSCRIPT",
+                            "URHO3D_LUA")
+                            .filter { project.hasProperty(it) }
+                            .map { "-D$it=${project.property(it)}" }
+                    )
+                    // In order to get clean module segregation, only build player/samples here
+                    // unless it is explicitly excluded
+                    addAll(listOf(
+                            "URHO3D_PLAYER",
+                            "URHO3D_SAMPLES")
+                            .map { "-D$it=${if (project.hasProperty(it)) project.property(it) else "1"}" }
+                    )
+                }
+            }
+        }
+        splits {
+            abi {
+                isEnable = project.hasProperty("ANDROID_ABI")
+                reset()
+                include(*(if (isEnable) project.property("ANDROID_ABI") as String else "")
+                        .split(',').toTypedArray())
+            }
+        }
     }
     buildTypes {
         getByName("release") {
@@ -44,9 +75,10 @@ android {
             proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
         }
     }
-    compileOptions {
-        setSourceCompatibility(JavaVersion.VERSION_1_8)
-        setTargetCompatibility(JavaVersion.VERSION_1_8)
+    externalNativeBuild {
+        cmake {
+            path = project.file("CMakeLists.txt")
+        }
     }
 }
 
@@ -58,3 +90,14 @@ dependencies {
     androidTestImplementation("com.android.support.test:runner:1.0.2")
     androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
 }
+
+afterEvaluate {
+    android.buildTypes.forEach {
+        val config = it.name.capitalize()
+        tasks {
+            "externalNativeBuild$config" {
+                mustRunAfter(":android:urho3d-lib:externalNativeBuild$config")
+            }
+        }
+    }
+}

+ 1 - 0
android/launcher-app/src/main/assets/Autoload

@@ -0,0 +1 @@
+../../../../../bin/Autoload

+ 1 - 0
android/launcher-app/src/main/assets/Data

@@ -0,0 +1 @@
+../../../../../bin/Data

+ 52 - 47
android/urho3d-lib/build.gradle.kts

@@ -20,7 +20,6 @@
 // THE SOFTWARE.
 //
 
-import java.nio.file.Files
 import org.jetbrains.kotlin.config.KotlinCompilerVersion
 
 plugins {
@@ -35,12 +34,14 @@ android {
         minSdkVersion(17)
         targetSdkVersion(27)
         versionCode = 1
-        versionName = "1.0"
+        versionName = "1.8-SNAPSHOT"
         testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
         externalNativeBuild {
             cmake {
                 arguments.apply {
                     add("-DANDROID_CCACHE=${System.getenv("ANDROID_CCACHE")}")
+                    add("-DGRADLE_BUILD_DIR=$buildDir")
+                    // Pass along matching Gradle properties as CMake build options
                     addAll(listOf(
                             "URHO3D_LIB_TYPE",
                             "URHO3D_ANGELSCRIPT",
@@ -56,22 +57,26 @@ android {
                             "URHO3D_DATABASE_SQLITE",
                             "URHO3D_WEBP",
                             "URHO3D_FILEWATCHER",
-                            "URHO3D_PACKAGING",
                             "URHO3D_PROFILING",
                             "URHO3D_LOGGING",
-                            "URHO3D_THREADING",
-                            "URHO3D_SAMPLES")
+                            "URHO3D_THREADING")
                             .filter { project.hasProperty(it) }
-                            .map { "-D$it=${project.property(it) as String}" }
+                            .map { "-D$it=${project.property(it)}" }
                     )
+                    // In order to get clean module segregation, always exclude player/samples from AAR
+                    addAll(listOf(
+                            "URHO3D_PLAYER",
+                            "URHO3D_SAMPLES"
+                    ).map { "-D$it=0" })
                 }
+                targets.add("Urho3D")
             }
         }
         splits {
             abi {
-                isEnable = project.hasProperty("abi")
+                isEnable = project.hasProperty("ANDROID_ABI")
                 reset()
-                include(*(if (isEnable) project.property("abi") as String else "")
+                include(*(if (isEnable) project.property("ANDROID_ABI") as String else "")
                         .split(',').toTypedArray())
             }
         }
@@ -87,11 +92,6 @@ android {
             path = project.file("../../CMakeLists.txt")
         }
     }
-    sourceSets {
-        getByName("main") {
-            assets.srcDir(project.file("../../bin"))
-        }
-    }
 }
 
 dependencies {
@@ -102,45 +102,50 @@ dependencies {
     androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
 }
 
-// This is a hack - workaround Android plugin for Gradle's bug where it erroneously dereference
-// the symlink causing the actual file being deleted when it attempts to remove stale contents
 afterEvaluate {
-    val symlinkDirs = listOf("include")       // This list is specific to Urho3D
+    // Part of the our external native build tree resided in Gradle buildDir
+    // When the buildDir is cleaned then we need a way to re-configure that part back
+    // It is achieved by ensuring that CMake configuration phase is rerun
     tasks {
-        "generateJsonModelDebug" {
-            doFirst { symlinkWorkaround("debug", true, symlinkDirs) }
-            doLast { symlinkWorkaround("debug", false, symlinkDirs) }
-        }
-        "generateJsonModelRelease" {
-            doFirst { symlinkWorkaround("release", true, symlinkDirs) }
-            doLast { symlinkWorkaround("release", false, symlinkDirs) }
+        getByName("clean") {
+            doLast {
+                delete(android.externalNativeBuild.cmake.buildStagingDirectory
+                        ?: project.file(".externalNativeBuild"))
+            }
         }
     }
-}
-//
-fun symlinkWorkaround(config: String, keep: Boolean, symlinkDirs: List<String>) {
-    val stagingDir = android.externalNativeBuild.cmake.buildStagingDirectory
-            ?: project.file(".externalNativeBuild")
-    val oriDir = File(stagingDir, "cmake/$config")
-    val bakDir = File(stagingDir, ".cmake-$config")
-    bakDir.mkdir()
-    oriDir.list().forEach { abi ->
-        symlinkDirs.forEach { dir ->
-            if (keep) {
-                // Keep the dir somewhere else that the original Gradle task doesn't touch it
-                File(oriDir, "$abi/$dir").renameTo(File(bakDir, "$abi-$dir"))
-            } else {
-                // It is OK to fail here because the dir might get regenerated back by original task
-                File(bakDir, "$abi-$dir").renameTo(File(oriDir, "$abi/$dir"))
+
+    // This is a hack - workaround Android plugin for Gradle not providing way to bundle extra "stuffs"
+    android.buildTypes.forEach {
+        val config = it.name.capitalize()
+        tasks {
+            create<Zip>("zipBuildTree$config") {
+                val aarDir = File(buildDir, "outputs/aar")
+                val aarName = "${project.name}-${it.name}.aar"
+                val aarFile = File(aarDir, aarName)
+                archiveName = "$aarName.new"
+                destinationDir = aarDir
+                outputs.upToDateWhen { false }
+                from(zipTree(aarFile))
+                dependsOn("zipBuildTreeConfigurer$config")
+                doLast { archivePath.renameTo(aarFile) }
+            }
+            create("zipBuildTreeConfigurer$config") {
+                val externalNativeBuildDir = File(buildDir, "tree/$config")
+                doLast {
+                    tasks.getByName<Zip>("zipBuildTree$config") {
+                        onlyIf { tasks["assemble$config"].state.executed }
+                        externalNativeBuildDir.list()?.forEach { abi ->
+                            listOf("include", "lib").forEach {
+                                from(File(externalNativeBuildDir, "$abi/$it")) {
+                                    into("tree/$config/$abi/$it")
+                                }
+                            }
+                        }
+                    }
+                }
             }
+            "assemble$config" { finalizedBy("zipBuildTree$config") }
         }
     }
-    if (!keep) {
-        // Whatever remaining in the backup dir must be disposed of with respect to symlink
-        bakDir.walkBottomUp()
-                .filterNot { it.parentFile.isSymlink() }
-                .forEach { Files.delete(it.toPath()) }
-    }
 }
-//
-fun File.isSymlink() = absoluteFile != canonicalFile

+ 1 - 0
android/urho3d-lib/src/main/assets/CoreData

@@ -0,0 +1 @@
+../../../../../bin/CoreData

+ 1 - 1
build.gradle.kts

@@ -32,7 +32,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath("com.android.tools.build:gradle:3.1.3")
+        classpath("com.android.tools.build:gradle:3.2.0-beta04")
         classpath(kotlin("gradle-plugin", kotlinVersion))
 
         // NOTE: Do not place your application dependencies here; they belong

+ 0 - 4
gradle.properties

@@ -35,7 +35,3 @@ org.gradle.jvmargs=-Xmx3G
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true
-
-# Configuration on demand is not supported by the current version of the Android plugin
-# with Gradle 4.6 or above.
-org.gradle.configureondemand=false

BIN
gradle/wrapper/gradle-wrapper.jar


+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip