-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1195 from moai/feature/cmake-hosts
Feature/cmake hosts
- Loading branch information
Showing
157 changed files
with
6,177 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "25.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 17 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
externalNativeBuild { | ||
cmake { | ||
arguments "-DBUILD_ANDROID=TRUE", "-DMOAI_ANDROID=TRUE", "-DANDROID_STL=c++_static", "-DMOAI_SDK_HOME=" + new File(moaiSdkRoot).canonicalPath | ||
} | ||
} | ||
ndk { | ||
// Specifies the ABI configurations of your native | ||
// libraries Gradle should build and package with your APK. | ||
abiFilters 'x86'//, 'x86_64', 'armeabi-v7a' | ||
|
||
} | ||
|
||
|
||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
externalNativeBuild { | ||
cmake { | ||
path new File(moaiSdkRoot).canonicalPath + '/cmake/cmake/hosts/host-android/CMakeLists.txt' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\dev\android-sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
|
||
package="com.example.libmoai"> | ||
|
||
<application android:allowBackup="true" android:label="@string/app_name" | ||
android:supportsRtl="true"> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">libmoai</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
include ':app' | ||
|
||
include ':core' | ||
project(':core').projectDir = new File('../src/moai-android/java') | ||
project(':core').projectDir = new File(moaiSdkRoot+'/src/moai-android/java') | ||
if (!hasProperty('usePrebuiltMoaiFrom')) { | ||
include(":libmoai") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@echo off | ||
setlocal enableextensions | ||
call "%~dp0%\env-win.bat" | ||
|
||
echo "Setting CMAKE bin path..." | ||
set "PATH=%PATH%;%CMAKE_PATH%" | ||
|
||
echo "Setting MingW Gcc path" | ||
set "PATH=%MINGW_PATH%;%PATH%" | ||
|
||
rem ----- Requirements Check ----- | ||
set "PITO_HOME=%~dp0..\" | ||
|
||
if "%ANDROID_NDK%"=="" echo "You need to set ANDROID_NDK to your ndk path try using env-win.bat and env-local.bat in scripts" && exit /b 1 | ||
if "%MOAI_SDK_HOME%"=="" echo "You need to set MOAI_SDK_HOME to your moai sdk folder" && exit /b 1 | ||
|
||
where mingw32-make || echo "mingw32-make is required. Install TCC Mingw from http://tdm-gcc.tdragon.net/ and add to the path" && goto ERROR | ||
|
||
where cmake || echo "Cmake 3.2+ is required, download from cmake.org" && goto ERROR | ||
|
||
rem ----- Build libmoai ----- | ||
pushd "%~dp0%" | ||
|
||
set "CMAKEROOT=%cd%" | ||
|
||
mkdir build | ||
cd build | ||
mkdir build-android | ||
cd build-android | ||
|
||
set "BUILDROOT=%cd%" | ||
rem for %%a in (x86 armeabi-v7a arm64-v8a) | ||
for %%a in (x86) do ( | ||
cmake ^ | ||
-H%CMAKEROOT%\cmake\hosts\host-android ^ | ||
-B%BUILDROOT% ^ | ||
-G"MinGW Makefiles" ^ | ||
-DANDROID_ABI=%%a ^ | ||
-DANDROID_NDK=%ANDROID_NDK% ^ | ||
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="%CMAKEROOT%\lib\android\%%a" ^ | ||
-DCMAKE_BUILD_TYPE=Release ^ | ||
-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake ^ | ||
-DANDROID_PLATFORM=android-17 ^ | ||
-DBUILD_ANDROID=TRUE ^ | ||
-DMOAI_ANDROID=TRUE ^ | ||
-DANDROID_STL=c++_static ^ | ||
-DMOAI_SDK_HOME=%MOAI_SDK_HOME% ^ | ||
-DHOST_ROOT=%MOAI_SDK_HOME%/src || goto ERROR | ||
|
||
cmake --build . --target moai -- -j3 || goto ERROR | ||
) | ||
|
||
goto END | ||
:ERROR | ||
exit /b 1 | ||
|
||
:END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
|
||
|
||
uname -a | grep -i Darwin && ENVSCRIPT=./env-osx.sh || ENVSCRIPT=./env-linux.sh | ||
source $ENVSCRIPT | ||
|
||
# requirements | ||
: "${MOAI_SDK_HOME:?Please set MOAI_SDK_HOME variable to point to your Moai SDK }" | ||
: "${ANDROID_NDK:?You need to set ANDROID_NDK to point to your ndk path. Try using env-local.sh }" | ||
|
||
javac -version || { echo "Can't find a JDK" ; exit 1; } | ||
cmake --version || { echo "Can't find cmake"; exit 1; } | ||
|
||
#----- Build libmoai using sdk methods ----- | ||
pushd `dirname $0` | ||
|
||
CMAKEROOT=$(pwd) | ||
|
||
mkdir -p build/build-android | ||
cd build/build-android | ||
|
||
BUILDROOT=$(pwd) | ||
|
||
# for a in x86 armeabi-v7a arm64-v8a; do | ||
for a in x86; do | ||
echo "building for :$a:" | ||
cmake \ | ||
-H$CMAKEROOT/cmake/hosts/host-android \ | ||
-B$BUILDROOT \ | ||
-G"Unix Makefiles" \ | ||
-DANDROID_ABI=$a \ | ||
-DANDROID_NDK=$ANDROID_NDK \ | ||
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$CMAKEROOT/lib/android/$a" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ | ||
-DANDROID_PLATFORM=android-17 \ | ||
-DBUILD_ANDROID=TRUE \ | ||
-DMOAI_ANDROID=TRUE \ | ||
-DANDROID_STL=c++_static \ | ||
-DMOAI_SDK_HOME=$MOAI_SDK_HOME \ | ||
-DHOST_ROOT=$MOAI_SDK_HOME/src || { echo "error running cmake"; exit 1; } | ||
|
||
make moai -j3 || { echo "error building libmoai"; exit 1; } | ||
done | ||
|
||
popd |
Oops, something went wrong.