Browse Source

Create out-of-source build directory for Android on Windows platform when mklink option is enabled.

Wei Tjong Yao 12 years ago
parent
commit
217c851811
5 changed files with 36 additions and 11 deletions
  1. 1 0
      Docs/GettingStarted.dox
  2. 2 0
      Readme.txt
  3. 1 1
      Source/cmake/Modules/Urho3D-CMake-magic.cmake
  4. 24 7
      cmake_android.bat
  5. 8 3
      cmake_vs2012.bat

+ 1 - 0
Docs/GettingStarted.dox

@@ -130,6 +130,7 @@ A number of build options can be defined explicitly when invoking the above cmak
 |-DENABLE_SSE=0                               |to disable SSE instruction set|
 |-DENABLE_SSE=0                               |to disable SSE instruction set|
 |-DENABLE_MINIDUMPS=0                         |to disable minidumps on crash (VS only)|
 |-DENABLE_MINIDUMPS=0                         |to disable minidumps on crash (VS only)|
 |-DUSE_OPENGL=1                               |to use OpenGL instead of Direct3D (only useful for VS on Windows platform because this option is enabled by default for other platforms)|
 |-DUSE_OPENGL=1                               |to use OpenGL instead of Direct3D (only useful for VS on Windows platform because this option is enabled by default for other platforms)|
+|-DUSE_MKLINK=1                               |to use mklink command to create symbolic links (Windows Vista and above only)|
 |-DSCP_TO_TARGET=user\@target:remote-location |to automatically scp executables to target system (only applicable for cross compiling Raspberry Pi on a build/host machine), SSH digital key must be setup first for this to work|
 |-DSCP_TO_TARGET=user\@target:remote-location |to automatically scp executables to target system (only applicable for cross compiling Raspberry Pi on a build/host machine), SSH digital key must be setup first for this to work|
 |-DCMAKE_BUILD_TYPE=Debug or Release          |to tell CMake which build configuration to be generated, default is RelWithDebInfo (only applicable for cmake_gcc.sh and cmake_eclipse.sh)|
 |-DCMAKE_BUILD_TYPE=Debug or Release          |to tell CMake which build configuration to be generated, default is RelWithDebInfo (only applicable for cmake_gcc.sh and cmake_eclipse.sh)|
 |-DURHO3D_BUILD_TYPE=STATIC or SHARED         |to tell CMake which Urho3D target to be built, default is EXE (Urho3D script host application)|
 |-DURHO3D_BUILD_TYPE=STATIC or SHARED         |to tell CMake which Urho3D target to be built, default is EXE (Urho3D script host application)|

+ 2 - 0
Readme.txt

@@ -363,6 +363,8 @@ cmake_xxxx batch files or shell scripts.
 |-DUSE_OPENGL=1        |to use OpenGL instead of Direct3D (only useful for VS  |
 |-DUSE_OPENGL=1        |to use OpenGL instead of Direct3D (only useful for VS  |
 |                      | on Windows platform because this option is enabled by |
 |                      | on Windows platform because this option is enabled by |
 |                      | default for other platforms)                          | 
 |                      | default for other platforms)                          | 
+|-DUSE_MKLINK=1        |to use mklink command to create symbolic links (Windows|
+|                      |  Vista and above only)                                |
 |-DSCP_TO_TARGET=      |to automatically scp executables to target system (only|
 |-DSCP_TO_TARGET=      |to automatically scp executables to target system (only|
 |  usr\@tgt:remote-loc | applicable for cross compiling Raspberry Pi on a      |
 |  usr\@tgt:remote-loc | applicable for cross compiling Raspberry Pi on a      |
 |                      | build/host machine), SSH digital key must be setup    |
 |                      | build/host machine), SSH digital key must be setup    |

+ 1 - 1
Source/cmake/Modules/Urho3D-CMake-magic.cmake

@@ -28,7 +28,7 @@ if (CMAKE_GENERATOR STREQUAL Xcode)
     set (XCODE TRUE)
     set (XCODE TRUE)
 endif ()
 endif ()
 if (NOT MSVC AND NOT XCODE AND NOT CMAKE_BUILD_TYPE)
 if (NOT MSVC AND NOT XCODE AND NOT CMAKE_BUILD_TYPE)
-    set (CMAKE_BUILD_TYPE "RelWithDebInfo")
+    set (CMAKE_BUILD_TYPE "Release")
 endif ()
 endif ()
 
 
 # On Visual Studio, whether to enable 64-bit build depends on the generator used
 # On Visual Studio, whether to enable 64-bit build depends on the generator used

+ 24 - 7
cmake_android.bat

@@ -1,9 +1,26 @@
 @echo off
 @echo off
-cd Source/Android
-del /F CMakeCache.txt
-rd /S /Q CMakeFiles
-cd ../..
-del /F CMakeCache.txt
-rd /S /Q CMakeFiles
+:: Define USE_MKLINK to 1 to enable out-of-source build
+del /F Source\Android\CMakeCache.txt CMakeCache.txt
+rd /S /Q Source\Android\CMakeFiles CMakeFiles
+set "build=Source\Android"
+set "source=Source"
+set "use_mklink="
+:loop
+if not "%1" == "" (
+    if "%1" == "-DUSE_MKLINK" set "use_mklink=%~2"
+    shift
+	shift
+    goto loop
+)
+if "%use_mklink%" == "1" (
+    cmake -E make_directory android-Build
+    del /F android-Build\CMakeCache.txt
+    rd /S /Q android-Build\CMakeFiles CMakeFiles
+	set "build=android-Build"
+	set "source=..\Source"
+    for %%d in (CoreData Data) do mklink /D "Source\Android\assets\%%d" "..\..\..\Bin\%%d"
+    for %%f in (src res assets) do mklink /D "android-Build/%%f" "..\Source\Android\%%f"
+    for %%f in (AndroidManifest.xml build.xml project.properties) do mklink "android-Build/%%f" "..\Source\Android\%%f"
+)
 echo on
 echo on
-cmake -E chdir Source/Android cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=. -DCMAKE_BUILD_TYPE=Release .. %*
+cmake -E chdir %build% cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=%source%\cmake\Toolchains\android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=. %source% %*

+ 8 - 3
cmake_vs2012.bat

@@ -3,9 +3,14 @@ cmake -E make_directory Build
 del /F Build\CMakeCache.txt Source\CMakeCache.txt CMakeCache.txt
 del /F Build\CMakeCache.txt Source\CMakeCache.txt CMakeCache.txt
 rd /S /Q Build\CMakeFiles Source\CMakeFiles CMakeFiles
 rd /S /Q Build\CMakeFiles Source\CMakeFiles CMakeFiles
 set "arch="
 set "arch="
-for %%n in (%*) do if "%%n" == "-DENABLE_64BIT" set "arch= Win64"
 set "version=11"
 set "version=11"
-set "parm=%1"
-if "%parm:~0,9%" == "-DVERSION" set "version=%~2"
+:loop
+if not "%1" == "" (
+    if "%1" == "-DENABLE_64BIT" if "%~2" == "1" set "arch= Win64"
+    if "%1" == "-DVERSION" set "version=%~2"
+    shift
+    shift
+    goto loop
+)
 echo on
 echo on
 cmake -E chdir Build cmake -G "Visual Studio %version%%arch%" ../Source %*
 cmake -E chdir Build cmake -G "Visual Studio %version%%arch%" ../Source %*