瀏覽代碼

Lua/LuaJIT host tool building while cross-compiling in one go.
For Travis CI - reenable CI build with Lua/LuaJIT build option turned on.

Yao Wei Tjong 姚伟忠 11 年之前
父節點
當前提交
4db162eb62

+ 7 - 1
.bash_helpers.sh

@@ -20,6 +20,9 @@
 # THE SOFTWARE.
 #
 
+# Detect markers in the build tree
+if [ -f $BUILD/.fix-scm ]; then FIX_SCM=1; fi
+
 # Define helpers
 post_cmake() {
     if [ $ECLIPSE ]; then
@@ -59,12 +62,15 @@ post_cmake() {
                         -r "/projectDescription/buildSpec/buildCommandNew" -v "buildCommand" \
                         $BUILD/.project
                 done
+            fi
 
-            elif [ $FIX_SCM ]; then
+            if [ $FIX_SCM ]; then
                 # Copy the Eclipse project setting files to Source tree in order to fix it so that Eclipse's SCM feature works again
                 echo -- post_cmake: Move Eclipse project setting files to $SOURCE and fix them to reenable Eclipse SCM feature
                 # Leave the original copy in the build tree
                 for f in .project .cproject; do cp $BUILD/$f $SOURCE; done
+                # Set a marker in the build tree that Eclipse project has been fixed
+                touch $BUILD/.fix-scm
 
                 #
                 # Replace [Source directory] linked resource to [Build] instead

+ 9 - 6
CMake/Modules/FindUrho3D.cmake

@@ -29,11 +29,11 @@
 #  URHO3D_LIBRARIES_DBG
 #
 #
-# For Urho3D project, the Urho3D library "source tree" and "build tree" paths are already known.
+# For internal Urho3D project, the Urho3D library "source tree" and "build tree" paths are already known.
 #
 # For external project that attempts to use the Urho3D source and build trees:
 #   1) Set the URHO3D_HOME environment variable to poin to the location of Urho3D "source tree"
-#   2) Set the URHO3D_BUILD_TREE environment variable to point to the location of Urho3D "build tree"
+#   2) Optionally, set the URHO3D_BUILD_TREE environment variable to point to the location of Urho3D "build tree" (if it differs from "source tree")
 # This module would not assume the location of the build tree anymore as in the previous versions.
 #
 # For external project that attempts to use the installed Urho3D SDK:
@@ -67,12 +67,15 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D AND TARGET Urho3D)
     set (IS_INTERNAL 1)
 elseif (NOT URHO3D_HOME AND DEFINED ENV{URHO3D_HOME})
     # The URHO3D_HOME variable should point to Urho3D's source tree, even when Urho3D is being used in an external project which has its own source tree
-    if (NOT DEFINED ENV{URHO3D_BUILD_TREE})
-        message (FATAL_ERROR "Could not determine the Urho3D build tree location. Use URHO3D_BUILD_TREE environment variable to specify the location of the build tree.")
-    endif ()
     file (TO_CMAKE_PATH "$ENV{URHO3D_HOME}" URHO3D_HOME)
     set (URHO3D_HOME ${URHO3D_HOME} CACHE PATH "Path to Urho3D source tree")
-    file (TO_CMAKE_PATH "$ENV{URHO3D_BUILD_TREE}" URHO3D_BUILD_TREE)
+    if (DEFINED ENV{URHO3D_BUILD_TREE})
+        # Out-of-source build tree
+        file (TO_CMAKE_PATH "$ENV{URHO3D_BUILD_TREE}" URHO3D_BUILD_TREE)
+    else ()
+        # Assume to be non-out-source build tree
+        set (URHO3D_BUILD_TREE ${URHO3D_HOME})
+    endif ()
     set (URHO3D_BUILD_TREE ${URHO3D_BUILD_TREE} CACHE PATH "Path to Urho3D build tree")
 endif ()
 

+ 12 - 7
CMakeLists.txt

@@ -29,11 +29,14 @@ cmake_minimum_required (VERSION 2.8.6)
 if (COMMAND cmake_policy)
     cmake_policy (SET CMP0003 NEW)
     if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)
-        cmake_policy (SET CMP0022 NEW) # INTERFACE_LINK_LIBRARIES defines the link interface
+        # INTERFACE_LINK_LIBRARIES defines the link interface
+        cmake_policy (SET CMP0022 NEW)
     endif ()
     if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
-        cmake_policy (SET CMP0026 OLD) # Disallow use of the LOCATION target property - therefore we set to OLD as we still need it
-        cmake_policy (SET CMP0042 NEW) # MACOSX_RPATH is enabled by default
+        # Disallow use of the LOCATION target property - therefore 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)
     endif ()
 endif ()
 
@@ -44,10 +47,13 @@ set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 include (Urho3D-CMake-common)
 
 # Setup SDK install destinations
-if (CMAKE_HOST_WIN32)
-    # CMake already automatically appends "Urho3D" to CMAKE_INSTALL_PREFIX on Windows platform
+if (WIN32)
     set (SCRIPT_EXT .bat)
 else ()
+    set (SCRIPT_EXT .sh)
+endif ()
+if (NOT CMAKE_HOST_WIN32)
+    # CMake already automatically appends "Urho3D" to CMAKE_INSTALL_PREFIX on Windows platform
     set (PATH_SUFFIX /Urho3D)
     if (URHO3D_64BIT)
         if (NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/lib64)
@@ -59,7 +65,6 @@ else ()
         # Use 'ios' arch subdirectory to differentiate, in case both Mac OS X and iOS build are installed at the same destination
         set (LIB_SUFFIX ${LIB_SUFFIX}/ios)
     endif ()
-    set (SCRIPT_EXT .sh)
 endif ()
 set (DEST_INCLUDE_DIR include${PATH_SUFFIX})
 set (DEST_SHARE_DIR share${PATH_SUFFIX})
@@ -70,7 +75,7 @@ if (ANDROID)
     set (DEST_RUNTIME_DIR ${DEST_RUNTIME_DIR}/${ANDROID_NDK_ABI_NAME})
     set (DEST_LIBRARY_DIR ${DEST_LIBRARY_DIR}/${ANDROID_NDK_ABI_NAME})
 endif ()
-set (SYSROOT ${ANDROID_TOOLCHAIN_ROOT} ${RPI_SYSROOT} ${MINGW_SYSROOT})       # SYSROOT is empty for native build
+set (SYSROOT ${ANDROID_TOOLCHAIN_ROOT} ${RPI_SYSROOT} ${MINGW_SYSROOT})         # SYSROOT is empty for native build
 string (REPLACE "${SYSROOT}" "" DEST_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})    # Our CMAKE_INSTALL_PREFIX is rooted, use DEST_INSTALL_PREFIX for the non-rooted version
 set (DEST_PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
 set (DEST_PERMISSIONS FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

+ 1 - 1
Docs/CMakeLists.txt

@@ -59,7 +59,7 @@ if (DOXYGEN_FOUND)
     # 2) ScriptAPI.dox and LuaScriptAPI.dox always get refreshed first before the 'doc' target is being built (similar to VS-only PRE_BUILD custom command)
     if (TARGET ScriptCompiler AND NOT CMAKE_CROSSCOMPILING)
         add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox
-            COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/ScriptCompiler -dumpapi ScriptAPI.dox AngelScriptAPI.h
+            COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/ScriptCompiler -dumpapi ${CMAKE_SOURCE_DIR} ScriptAPI.dox AngelScriptAPI.h
             DEPENDS Urho3D ScriptCompiler
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
             COMMENT "Dumping AngelScript API to ScriptAPI.dox")

+ 3 - 3
Docs/GettingStarted.dox

@@ -94,8 +94,8 @@ Note that Eclipse requires CDT plugin to build C/C++ project. When using generat
 
 If using MinGW to compile, DirectX headers may need to be acquired separately. They can be copied to the MinGW installation eg. from the following package: http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz These will be missing some of the headers related to shader compilation, so a MinGW build will use OpenGL by default. To build in Direct3D9 mode, the MinGW-w64 port is necessary: http://mingw-w64.sourceforge.net/. Using it, Direct3D9 can be enabled with the "-DURHO3D_OPENGL=0" build option.
 
-After the build is complete, the programs can be run from the Bin subdirectory in the build tree. These include the Urho3D player application, which can run application scripts, the tools, and C++ sample applications if they have been enabled. In order to run the Urho3D executables successfully, you must do one of the following first:
-- Copy both the Bin/Data and Bin/CoreData directories to the Bin subdirectory in the build tree.
+After the build is complete, the programs can be run from the Bin subdirectory in the build tree. These include the Urho3D player application, which can run application scripts, the tools, and C++ sample applications if they have been enabled. Unless your build tree location is also the same as the Urho3D project source tree, in order to run the Urho3D executables successfully, you must do one of the following first:
+- Copy both the Bin/Data and Bin/CoreData directories in the source tree to the Bin subdirectory in the build tree.
 - Instead of copying, just create symbolic links in the build tree pointing to the above two directories.
 - Or even better, set and export URHO3D_PREFIX_PATH variable in your host environment. The prefix variable must be set to an absolute path which contains the Data and CoreData subdirectories.      
 
@@ -341,7 +341,7 @@ The physical project root directory is also now the logical project source tree
 
 \section UsingLibraryFromProjectSourceAndBuildTrees From Urho3D project source tree and build tree
 
-This section assumes that you have already successfully build a static or shared library in the Urho3D project (separately from your own project). In order to find Urho3D library in Urho3D project library output directory in its build tree, specify an environment variable called "URHO3D_BUILD_TREE" which points to the Urho3D project build tree itself. Then also specify another environment variable called "URHO3D_HOME" which points to the Urho3D project source tree where the Urho3D headers and CMake modules can be found.
+This section assumes that you have already successfully build a static or shared library in the Urho3D project (separately from your own project). In order to find the Urho3D headers and its CMake modules, specify an environment variable called "URHO3D_HOME" which points to the Urho3D project root directory (aka Urho3D source tree). Then also specify another environment variable called "URHO3D_BUILD_TREE" which points to the location of the Urho3D build tree (if it is different than the Urho3D source tree) in order to find the Urho3D library in its build tree.
 
 In your own project root directory, create a main CMakeLists.txt file and add the following lines: (replace MyProjectName and MyExecutableName with the actual names you want)
 

+ 10 - 38
Rakefile

@@ -51,7 +51,7 @@ task :scaffolding do
   end
 end
 
-# Usage: rake cmake [prefix_path=..] [fix_scm] (only intended to be used by lazy man =), e.g. rake cmake android URHO3D_LIB_TYPE=SHARED; rake cmake clean android
+# Usage: rake cmake [prefix_path=..] [fix_scm] (only intended to be used by lazy man =), e.g. rake cmake clean android; rake cmake android URHO3D_LIB_TYPE=SHARED
 desc 'Invoke cmake shell script with the build tree location predetermined based on the target platform'
 task :cmake do
   prefix_path = ENV['prefix_path'] || '..'
@@ -78,7 +78,7 @@ task :cmake do
   system "./#{script} #{prefix_path}/#{platform}-Build #{build_options}" or abort
 end
 
-# Usage: rake make [prefix_path=..] [num_jobs=8] (only intended to be used by lazy man =), e.g. rake make android
+# Usage: rake make [prefix_path=..] [num_jobs=8] (only intended to be used by lazy man =), e.g. rake make android, rake make android doc
 desc 'Invoke make command in the build tree location predetermined based on the target platform'
 task :make do
   prefix_path = ENV['prefix_path'] || '..'
@@ -92,7 +92,7 @@ task :make do
     when 'android', 'ios', 'mingw', 'rpi'
       platform = option
     else
-      build_options = "#{build_options} -#{option}" unless /(?:prefix_path|num_jobs)=.*/ =~ option
+      build_options = "#{build_options} #{option}" unless /(?:prefix_path|num_jobs)=.*/ =~ option
     end
   }
   system "cd #{prefix_path}/#{platform}-Build && make #{build_options}" or abort
@@ -343,18 +343,15 @@ EOF
 end
 
 def makefile_ci
-  if ENV['WINDOWS']
+  if ENV['WINDOWS'] && ENV['CI']
     # MinGW package on Ubuntu 12.04 LTS does not come with d3dcompiler.h file which is required by our CI build with URHO3D_OPENGL=0.
     # Temporarily workaround the problem by downloading the missing header from Ubuntu 14.04 LTS source package.
-    if ENV['URHO3D_OPENGL'] && ENV['CI'] then
+    if ENV['URHO3D_OPENGL']
       system "sudo wget -P $(echo |$MINGW_PREFIX-gcc -v -E - 2>&1 |grep -B 1 'End of search list' |head -1) http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/mingw-w64/trusty/download/package-import%40ubuntu.com-20130624192537-vzn12bb7qd5w3iy8/d3dcompiler.h-20120402093420-bk10a737hzitlkgj-65/d3dcompiler.h" or abort 'Failed to download d3dcompiler.h header'
     end
     # LuaJIT on MinGW build is not possible on Ubuntu 12.04 LTS as its GCC cross-compiler version is too old. Fallback to use Lua library instead.
     jit = ''
     amalg = ''
-#    # Lua on MinGW build requires tolua++ tool to be built natively first
-#    system "MINGW_PREFIX= ./cmake_generic.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA=1 -DURHO3D_TOOLS=0" or abort 'Failed to configure native build for tolua++ target'
-#    system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
   elsif ENV['ANDROID'] && ENV['ABI'] == 'arm64-v8a'
     # The upstream LuaJIT library does not support this Android ABI at the moment, fallback to use Lua library instead
     jit = ''
@@ -363,26 +360,9 @@ def makefile_ci
     jit = 'JIT'
     amalg = '-DURHO3D_LUAJIT_AMALG=1'
   end
-# Temporarily not using any build options that require native tool building
-#  system "./cmake_generic.sh ../Build -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration}" or abort 'Failed to configure Urho3D library build'
-  system "./cmake_generic.sh ../Build -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration}" or abort 'Failed to configure Urho3D library build'
-  if ENV['ANDROID']
-    if ENV['AVD'] && !ENV['PACKAGE_UPLOAD']   # Skip APK test run when packaging
+  system "./cmake_generic.sh ../Build -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration}" or abort 'Failed to configure Urho3D library build'
+  if ENV['AVD'] && !ENV['PACKAGE_UPLOAD']   # Skip APK test run when packaging
       android_prepare_device ENV['API'], ENV['ABI'], ENV['AVD'] or abort 'Failed to prepare Android (virtual) device for test run'
-    end
-#    # LuaJIT on Android build requires tolua++ and buildvm-android tools to be built natively first
-#    system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
-#    if !jit.empty?
-#      system "cd Build/ThirdParty/Lua#{jit}/generated/buildvm-android-#{ENV['ABI']} && make -j$NUMJOBS" or abort 'Failed to build buildvm-android tool'
-#    end
-#    # Reconfigure Android build one more time now that we have the tools built
-#    system './cmake_generic.sh' or abort 'Failed to reconfigure Urho3D library for Android build'
-#  elsif ENV['RPI']
-#    # LuaJIT on Raspberry Pi build requires tolua++ and buildvm-raspi tools to be built natively first
-#    system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
-#    system "cd Build/ThirdParty/LuaJIT/generated/buildvm-raspi && make -j$NUMJOBS" or abort 'Failed to build buildvm-raspi tool'
-#    # Reconfigure Raspberry Pi build one more time now that we have the tools built
-#    system './cmake_generic.sh' or abort 'Failed to reconfigure Urho3D library for Raspberry Pi build'
   end
   if $testing == 1
     test = '&& make test'
@@ -392,9 +372,7 @@ def makefile_ci
   system "cd ../Build && make -j$NUMJOBS #{test}" or abort 'Failed to build or test Urho3D library'
   # Create a new project on the fly that uses newly built Urho3D library
   scaffolding "../Build/generated/UsingSourceAndBuildTrees"
-# Temporarily not using any build options that require native tool building
-#  system "export URHO3D_HOME=`pwd` URHO3D_BUILD_TREE=../.. && cd ../Build/generated/UsingSourceAndBuildTrees && echo '\nExternal project using Urho3D source and build trees' && ./cmake_generic.sh . #{$build_options} -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration} && make -j$NUMJOBS #{test}" or abort 'Failed to configure/build/test temporary project using Urho3D as external library' 
-  system "export URHO3D_HOME=`pwd` URHO3D_BUILD_TREE=../.. && cd ../Build/generated/UsingSourceAndBuildTrees && echo '\nExternal project using Urho3D source and build trees' && ./cmake_generic.sh . #{$build_options} -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration} && make -j$NUMJOBS #{test}" or abort 'Failed to configure/build/test temporary project using Urho3D as external library' 
+  system "export URHO3D_HOME=`pwd` URHO3D_BUILD_TREE=../.. && cd ../Build/generated/UsingSourceAndBuildTrees && echo '\nExternal project using Urho3D source and build trees' && ./cmake_generic.sh . #{$build_options} -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration} && make -j$NUMJOBS #{test}" or abort 'Failed to configure/build/test temporary project using Urho3D as external library' 
   # Make, deploy, and test run Android APK in an Android (virtual) device
   if ENV['AVD'] && !ENV['PACKAGE_UPLOAD']
     system "echo '\nTest deploying and running Urho3D Samples APK...' && cd ../Build && android update project -p . -t $( android list target |grep android-$API |cut -d ' ' -f2 ) && ant debug" or abort 'Failed to make Urho3D Samples APK'
@@ -492,22 +470,16 @@ def xcode_ci
     jit = ''
     amalg = ''
     deployment_target = "-DIPHONEOS_DEPLOYMENT_TARGET=#{ENV['DEPLOYMENT_TARGET']}"
-#    # Lua on IOS build requires tolua++ tool to be built natively first
-#    system "./cmake_macosx.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA=1 -DURHO3D_TOOLS=0" or abort 'Failed to configure native build for tolua++ target'
-#    xcode_build(0, 'Build/Urho3D.xcodeproj', 'tolua++') or abort 'Failed to build tolua++ tool'
   else
     jit = 'JIT'
     amalg = '-DURHO3D_LUAJIT_AMALG=1'
     deployment_target = "-DCMAKE_OSX_DEPLOYMENT_TARGET=#{ENV['DEPLOYMENT_TARGET']}"
   end
-# Temporarily not using any build options that require native tool building
-#  system "./cmake_macosx.sh ../Build -DIOS=$IOS #{deployment_target} -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure Urho3D library build'
-  system "./cmake_macosx.sh ../Build -DIOS=$IOS #{deployment_target} -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure Urho3D library build'
+  system "./cmake_macosx.sh ../Build -DIOS=$IOS #{deployment_target} -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure Urho3D library build'
   xcode_build(ENV['IOS'], "../Build/Urho3D.xcodeproj") or abort 'Failed to build or test Urho3D library'
   # Create a new project on the fly that uses newly built Urho3D library
   scaffolding "../Build/generated/UsingSourceAndBuildTrees"
-#  system "export URHO3D_HOME=`pwd` URHO3D_BUILD_TREE=../.. && cd ../Build/generated/UsingSourceAndBuildTrees && echo '\nExternal project using Urho3D source and build trees' && ./cmake_macosx.sh . -DIOS=$IOS #{deployment_target} #{$build_options} -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure temporary project using Urho3D as external library'
-  system "export URHO3D_HOME=`pwd` URHO3D_BUILD_TREE=../.. && cd ../Build/generated/UsingSourceAndBuildTrees && echo '\nExternal project using Urho3D source and build trees' && ./cmake_macosx.sh . -DIOS=$IOS #{deployment_target} #{$build_options} -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure temporary project using Urho3D as external library'
+  system "export URHO3D_HOME=`pwd` URHO3D_BUILD_TREE=../.. && cd ../Build/generated/UsingSourceAndBuildTrees && echo '\nExternal project using Urho3D source and build trees' && ./cmake_macosx.sh . -DIOS=$IOS #{deployment_target} #{$build_options} -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure temporary project using Urho3D as external library'
   xcode_build(ENV['IOS'], "../Build/generated/UsingSourceAndBuildTrees/Scaffolding.xcodeproj") or abort 'Failed to configure/build/test temporary project using Urho3D as external library'
 end
 

+ 6 - 3
Source/Engine/Engine/Engine.cpp

@@ -369,9 +369,12 @@ bool Engine::Initialize(const VariantMap& parameters)
 
     // In debug mode, check now that all factory created objects can be created without crashing
     #ifdef _DEBUG
-    const HashMap<StringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories();
-    for (HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories.Begin(); i != factories.End(); ++i)
-        SharedPtr<Object> object = i->second_->CreateObject();
+    if (!resourcePaths.Empty())
+    {
+        const HashMap<StringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories();
+        for (HashMap<StringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories.Begin(); i != factories.End(); ++i)
+            SharedPtr<Object> object = i->second_->CreateObject();
+    }
     #endif
 
     frameTimer_.Reset();

+ 10 - 8
Source/Engine/LuaScript/CMakeLists.txt

@@ -28,15 +28,17 @@ if (NOT URHO3D_SAFE_LUA)
     add_definitions (-DTOLUA_RELEASE)
 endif ()
 
-# The host tool must be built natively and would be used when cross-compiling
+# The host tool must be built natively
 if (CMAKE_CROSSCOMPILING OR IOS)
-    execute_process (COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/tolua++ -v RESULT_VARIABLE TOLUA_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
-    if (NOT TOLUA_EXIT_CODE EQUAL 0)
-        message (WARNING "For cross-compiling build to be successful, the 'tolua++' tool must be built natively first and present in the 'Bin' folder." )
-    endif ()
+    # When cross-compiling, build the host tool as external project
+    include (ExternalProject)
+    ExternalProject_Add(tolua++
+        SOURCE_DIR ${CMAKE_SOURCE_DIR}/Source/ThirdParty/toluapp/src/bin
+        CMAKE_ARGS -DJIT=${JIT} -DDEST_RUNTIME_DIR=${CMAKE_BINARY_DIR}/Bin/tool -DBAKED_CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
+    )
 else ()
+    # Otherwise, build it internally as per normal
     add_subdirectory (../../ThirdParty/toluapp/src/bin ../../ThirdParty/toluapp/src/bin)
-    set (TOLUADEP tolua++)
 endif ()
 
 # Define generated source files
@@ -71,7 +73,7 @@ foreach (API_PKG_FILE ${API_PKG_FILES})
     file (GLOB PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/${API}/*.pkg)
     add_custom_command (OUTPUT ${GEN_CPP_FILE} 
         COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/tolua++ -L ToCppHook.lua -o ${CMAKE_CURRENT_BINARY_DIR}/${GEN_CPP_FILE} ${NAME}
-        DEPENDS ${TOLUADEP} ${API_PKG_FILE} ${PKG_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/ToCppHook.lua
+        DEPENDS tolua++ ${API_PKG_FILE} ${PKG_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/ToCppHook.lua
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pkgs
         COMMENT "Generating tolua++ API binding on the fly for ${API}")
 endforeach ()
@@ -84,7 +86,7 @@ install (FILES ${H_FILES} DESTINATION ${DEST_INCLUDE_DIR})
 set (LIBS ../../ThirdParty/Lua${JIT}/src)
 set (LINK_LIBS_ONLY toluapp)
 set (INCLUDE_DIRS_ONLY . .. ../Audio ../Container ../Core ../Engine ../Graphics ../Input ../IO ../Math ../Navigation ../Resource ../Scene ../UI
-    ../../ThirdParty/SDL/include ../../ThirdParty/toluapp/include ${CMAKE_BINARY_DIR}/Engine)
+    ../../ThirdParty/SDL/include ../../ThirdParty/toluapp/include ${CMAKE_BINARY_DIR}/Source/Engine)
 
 if (URHO3D_NAVIGATION)
     set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Navigation)

+ 1 - 1
Source/Engine/Script/Script.h

@@ -71,7 +71,7 @@ public:
     /// Set whether to execute engine console commands as script code.
     void SetExecuteConsoleCommands(bool enable);
     /// Print the whole script API (all registered classes, methods and properties) to the log. No-ops when URHO3D_LOGGING not defined.
-    void DumpAPI(DumpMode mode= DOXYGEN);
+    void DumpAPI(DumpMode mode= DOXYGEN, const String& sourceTree = String::EMPTY);
     /// Log a message from the script engine.
     void MessageCallback(const asSMessageInfo* msg);
     /// Handle a script exception.

+ 1 - 1
Source/Engine/Script/ScriptAPI.cpp

@@ -301,7 +301,7 @@ static void RegisterScript(asIScriptEngine* engine)
 
     RegisterObject<Script>(engine, "Script");
     engine->RegisterObjectMethod("Script", "bool Execute(const String&in)", asMETHOD(Script, Execute), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Script", "void DumpAPI(DumpMode mode = DOXYGEN)", asMETHOD(Script, DumpAPI), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Script", "void DumpAPI(DumpMode mode = DOXYGEN, const String&in sourceTree = String())", asMETHOD(Script, DumpAPI), asCALL_THISCALL);
     engine->RegisterObjectMethod("Script", "void set_defaultScriptFile(ScriptFile@+)", asMETHOD(Script, SetDefaultScriptFile), asCALL_THISCALL);
     engine->RegisterObjectMethod("Script", "ScriptFile@+ get_defaultScriptFile() const", asMETHOD(Script, GetDefaultScriptFile), asCALL_THISCALL);
     engine->RegisterObjectMethod("Script", "void set_defaultScene(Scene@+)", asMETHOD(Script, SetDefaultScene), asCALL_THISCALL);

+ 4 - 3
Source/Engine/Script/ScriptAPIDump.cpp

@@ -179,7 +179,7 @@ void Script::OutputAPIRow(DumpMode mode, const String& row, bool removeReference
     }
 }
 
-void Script::DumpAPI(DumpMode mode)
+void Script::DumpAPI(DumpMode mode, const String& sourceTree)
 {
     // Does not use LOGRAW macro here to ensure the messages are always dumped regardless of URHO3D_LOGGING compiler directive
     // and of Log subsystem availability
@@ -194,8 +194,9 @@ void Script::DumpAPI(DumpMode mode)
 
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
         Vector<String> headerFiles;
-        String path = fileSystem->GetProgramDir();
-        path.Replace("/Bin", "/Source/Engine");
+        String path = AddTrailingSlash(sourceTree);
+        if (!path.Empty())
+            path.Append("Source/Engine/");
         
         fileSystem->ScanDir(headerFiles, path, "*.h", SCAN_FILES, true);
         if (!headerFiles.Empty())

+ 30 - 48
Source/ThirdParty/LuaJIT/CMakeLists.txt

@@ -149,52 +149,31 @@ endif ()
 # Urho3D only builds static LuaJIT library
 
 # Makefile: Make targets
-# These host tools must be built natively and would be used when cross-compiling
+set (WARNING "# This is a generated file. DO NOT EDIT!")
+configure_file (CMakeLists.txt-minilua.in ${CMAKE_CURRENT_BINARY_DIR}/generated/minilua/CMakeLists.txt @ONLY)
+configure_file (CMakeLists.txt-buildvm.in ${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm/CMakeLists.txt @ONLY)
+# The host tool must be built natively
 if (CMAKE_CROSSCOMPILING OR IOS)
-    # Cross-compiling
-    If (IOS)
-        set (BUILDVM_X buildvm-ios)
-    elseif (ANDROID)
-        set (BUILDVM_X buildvm-android-${ANDROID_NDK_ABI_NAME})
-    elseif (RPI)
-        set (BUILDVM_X buildvm-raspi)
+    # Store the target architecture information for later use when cross-compiling 'buildvm' host tool
+    file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm/TARGET_TESTARCH.txt ${TARGET_TESTARCH})
+
+    if (IOS)
+        set (TARGET_SYS iOS)
+    elseif (ANDROID OR RPI)
+        set (TARGET_SYS Linux)
     elseif (MINGW)
-        set (BUILDVM_X buildvm-mingw)
-    else ()
-        message (FATAL_ERROR "Unsupported cross-compiling target") 
-    endif ()
-    execute_process (COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/${BUILDVM_X} RESULT_VARIABLE BUILDVM_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
-    if (NOT BUILDVM_EXIT_CODE EQUAL 1)
-        file (WRITE ${CMAKE_BINARY_DIR}/Bin/tool/${BUILDVM_X}-arch.txt ${TARGET_TESTARCH})
-        message (FATAL_ERROR
-            "The configuration cannot be done now because the target-specific '${BUILDVM_X}' tool has not been built yet. "
-            "However, the specific target architecture information is now saved. "
-            "Reconfigure the desktop native build to incorporate the saved information by calling the respective batch/shell script for native build (it might be the same script as this one). "
-            "Then run make or the equivalent command to actually build the missing tool natively. "
-            "Finally, after the tool is built, come back to call this batch/shell script again to complete this configuration.")
+        set (TARGET_SYS Windows)
     endif ()
+
+    # When cross-compiling, build the host tool as external project
+    include (ExternalProject)
+    ExternalProject_Add(buildvm
+        SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm
+        CMAKE_ARGS -DTARGET_SYS=${TARGET_SYS} -DDEST_RUNTIME_DIR=${CMAKE_BINARY_DIR}/Bin/tool
+    )
 else ()
-    # Not cross-compiling
-    set (WARNING "# This is a generated file. DO NOT EDIT!")
-    
-    # minilua
-    configure_file (CMakeLists.txt-minilua.in ${CMAKE_CURRENT_BINARY_DIR}/generated/minilua/CMakeLists.txt @ONLY)
-    add_subdirectory (${CMAKE_CURRENT_BINARY_DIR}/generated/minilua generated/minilua)
-    
-    # buildvm
-    configure_file (CMakeLists.txt-buildvm.in ${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm/CMakeLists.txt @ONLY)
+    # Otherwise, build it internally as per normal
     add_subdirectory (${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm generated/buildvm)
-    set (BUILDVM_DEP buildvm)
-    set (BUILDVM_X buildvm)
-    
-    # Also build variants for the supported target architectures
-    file (GLOB VARIANT_ARCHS ${CMAKE_BINARY_DIR}/Bin/tool/buildvm-*-arch.txt)
-    foreach (VARIANT_ARCH ${VARIANT_ARCHS})
-        string (REGEX REPLACE "^.*buildvm(-.*)-arch\\.txt$" \\1 VARIANT ${VARIANT_ARCH})
-        file (READ ${VARIANT_ARCH} TARGET_TESTARCH)
-        configure_file (CMakeLists.txt-buildvm.in ${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm${VARIANT}/CMakeLists.txt @ONLY)
-        add_subdirectory (${CMAKE_CURRENT_BINARY_DIR}/generated/buildvm${VARIANT} generated/buildvm${VARIANT})
-    endforeach ()
 endif ()
 
 # Add definitions specific for target C Compiler 
@@ -213,8 +192,8 @@ macro (generate_source name mode)
     set (GEN_SRC ${CMAKE_CURRENT_BINARY_DIR}/generated/${name})
     set (GEN_SRCS ${GEN_SRCS} ${GEN_SRC})
     add_custom_command (OUTPUT ${GEN_SRC}
-        COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/${BUILDVM_X} -m ${mode} -o ${GEN_SRC} ${ARGN}
-        DEPENDS ${BUILDVM_DEP} ${ARGN}
+        COMMAND ${CMAKE_BINARY_DIR}/Bin/tool/buildvm -m ${mode} -o ${GEN_SRC} ${ARGN}
+        DEPENDS buildvm ${ARGN}
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         COMMENT "Generating buildvm output: ${name}")
 endmacro ()
@@ -284,23 +263,26 @@ if (NOT IOS)
 
     # Define dependency libs
     set (LINK_LIBS_ONLY LuaJIT)
+    if (NOT MSVC)
+        set (LINK_LIBS_ONLY ${LINK_LIBS_ONLY} m)
+    endif ()
 
     # Setup target
     setup_executable (NODEPS)
     adjust_target_name ()   # Adjust to intended target output name
 
     # Define post build steps
-    set (LUAJIT_DEP_DIR ${CMAKE_BINARY_DIR}/Bin/Data/LuaScripts/jit)
+    set (LUAJIT_DEP_DIR ${CMAKE_BINARY_DIR}/Bin/jit)
     add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
         COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src/jit ${LUAJIT_DEP_DIR}
         COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/generated/vmdef.lua ${LUAJIT_DEP_DIR}
         COMMENT "Copying dependency files for luajit standalone executable")
 
     # Install dependency files required by luajit
-    install (DIRECTORY ${LUAJIT_DEP_DIR} DESTINATION ${DEST_RUNTIME_DIR}/Data/LuaScripts ${DEST_PERMISSIONS})
+    install (DIRECTORY ${LUAJIT_DEP_DIR} DESTINATION ${DEST_RUNTIME_DIR} ${DEST_PERMISSIONS})
 endif ()
 
-# Add Data/LuaScripts directory into the LuaJIT module search path
-set (LUA_RDIR Data/LuaScripts/)     # Relative directory
-set (LUA_IDIR ${CMAKE_INSTALL_PREFIX}/${DEST_RUNTIME_DIR}/Data/LuaScripts/)     # Installation directory
+# Add directory containing the dependency files into the LuaJIT module search path
+set (LUA_RDIR ./)     # Relative directory
+set (LUA_IDIR ${CMAKE_INSTALL_PREFIX}/${DEST_RUNTIME_DIR}/)     # Installation directory
 add_definitions (-DLUA_RDIR="${LUA_RDIR}" -DLUA_IDIR="${LUA_IDIR}")

+ 47 - 1
Source/ThirdParty/LuaJIT/CMakeLists.txt-buildvm.in

@@ -22,10 +22,53 @@
 
 @WARNING@
 
+if (CMAKE_PROJECT_NAME STREQUAL ExternalProject-tolua++)
+    # Do not install the buildvm host tool from tolua++ external project because it is built for targetting host system itself
+    # We only want to keep the buildvm host tool which targets a cross-compiling target (the one built from internal LuaJIT CMake-target) 
+    set (DEST_RUNTIME_DIR "")
+elseif (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
+    # Set project name
+    project (ExternalProject-buildvm)
+
+    # Set minimum version
+    cmake_minimum_required (VERSION 2.8.6)
+
+    if (COMMAND cmake_policy)
+        cmake_policy (SET CMP0003 NEW)
+        if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)
+            # INTERFACE_LINK_LIBRARIES defines the link interface
+            cmake_policy (SET CMP0022 NEW)
+        endif ()
+        if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
+            # Disallow use of the LOCATION target property - therefore 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)
+        endif ()
+    endif ()
+
+    # Set CMake modules search path
+    set (CMAKE_MODULE_PATH @CMAKE_SOURCE_DIR@/CMake/Modules)
+
+    # Include Urho3D Cmake common module
+    include (Urho3D-CMake-common)
+endif ()
+
+# Add dependency target
+add_subdirectory (../minilua ../minilua)
+
 # Define target name
-set (TARGET_NAME buildvm@VARIANT@)
+set (TARGET_NAME buildvm)
+
+# Read the target architecture information
+if (NOT TARGET_TESTARCH)
+    file (READ TARGET_TESTARCH.txt TARGET_TESTARCH)
+endif ()
 
 # Add definitions specific for host C compiler
+if (NOT BAKED_CMAKE_SOURCE_DIR)
+    set (BAKED_CMAKE_SOURCE_DIR @CMAKE_SOURCE_DIR@)
+endif ()
 include (@CMAKE_CURRENT_SOURCE_DIR@/DetectTargetArchitecture.cmake)
 add_definitions (${HOST_XCFLAGS} ${TARGET_ARCH})
 
@@ -46,5 +89,8 @@ set (SOURCE_FILES ${C_FILES} ${GEN_ARCH_H})
 # Define dependency libs
 set (INCLUDE_DIRS_ONLY ${CMAKE_CURRENT_BINARY_DIR} @CMAKE_CURRENT_SOURCE_DIR@/src)
 
+# All tools must be natively built and output to Bin/tool subdir to differentiate them from platform-specific binaries in the Bin directory
+set_output_directories (${CMAKE_BINARY_DIR}/Bin/tool RUNTIME PDB)
+
 # Setup target
 setup_executable (NODEPS)

+ 3 - 0
Source/ThirdParty/LuaJIT/CMakeLists.txt-minilua.in

@@ -33,5 +33,8 @@ if (NOT MSVC)
     set (LINK_LIBS_ONLY m)
 endif ()
 
+# All tools must be natively built and output to Bin/tool subdir to differentiate them from platform-specific binaries in the Bin directory
+set_output_directories (${CMAKE_BINARY_DIR}/Bin/tool RUNTIME PDB)
+
 # Setup target
 setup_executable (NODEPS)

+ 25 - 39
Source/ThirdParty/LuaJIT/DetectTargetArchitecture.cmake

@@ -22,30 +22,26 @@
 
 # Macro for finding a substring
 macro (find_string find_regex input_string output_string)
-    if (NOT DEFINED ${output_string}${ARGN})
-        message (STATUS "Finding value for LuaJIT:${output_string}${ARGN}")
+    if (NOT DEFINED ${output_string})
+        message (STATUS "Finding value for LuaJIT:${output_string}")
         string (REGEX MATCH ${find_regex} matched ${input_string})
         if (matched)
             string (REGEX MATCH "\\(.*\\)" captured ${find_regex})
             if (captured) 
                 string (REGEX REPLACE ${find_regex} \\1 matched ${matched})
             endif ()
-            set (${output_string}${ARGN} ${matched} CACHE INTERNAL "LUAJIT INTERNAL - ${output_string}${ARGN}")
-            message (STATUS "Finding value for LuaJIT:${output_string}${ARGN} - found (${matched})")
+            set (${output_string} ${matched} CACHE INTERNAL "LUAJIT INTERNAL - ${output_string}")
+            message (STATUS "Finding value for LuaJIT:${output_string} - found (${matched})")
         else ()
-            set (${output_string}${ARGN} 0 CACHE INTERNAL "LUAJIT INTERNAL - ${output_string}${ARGN}")
+            set (${output_string} 0 CACHE INTERNAL "LUAJIT INTERNAL - ${output_string}")
         endif ()
     endif ()
-    if (${ARGC} EQUAL 4)
-        list (GET ${output_string}${ARGN} 0 ${output_string})
-    endif ()
 endmacro ()
 
 # Makefile: Architecture detection
-find_string ("LJ_TARGET_(X64|X86|ARM|PPC|PPCSPE|MIPS) 1" "${TARGET_TESTARCH}" TARGET_LJARCH ${VARIANT})
+find_string ("LJ_TARGET_(X64|X86|ARM|PPC|PPCSPE|MIPS) 1" "${TARGET_TESTARCH}" TARGET_LJARCH)
 if (TARGET_LJARCH)
     string (TOLOWER ${TARGET_LJARCH} TARGET_LJARCH)
-    set (TARGET_LJARCH${VARIANT} ${TARGET_LJARCH} CACHE INTERNAL "LUAJIT INTERNAL - TARGET_LJARCH${VARIANT}")
     if (TARGET_LJARCH STREQUAL x64 AND NOT URHO3D_64BIT)
         set (TARGET_LJARCH x86)
     endif ()
@@ -53,20 +49,20 @@ else ()
     message (FATAL_ERROR "Unsupported target architecture") 
 endif () 
 if (TARGET_LJARCH STREQUAL mips)
-    find_string ("MIPSEL (1)" "${TARGET_TESTARCH}" MIPSEL ${VARIANT})
+    find_string ("MIPSEL (1)" "${TARGET_TESTARCH}" MIPSEL)
     if (MIPSEL)
         set (TARGET_ARCH ${TARGET_ARCH} -D__MIPSEL__=1)
     endif ()
 endif ()
 
-find_string ("LJ_TARGET_PS3 (1)" "${TARGET_TESTARCH}" PS3 ${VARIANT})
+find_string ("LJ_TARGET_PS3 (1)" "${TARGET_TESTARCH}" PS3)
 if (PS3)
     set (TARGET_SYS PS3)
     set (TARGET_ARCH ${TARGET_ARCH} -D__CELLOS_LV2__)
     add_definitions (-DLUAJIT_USE_SYSMALLOC)
 endif ()
 
-find_string ("LJ_NO_UNWIND (1)" "${TARGET_TESTARCH}" NO_UNWIND ${VARIANT})
+find_string ("LJ_NO_UNWIND (1)" "${TARGET_TESTARCH}" NO_UNWIND)
 if (NO_UNWIND)
     set (TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_NO_UNWIND)
 endif ()
@@ -79,16 +75,7 @@ if (WIN32)
 else ()
     execute_process (COMMAND uname -s OUTPUT_VARIABLE HOST_SYS ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
 endif ()
-if (VARIANT)
-    if (VARIANT MATCHES ios)
-        set (TARGET_SYS iOS)
-    elseif (VARIANT MATCHES android|raspi)
-        set (TARGET_SYS Linux)
-    elseif (VARIANT MATCHES mingw)
-        set (TARGET_SYS Windows)
-    else ()
-        message (FATAL_ERROR "Unsupported buildvm variant: ${VARIANT}")
-    endif ()
+if (TARGET_SYS)
     # Makefile: ifneq ($(HOST_SYS),$(TARGET_SYS))
     if (TARGET_SYS STREQUAL Windows)
         set (HOST_XCFLAGS ${HOST_XCFLAGS} -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS)
@@ -104,11 +91,11 @@ else ()
 endif ()
 
 # Makefile: Files and pathnames
-set (DASM_DIR ${PROJECT_SOURCE_DIR}/ThirdParty/LuaJIT/dynasm)
+set (DASM_DIR ${BAKED_CMAKE_SOURCE_DIR}/Source/ThirdParty/LuaJIT/dynasm)
 set (DASM_ARCH ${TARGET_LJARCH})
 
 # Below regex is a workaround for "LJ_ARCH_BITS (.*?)\\n" as CMake does not understand non-greedy quantifier
-find_string ("LJ_ARCH_BITS ([^\\n]*)" "${TARGET_TESTARCH}" ARCH_BITS ${VARIANT})
+find_string ("LJ_ARCH_BITS ([^\\n]*)" "${TARGET_TESTARCH}" ARCH_BITS)
 if (ARCH_BITS EQUAL 64)
     if (URHO3D_64BIT)
         set (DASM_AFLAGS ${DASM_AFLAGS} -D P64)
@@ -116,45 +103,44 @@ if (ARCH_BITS EQUAL 64)
         set (ARCH_BITS 32)
     endif ()
 endif ()
-if (VARIANT)
+if (TARGET_SYS)
     if (MSVC)
-        message (FATAL_ERROR "MSVC is not able to build 'buildvm${VARIANT}' target at this moment, please use GCC or LLVM/Clang instead. "
-            "To recover from this error, remove this file (generated by Android build script when LuaJIT is enabled) in ${CMAKE_BINARY_DIR}/Bin/tool/buildvm${VARIANT}-arch.txt.")
+        message (FATAL_ERROR "MSVC is not able to cross-compile 'buildvm' target at this moment, please use GCC or LLVM/Clang instead.")
     else ()
         string (REGEX REPLACE "-m(32|64) *" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
         set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m${ARCH_BITS}")
     endif ()
 endif ()
 
-find_string ("LJ_HASJIT (1)" "${TARGET_TESTARCH}" HASJIT ${VARIANT})
+find_string ("LJ_HASJIT (1)" "${TARGET_TESTARCH}" HASJIT)
 if (HASJIT)
     set (DASM_AFLAGS ${DASM_AFLAGS} -D JIT)
 endif ()
 
-find_string ("LJ_HASFFI (1)" "${TARGET_TESTARCH}" HASFFI ${VARIANT})
+find_string ("LJ_HASFFI (1)" "${TARGET_TESTARCH}" HASFFI)
 if (HASFFI)
     set (DASM_AFLAGS ${DASM_AFLAGS} -D FFI)
 endif ()
 
-find_string ("LJ_DUALNUM (1)" "${TARGET_TESTARCH}" DUALNUM ${VARIANT})
+find_string ("LJ_DUALNUM (1)" "${TARGET_TESTARCH}" DUALNUM)
 if (DUALNUM)
     set (DASM_AFLAGS ${DASM_AFLAGS} -D DUALNUM)
 endif ()
 
-find_string ("LJ_ARCH_HASFPU (1)" "${TARGET_TESTARCH}" ARCH_HASFPU ${VARIANT})
+find_string ("LJ_ARCH_HASFPU (1)" "${TARGET_TESTARCH}" ARCH_HASFPU)
 if (ARCH_HASFPU)
     set (DASM_AFLAGS ${DASM_AFLAGS} -D FPU)
 endif ()
 set (TARGET_ARCH ${TARGET_ARCH} -DLJ_ARCH_HASFPU=${ARCH_HASFPU})
 
-find_string ("LJ_ABI_SOFTFP (1)" "${TARGET_TESTARCH}" ABI_SOFTFP ${VARIANT})
+find_string ("LJ_ABI_SOFTFP (1)" "${TARGET_TESTARCH}" ABI_SOFTFP)
 if (NOT ABI_SOFTFP)
     set (DASM_AFLAGS ${DASM_AFLAGS} -D HFABI)
 endif ()
 set (TARGET_ARCH ${TARGET_ARCH} -DLJ_ABI_SOFTFP=${ABI_SOFTFP})
 
 # Below regex is a workaround for "LJ_ARCH_VERSION (.*?)\\n" as CMake does not understand non-greedy quantifier
-find_string ("LJ_ARCH_VERSION ([^\\n]*)" "${TARGET_TESTARCH}" ARCH_VERSION ${VARIANT})
+find_string ("LJ_ARCH_VERSION ([^\\n]*)" "${TARGET_TESTARCH}" ARCH_VERSION)
 if (ARCH_VERSION)
     set (DASM_AFLAGS ${DASM_AFLAGS} -D VER=${ARCH_VERSION})
 else ()
@@ -166,7 +152,7 @@ if (TARGET_SYS STREQUAL Windows)
 endif ()
 
 if (TARGET_LJARCH STREQUAL x86)
-    find_string ("__SSE2__ (1)" "${TARGET_TESTARCH}" SSE2 ${VARIANT})
+    find_string ("__SSE2__ (1)" "${TARGET_TESTARCH}" SSE2)
     if (SSE2)
         set (DASM_AFLAGS ${DASM_AFLAGS} -D SSE)
     endif ()
@@ -177,15 +163,15 @@ elseif (TARGET_LJARCH STREQUAL arm)
         set (DASM_AFLAGS ${DASM_AFLAGS} -D IOS)
     endif ()
 elseif (TARGET_LJARCH STREQUAL ppc)
-    find_string ("LJ_ARCH_SQRT (1)" "${TARGET_TESTARCH}" ARCH_SQRT ${VARIANT})
+    find_string ("LJ_ARCH_SQRT (1)" "${TARGET_TESTARCH}" ARCH_SQRT)
     if (ARCH_SQRT)
         set (DASM_AFLAGS ${DASM_AFLAGS} -D SQRT)
     endif ()
-    find_string ("LJ_ARCH_ROUND (1)" "${TARGET_TESTARCH}" ARCH_ROUND ${VARIANT})
+    find_string ("LJ_ARCH_ROUND (1)" "${TARGET_TESTARCH}" ARCH_ROUND)
     if (ARCH_ROUND)
         set (DASM_AFLAGS ${DASM_AFLAGS} -D ROUND)
     endif ()
-    find_string ("LJ_ARCH_PPC64 (1)" "${TARGET_TESTARCH}" ARCH_PPC64 ${VARIANT})
+    find_string ("LJ_ARCH_PPC64 (1)" "${TARGET_TESTARCH}" ARCH_PPC64)
     if (ARCH_PPC64)
         set (DASM_AFLAGS ${DASM_AFLAGS} -D GPR64)
     endif ()
@@ -195,4 +181,4 @@ elseif (TARGET_LJARCH STREQUAL ppc)
 endif ()
 
 set (DASM_FLAGS ${DASM_XFLAGS} ${DASM_AFLAGS})
-set (DASM_DASC ${PROJECT_SOURCE_DIR}/ThirdParty/LuaJIT/src/vm_${DASM_ARCH}.dasc)
+set (DASM_DASC ${BAKED_CMAKE_SOURCE_DIR}/Source/ThirdParty/LuaJIT/src/vm_${DASM_ARCH}.dasc)

+ 57 - 0
Source/ThirdParty/toluapp/src/bin/CMakeLists.txt

@@ -1,3 +1,57 @@
+#
+# Copyright (c) 2008-2014 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.
+#
+
+if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
+    # Set project name
+    project (ExternalProject-tolua++)
+
+    # Set minimum version
+    cmake_minimum_required (VERSION 2.8.6)
+
+    if (COMMAND cmake_policy)
+        cmake_policy (SET CMP0003 NEW)
+        if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)
+            # INTERFACE_LINK_LIBRARIES defines the link interface
+            cmake_policy (SET CMP0022 NEW)
+        endif ()
+        if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
+            # Disallow use of the LOCATION target property - therefore 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)
+        endif ()
+    endif ()
+
+    # Set CMake modules search path
+    set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../../../CMake/Modules)
+
+    # Include Urho3D Cmake common module
+    include (Urho3D-CMake-common)
+
+    # Add dependency targets
+    add_subdirectory (../../../../ThirdParty/Lua${JIT} ../../../../ThirdParty/Lua${JIT})
+    add_subdirectory (../../../../ThirdParty/toluapp/src/lib ../../../../ThirdParty/toluapp/src/lib)
+endif ()
+
 # Define target name
 set (TARGET_NAME tolua++)
 
@@ -14,6 +68,9 @@ if (NOT MSVC)
 endif ()
 set (INCLUDE_DIRS_ONLY ../../include)
 
+# All tools must be natively built and output to Bin/tool subdir to differentiate them from platform-specific binaries in the Bin directory
+set_output_directories (${CMAKE_BINARY_DIR}/Bin/tool RUNTIME PDB)
+
 # Setup target
 if (URHO3D_LUAJIT AND URHO3D_64BIT AND APPLE AND NOT IOS)
     setup_macosx_linker_flags (CMAKE_EXE_LINKER_FLAGS)

+ 15 - 7
Source/Tools/ScriptCompiler/ScriptCompiler.cpp

@@ -53,11 +53,12 @@ int main(int argc, char** argv)
     #endif
 
     bool dumpApiMode = false;
+    String sourceTree;
     String outputFile;
 
     if (arguments.Size() < 1)
         ErrorExit("Usage: ScriptCompiler <input file> [resource path for includes]\n"
-                  "       ScriptCompiler -dumpapi <Doxygen output file> [C header output file]");
+                  "       ScriptCompiler -dumpapi <source tree> <Doxygen output file> [C header output file]");
     else
     {
         if (arguments[0] != "-dumpapi")
@@ -65,8 +66,13 @@ int main(int argc, char** argv)
         else
         {
             dumpApiMode = true;
-            if (arguments.Size() > 1)
-                outputFile = arguments[1];
+            if (arguments.Size() > 2)
+            {
+                sourceTree = arguments[1];
+                outputFile = arguments[2];
+            }
+            else
+                ErrorExit("Usage: ScriptCompiler -dumpapi <source tree> <Doxygen output file> [C header output file]");
         }
     }
 
@@ -82,6 +88,8 @@ int main(int argc, char** argv)
         engineParameters["Headless"] = true;
         engineParameters["WorkerThreads"] = false;
         engineParameters["LogName"] = String::EMPTY;
+        engineParameters["ResourcePaths"] = String::EMPTY;
+        engineParameters["AutoloadPaths"] = String::EMPTY;
         engine->Initialize(engineParameters);
     #ifdef URHO3D_LUA
         context->RegisterSubsystem(new LuaScript(context));
@@ -130,14 +138,14 @@ int main(int argc, char** argv)
             log->Open(outputFile);
         }
         // If without output file, dump to stdout instead
-        context->GetSubsystem<Script>()->DumpAPI(DOXYGEN);
+        context->GetSubsystem<Script>()->DumpAPI(DOXYGEN, sourceTree);
 
         // Only dump API as C Header when an output file name is explicitly given
-        if (arguments.Size() > 2)
+        if (arguments.Size() > 3)
         {
-            outputFile = arguments[2];
+            outputFile = arguments[3];
             log->Open(outputFile);
-            context->GetSubsystem<Script>()->DumpAPI(C_HEADER);
+            context->GetSubsystem<Script>()->DumpAPI(C_HEADER, sourceTree);
         }
     }