Skip to content

Commit

Permalink
Updating build.gradle files to depend on gpg-sdk
Browse files Browse the repository at this point in the history
This adds a dependency task to each sample for running the Common/gpg-sdk project.
This project downloads and unzips the C++ SDK before compilation.

Change-Id: I0013f66ecc5ce045f1ed3d85537ab78347049bc1
  • Loading branch information
claywilkinson committed Jan 29, 2016
1 parent e01a3fd commit 8f5216d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 66 deletions.
24 changes: 13 additions & 11 deletions samples-android/ButtonClicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
apply plugin: 'com.android.model.application'

evaluationDependsOn(':Common/gpg-sdk')
// Depend on another project that downloads and unzips the C++ SDK.
evaluationDependsOn(':Common/gpg-sdk')

// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
}
}

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"

Expand All @@ -21,20 +32,11 @@ model {
}
}
android {
signingConfigs.with {
debug {
storeFile = file('/Users/wilkinsonclay/gswitch/automation-cpp-android-samples/configs/debug.keystore')
keyAlias = 'androiddebugkey'
keyPassword = 'android'
storePassword = 'android'
}
}

compileSdkVersion=23
buildToolsVersion="23.0.2"

defaultConfig.with {
applicationId= "com.google.clayton.play.bc"
applicationId="com.google.example.games.ButtonClicker"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23
}
Expand Down
13 changes: 13 additions & 0 deletions samples-android/CollectAllTheStarsNative/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
apply plugin: 'com.android.model.application'

// Depend on another project that downloads and unzips the C++ SDK.
evaluationDependsOn(':Common/gpg-sdk')

// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
}
}

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"

// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
Expand Down
23 changes: 18 additions & 5 deletions samples-android/Common/cpufeatures/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
apply plugin: "com.android.model.native"

// Retrieve ndk path: ndk.dir MUST be set in file local.properties
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
def ndkDir = null

if (project.rootProject.file('local.properties').exists()) {
// Retrieve ndk path: ndk.dir MUST be set in file local.properties
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
ndkDir = properties.getProperty('ndk.dir')
} else if (System.getProperty('ANDROID_NDK_HOME') != null) {
ndkDir = System.getProperty('ANDROID_NDK_HOME')
} else if (System.getenv('ANDROID_NDK_HOME') != null) {
ndkDir = System.getenv('ANDROID_NDK_HOME')
}

if (ndkDir == null || ndkDir == "") {
throw new Exception("Need to run from Android Studio or define ANDROID_NDK_HOME")
}


model {
android {
Expand All @@ -13,7 +26,7 @@ model {
android.ndk {
moduleName = "cpufeatures"
}

android.sources {
main {
jni {
Expand Down
67 changes: 17 additions & 50 deletions samples-android/Common/native_app_glue/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
apply plugin: "com.android.model.native"

// Retrieve ndk path: ndk.dir MUST be set in file local.properties
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
def ndkDir = null

if (project.rootProject.file('local.properties').exists()) {
// Retrieve ndk path: ndk.dir MUST be set in file local.properties
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
ndkDir = properties.getProperty('ndk.dir')
} else if (System.getProperty('ANDROID_NDK_HOME') != null) {
ndkDir = System.getProperty('ANDROID_NDK_HOME')
} else if (System.getenv('ANDROID_NDK_HOME') != null) {
ndkDir = System.getenv('ANDROID_NDK_HOME')
}

if (ndkDir == null || ndkDir == "") {
throw new Exception("Need to run from Android Studio or define ANDROID_NDK_HOME")
}

model {
android {
Expand Down Expand Up @@ -33,52 +45,7 @@ model {
We are building a static library, so disable all the shared library tasks.
*/
tasks.whenTaskAdded { task ->
if (task.name == 'linkArmeabi-v7aDebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkArm64-v8aDebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkArmeabiDebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkX86DebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsArmeabi-v7aDebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsArm64-v8aDebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsArmeabiDebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsX86DebugNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkArm64-v8aReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsArm64-v8aReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkArmeabi-v7aReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsArmeabi-v7aReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkArmeabiReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsArmeabiReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'linkX86ReleaseNative_app_glueSharedLibrary') {
task.enabled = false
}
else if (task.name == 'stripSymbolsX86ReleaseNative_app_glueSharedLibrary') {
if (task.name.contains("SharedLibrary")) {
task.enabled = false
}
}
13 changes: 13 additions & 0 deletions samples-android/Minimalist/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
apply plugin: 'com.android.model.application'

// Depend on another project that downloads and unzips the C++ SDK.
evaluationDependsOn(':Common/gpg-sdk')

// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
}
}

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"

// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
Expand Down
13 changes: 13 additions & 0 deletions samples-android/Teapot/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
apply plugin: 'com.android.model.application'

// Depend on another project that downloads and unzips the C++ SDK.
evaluationDependsOn(':Common/gpg-sdk')

// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
}
}

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"

// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
Expand Down
13 changes: 13 additions & 0 deletions samples-android/TrivialQuestNative/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
apply plugin: 'com.android.model.application'

// Depend on another project that downloads and unzips the C++ SDK.
evaluationDependsOn(':Common/gpg-sdk')

// As the plugin has created the build tasks, add the gpg-sdk task to
// the task dependencies so it gets done before compiling
tasks.whenTaskAdded { task ->
if (task.name.equals("preBuild")) {
project(':Common/gpg-sdk').defaultTasks.each { t ->
task.dependsOn project(':Common/gpg-sdk').tasks[t]
}
}
}

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"

// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
Expand Down

0 comments on commit 8f5216d

Please sign in to comment.