summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguanghuafan <gfan@google.com>2017-04-26 14:31:16 -0700
committerCody Northrop <cnorthrop@google.com>2017-04-26 17:15:30 -0600
commitf889e5e31016e31cbce9e057fd2513ba4c686101 (patch)
tree11a14168c2a29a56e89588c94444abe411e4c4c5
parent51c4239d382a5382c8320196206b43b19a3b7245 (diff)
demo/smoke Android build update: use latest cmake with Android Studio
-rw-r--r--demos/smoke/android/CMakeLists.txt54
-rwxr-xr-xdemos/smoke/android/build-and-install3
-rw-r--r--demos/smoke/android/build.gradle105
-rw-r--r--demos/smoke/android/gradle/wrapper/gradle-wrapper.properties4
4 files changed, 88 insertions, 78 deletions
diff --git a/demos/smoke/android/CMakeLists.txt b/demos/smoke/android/CMakeLists.txt
new file mode 100644
index 00000000..8846bce3
--- /dev/null
+++ b/demos/smoke/android/CMakeLists.txt
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+project(Smoke)
+cmake_minimum_required(VERSION 3.4.1)
+
+get_filename_component(demosDir "${CMAKE_SOURCE_DIR}/../.." ABSOLUTE)
+set(smokeDir "${demosDir}/smoke")
+get_filename_component(glmDir "${demosDir}/../libs" ABSOLUTE)
+get_filename_component(vulkanDir "${demosDir}/../include" ABSOLUTE)
+
+# build native_app_glue as a static lib
+add_library(native_activity_glue STATIC
+ ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
+
+# Build application's shared lib
+set(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -std=c++11 -fexceptions -Wall \
+ -Wextra -Wno-unused-parameter \
+ -DVK_NO_PROTOTYPES -DVK_USE_PLATFORM_ANDROID_KHR \
+ -DGLM_FORCE_RADIANS")
+add_library(Smoke SHARED
+ ${smokeDir}/Game.cpp
+ ${smokeDir}/Meshes.cpp
+ ${smokeDir}/Simulation.cpp
+ ${smokeDir}/HelpersDispatchTable.cpp
+ ${smokeDir}/Shell.cpp
+ ${smokeDir}/ShellAndroid.cpp
+ ${smokeDir}/Smoke.cpp
+ ${smokeDir}/Main.cpp)
+
+target_include_directories(Smoke PRIVATE
+ ${ANDROID_NDK}/sources/android/native_app_glue
+ ${vulkanDir}
+ ${glmDir}
+ ${CMAKE_SOURCE_DIR}/src/main/jni)
+
+target_link_libraries(Smoke
+ android
+ log
+ native_activity_glue)
diff --git a/demos/smoke/android/build-and-install b/demos/smoke/android/build-and-install
index 7ee17b44..c3295a9b 100755
--- a/demos/smoke/android/build-and-install
+++ b/demos/smoke/android/build-and-install
@@ -34,8 +34,7 @@ build() {
}
install() {
- adb uninstall com.example.Smoke
- adb install build/outputs/apk/android-fat-debug.apk
+ adb install -r build/outputs/apk/android-debug.apk
}
run() {
diff --git a/demos/smoke/android/build.gradle b/demos/smoke/android/build.gradle
index 943b46ac..30df002c 100644
--- a/demos/smoke/android/build.gradle
+++ b/demos/smoke/android/build.gradle
@@ -4,92 +4,49 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle-experimental:0.8.0'
+ classpath 'com.android.tools.build:gradle:2.3.0'
}
}
-apply plugin: 'com.android.model.application'
-
-def demosDir = "../.."
-def smokeDir = "${demosDir}/smoke"
-def glmDir = "${demosDir}/../libs"
-def vulkanDir = "${demosDir}/../include"
-def layersDir = "${demosDir}/../build-android/libs"
-
-Properties properties = new Properties()
-properties.load(project.rootProject.file('local.properties').newDataInputStream())
-def ndkDir = properties.getProperty('ndk.dir')
-
-model {
- android {
- compileSdkVersion = 23
- buildToolsVersion = "23.0.2"
-
- defaultConfig.with {
- applicationId = "com.example.Smoke"
- minSdkVersion.apiLevel = 22
- targetSdkVersion.apiLevel = 22
- versionCode = 1
- versionName = "0.1"
+apply plugin: 'com.android.application'
+
+def layersDir = "../../../build-android/libs"
+
+android {
+ compileSdkVersion = 25
+ buildToolsVersion = "25.0.2"
+
+ defaultConfig {
+ applicationId = "com.example.Smoke"
+ minSdkVersion 24
+ targetSdkVersion 24
+ versionCode = 1
+ versionName = "0.1"
+ ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
+ externalNativeBuild {
+ cmake.arguments '-DANDROID_PLATFORM=android-24',
+ '-DANDROID_STL=c++_static',
+ '-DANDROID_TOOLCHAIN=clang'
}
}
-
- android.ndk {
- moduleName = "Smoke"
- toolchain = "clang"
- stl = "c++_static"
-
- cppFlags.addAll(["-std=c++11", "-fexceptions"])
- cppFlags.addAll(["-Wall", "-Wextra", "-Wno-unused-parameter"])
-
- cppFlags.addAll([
- "-DVK_NO_PROTOTYPES",
- "-DVK_USE_PLATFORM_ANDROID_KHR",
- "-DGLM_FORCE_RADIANS",
- ])
-
- cppFlags.addAll([
- "-I${file("${ndkDir}/sources/android/native_app_glue")}".toString(),
- "-I${file("${vulkanDir}")}".toString(),
- "-I${file("${glmDir}")}".toString(),
- "-I${file("src/main/jni")}".toString(),
- ])
-
- ldLibs.addAll(["android", "log", "dl"])
+ externalNativeBuild {
+ cmake.path 'CMakeLists.txt'
}
- android.sources {
- main {
- jni {
- source {
- srcDir "${ndkDir}/sources/android/native_app_glue"
- srcDir "${smokeDir}"
- exclude 'ShellXcb.cpp'
- exclude 'ShellWin32.cpp'
- exclude 'ShellWayland.cpp'
- }
- }
- jniLibs {
- dependencies {
- source.srcDir "${layersDir}"
- }
- }
- }
+ // Need Android NDK-r12+ for pre-built validation layers
+ sourceSets {
+ main.jniLibs.srcDirs = [ "${layersDir}" ]
}
- android.buildTypes {
+ buildTypes {
release {
- ndk.with {
+ // enable debugging for release built too
+ ndk {
debuggable = true
}
- }
- }
-
- android.productFlavors {
- create ("fat") {
- ndk.abiFilters.add("arm64-v8a")
- ndk.abiFilters.add("armeabi-v7a")
- ndk.abiFilters.add("x86")
+ minifyEnabled = false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'),
+ 'proguard-rules.pro'
}
}
}
diff --git a/demos/smoke/android/gradle/wrapper/gradle-wrapper.properties b/demos/smoke/android/gradle/wrapper/gradle-wrapper.properties
index 6c7451b7..5b57031b 100644
--- a/demos/smoke/android/gradle/wrapper/gradle-wrapper.properties
+++ b/demos/smoke/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Jan 27 08:20:52 CST 2016
+#Mon Apr 24 14:40:58 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip