Last active
August 29, 2015 14:01
-
-
Save kyokomi/66d4978815089d0fb520 to your computer and use it in GitHub Desktop.
Cocos2d-x3.1でAndroidをGradleビルドするためにproj.android下とproj.android/jni下に配置するもの
This file contains hidden or 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
# proj.android/jni/Android.mk | |
LOCAL_PATH := $(call my-dir) | |
COCOS2DX_ROOT := $(LOCAL_PATH)/../../cocos2d | |
include $(CLEAR_VARS) | |
LOCAL_MODULE := cocos2dcpp_shared | |
LOCAL_MODULE_FILENAME := libcocos2dcpp | |
# cppファイルの自動検索設定 | |
ifeq ($(HOST_OS),windows) | |
CPP_FILES := $(shell dir $(LOCAL_PATH)/../../Classes/*.cpp /b/a-d/s) | |
else | |
CPP_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.cpp) | |
endif | |
# hellocppは各自直しますね | |
LOCAL_SRC_FILES := hellocpp/main.cpp | |
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%) | |
# LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes | |
# headerフォルダの自動検索設定 | |
ifeq ($(HOST_OS),windows) | |
LOCAL_C_INCLUDES := $(shell dir $(LOCAL_PATH)/../../Classes /b/ad/s) | |
else | |
LOCAL_C_INCLUDES := $(shell find $(LOCAL_PATH)/../../Classes -type d) | |
endif | |
ifeq ($(APP_OPTIM),debug) | |
LOCAL_CFLAGS := -w -g | |
endif | |
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static | |
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static | |
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static | |
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static | |
LOCAL_WHOLE_STATIC_LIBRARIES += spine_static | |
include $(BUILD_SHARED_LIBRARY) | |
$(call import-add-path,$(COCOS2DX_ROOT)) | |
$(call import-add-path,$(COCOS2DX_ROOT)/cocos) | |
$(call import-add-path,$(COCOS2DX_ROOT)/external) | |
$(call import-add-path,$(COCOS2DX_ROOT)/cocos/platform/android) | |
$(call import-module,.) | |
$(call import-module,audio/android) | |
$(call import-module,platform/android) | |
# この辺はお好みで | |
# $(call import-module,Box2D) | |
# $(call import-module,editor-support/cocostudio) | |
# $(call import-module,editor-support/spine) | |
# $(call import-module,editor-support/cocosbuilder) | |
# $(call import-module,network) | |
# $(call import-module,extensions) |
This file contains hidden or 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
# proj.android/jni/Application.mk | |
APP_STL := gnustl_static | |
APP_OPTIM := debug | |
#APP_OPTIM := release | |
ifeq ($(APP_OPTIM),debug) | |
APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -fsigned-char -Wno-literal-suffix | |
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl -ldebug -llog | |
else | |
APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=0 -std=c++11 -fsigned-char -Wno-literal-suffix | |
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl -llog | |
endif | |
APP_ABI :=armeabi | |
APP_PLATFORM := android-9 | |
NDK_TOOLCHAIN_VERSION=4.8 |
This file contains hidden or 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
// proj.android/build.gradle | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.10.+' | |
} | |
} | |
project(':cocos2d:cocos:platform:android:java') { | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.10.+' | |
} | |
} | |
} | |
apply plugin: 'android' | |
dependencies { | |
compile 'com.android.support:support-v4:+' | |
compile project(':cocos2d:cocos:platform:android:java') | |
} | |
allprojects { | |
tasks.withType(Compile) { | |
options.encoding = 'UTF-8' | |
} | |
} | |
android { | |
compileSdkVersion 19 | |
buildToolsVersion "19.0.3" | |
defaultConfig { | |
versionCode 1 | |
versionName "0.0.1" | |
minSdkVersion 9 | |
targetSdkVersion 19 | |
} | |
// // 複数のバージョン作りたいなら | |
// productFlavors { | |
// dev { | |
// versionCode 1 | |
// versionName "1.0" | |
// } | |
// pro { | |
// versionCode 1 | |
// versionName "1.0" | |
// } | |
// } | |
// 署名関係 | |
signingConfigs { | |
debug { | |
// storeFile file("signingConfigs/debug.keystore") | |
} | |
} | |
buildTypes { | |
debug { | |
packageNameSuffix ".debug" | |
// 署名と難読化はやらない | |
debuggable true | |
jniDebugBuild true | |
zipAlign true | |
// runProguard true | |
// proguardFile getDefaultProguardFile('proguard-android.txt') | |
} | |
} | |
sourceSets { | |
main { | |
manifest.srcFile 'AndroidManifest.xml' | |
java.srcDirs = ['src'] | |
resources.srcDirs = ['src'] | |
aidl.srcDirs = ['src'] | |
renderscript.srcDirs = ['src'] | |
res.srcDirs = ['res'] | |
assets.srcDirs = ['assets'] | |
} | |
} | |
} | |
task resourcesCopy(dependsOn: "resourcesClean", type: Copy) { | |
from "../Resources" | |
into "assets" | |
} | |
task resourcesDelete(type: Delete) { | |
delete "assets" | |
} | |
task resourcesClean (dependsOn: "resourcesDelete" ) << { | |
def classesDir = new File("assets") | |
classesDir.mkdirs() | |
} | |
task ndkBuild(type:Exec) { | |
def cpu_num = Runtime.getRuntime().availableProcessors() | |
println "cpu_num=${cpu_num}" | |
commandLine 'ndk-build', "-j${cpu_num}" | |
} | |
task ndkClean(type:Exec) { | |
commandLine 'ndk-build', 'clean' | |
} | |
task libsClean(type: Delete) { | |
delete 'libs/armeabi', 'libs/armeabi-v7a', 'libs/x86', 'libs/mips' | |
} | |
task objClean(type: Delete) { | |
delete 'obj' | |
} | |
if (new File(projectDir, "jni").exists()) { | |
tasks.withType(JavaCompile) { | |
compileTask -> compileTask.dependsOn ndkBuild | |
} | |
tasks.withType(JavaCompile) { | |
compileTask -> compileTask.dependsOn resourcesCopy | |
} | |
//mod see http://stackoverflow.com/questions/20704812/android-studio-0-4-could-not-find-method-jnidir | |
tasks.withType(com.android.build.gradle.tasks.PackageApplication) {pkgTask -> | |
pkgTask.jniFolders = new HashSet<File>() | |
pkgTask.jniFolders.add(new File(projectDir, 'libs')) | |
} | |
clean.dependsOn 'ndkClean' | |
clean.dependsOn 'libsClean' | |
clean.dependsOn 'objClean' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment