Skip to content

Commit 8f5216d

Browse files
committed
Updating build.gradle files to depend on gpg-sdk
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
1 parent e01a3fd commit 8f5216d

File tree

7 files changed

+100
-66
lines changed

7 files changed

+100
-66
lines changed

samples-android/ButtonClicker/build.gradle

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
apply plugin: 'com.android.model.application'
22

3-
evaluationDependsOn(':Common/gpg-sdk')
3+
// Depend on another project that downloads and unzips the C++ SDK.
4+
evaluationDependsOn(':Common/gpg-sdk')
5+
6+
// As the plugin has created the build tasks, add the gpg-sdk task to
7+
// the task dependencies so it gets done before compiling
8+
tasks.whenTaskAdded { task ->
9+
if (task.name.equals("preBuild")) {
10+
project(':Common/gpg-sdk').defaultTasks.each { t ->
11+
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12+
}
13+
}
14+
}
415

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

@@ -21,20 +32,11 @@ model {
2132
}
2233
}
2334
android {
24-
signingConfigs.with {
25-
debug {
26-
storeFile = file('/Users/wilkinsonclay/gswitch/automation-cpp-android-samples/configs/debug.keystore')
27-
keyAlias = 'androiddebugkey'
28-
keyPassword = 'android'
29-
storePassword = 'android'
30-
}
31-
}
32-
3335
compileSdkVersion=23
3436
buildToolsVersion="23.0.2"
3537

3638
defaultConfig.with {
37-
applicationId= "com.google.clayton.play.bc"
39+
applicationId="com.google.example.games.ButtonClicker"
3840
minSdkVersion.apiLevel = 11
3941
targetSdkVersion.apiLevel = 23
4042
}

samples-android/CollectAllTheStarsNative/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
apply plugin: 'com.android.model.application'
22

3+
// Depend on another project that downloads and unzips the C++ SDK.
4+
evaluationDependsOn(':Common/gpg-sdk')
5+
6+
// As the plugin has created the build tasks, add the gpg-sdk task to
7+
// the task dependencies so it gets done before compiling
8+
tasks.whenTaskAdded { task ->
9+
if (task.name.equals("preBuild")) {
10+
project(':Common/gpg-sdk').defaultTasks.each { t ->
11+
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12+
}
13+
}
14+
}
15+
316
def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
417

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

samples-android/Common/cpufeatures/build.gradle

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
apply plugin: "com.android.model.native"
22

3-
// Retrieve ndk path: ndk.dir MUST be set in file local.properties
4-
Properties properties = new Properties()
5-
properties.load(project.rootProject.file('local.properties').newDataInputStream())
6-
def ndkDir = properties.getProperty('ndk.dir')
3+
def ndkDir = null
4+
5+
if (project.rootProject.file('local.properties').exists()) {
6+
// Retrieve ndk path: ndk.dir MUST be set in file local.properties
7+
Properties properties = new Properties()
8+
properties.load(project.rootProject.file('local.properties').newDataInputStream())
9+
ndkDir = properties.getProperty('ndk.dir')
10+
} else if (System.getProperty('ANDROID_NDK_HOME') != null) {
11+
ndkDir = System.getProperty('ANDROID_NDK_HOME')
12+
} else if (System.getenv('ANDROID_NDK_HOME') != null) {
13+
ndkDir = System.getenv('ANDROID_NDK_HOME')
14+
}
15+
16+
if (ndkDir == null || ndkDir == "") {
17+
throw new Exception("Need to run from Android Studio or define ANDROID_NDK_HOME")
18+
}
19+
720

821
model {
922
android {
@@ -13,7 +26,7 @@ model {
1326
android.ndk {
1427
moduleName = "cpufeatures"
1528
}
16-
29+
1730
android.sources {
1831
main {
1932
jni {
Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
apply plugin: "com.android.model.native"
22

3-
// Retrieve ndk path: ndk.dir MUST be set in file local.properties
4-
Properties properties = new Properties()
5-
properties.load(project.rootProject.file('local.properties').newDataInputStream())
6-
def ndkDir = properties.getProperty('ndk.dir')
3+
def ndkDir = null
4+
5+
if (project.rootProject.file('local.properties').exists()) {
6+
// Retrieve ndk path: ndk.dir MUST be set in file local.properties
7+
Properties properties = new Properties()
8+
properties.load(project.rootProject.file('local.properties').newDataInputStream())
9+
ndkDir = properties.getProperty('ndk.dir')
10+
} else if (System.getProperty('ANDROID_NDK_HOME') != null) {
11+
ndkDir = System.getProperty('ANDROID_NDK_HOME')
12+
} else if (System.getenv('ANDROID_NDK_HOME') != null) {
13+
ndkDir = System.getenv('ANDROID_NDK_HOME')
14+
}
15+
16+
if (ndkDir == null || ndkDir == "") {
17+
throw new Exception("Need to run from Android Studio or define ANDROID_NDK_HOME")
18+
}
719

820
model {
921
android {
@@ -33,52 +45,7 @@ model {
3345
We are building a static library, so disable all the shared library tasks.
3446
*/
3547
tasks.whenTaskAdded { task ->
36-
if (task.name == 'linkArmeabi-v7aDebugNative_app_glueSharedLibrary') {
37-
task.enabled = false
38-
}
39-
else if (task.name == 'linkArm64-v8aDebugNative_app_glueSharedLibrary') {
40-
task.enabled = false
41-
}
42-
else if (task.name == 'linkArmeabiDebugNative_app_glueSharedLibrary') {
43-
task.enabled = false
44-
}
45-
else if (task.name == 'linkX86DebugNative_app_glueSharedLibrary') {
46-
task.enabled = false
47-
}
48-
else if (task.name == 'stripSymbolsArmeabi-v7aDebugNative_app_glueSharedLibrary') {
49-
task.enabled = false
50-
}
51-
else if (task.name == 'stripSymbolsArm64-v8aDebugNative_app_glueSharedLibrary') {
52-
task.enabled = false
53-
}
54-
else if (task.name == 'stripSymbolsArmeabiDebugNative_app_glueSharedLibrary') {
55-
task.enabled = false
56-
}
57-
else if (task.name == 'stripSymbolsX86DebugNative_app_glueSharedLibrary') {
58-
task.enabled = false
59-
}
60-
else if (task.name == 'linkArm64-v8aReleaseNative_app_glueSharedLibrary') {
61-
task.enabled = false
62-
}
63-
else if (task.name == 'stripSymbolsArm64-v8aReleaseNative_app_glueSharedLibrary') {
64-
task.enabled = false
65-
}
66-
else if (task.name == 'linkArmeabi-v7aReleaseNative_app_glueSharedLibrary') {
67-
task.enabled = false
68-
}
69-
else if (task.name == 'stripSymbolsArmeabi-v7aReleaseNative_app_glueSharedLibrary') {
70-
task.enabled = false
71-
}
72-
else if (task.name == 'linkArmeabiReleaseNative_app_glueSharedLibrary') {
73-
task.enabled = false
74-
}
75-
else if (task.name == 'stripSymbolsArmeabiReleaseNative_app_glueSharedLibrary') {
76-
task.enabled = false
77-
}
78-
else if (task.name == 'linkX86ReleaseNative_app_glueSharedLibrary') {
79-
task.enabled = false
80-
}
81-
else if (task.name == 'stripSymbolsX86ReleaseNative_app_glueSharedLibrary') {
48+
if (task.name.contains("SharedLibrary")) {
8249
task.enabled = false
8350
}
8451
}

samples-android/Minimalist/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
apply plugin: 'com.android.model.application'
22

3+
// Depend on another project that downloads and unzips the C++ SDK.
4+
evaluationDependsOn(':Common/gpg-sdk')
5+
6+
// As the plugin has created the build tasks, add the gpg-sdk task to
7+
// the task dependencies so it gets done before compiling
8+
tasks.whenTaskAdded { task ->
9+
if (task.name.equals("preBuild")) {
10+
project(':Common/gpg-sdk').defaultTasks.each { t ->
11+
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12+
}
13+
}
14+
}
15+
316
def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
417

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

samples-android/Teapot/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
apply plugin: 'com.android.model.application'
22

3+
// Depend on another project that downloads and unzips the C++ SDK.
4+
evaluationDependsOn(':Common/gpg-sdk')
5+
6+
// As the plugin has created the build tasks, add the gpg-sdk task to
7+
// the task dependencies so it gets done before compiling
8+
tasks.whenTaskAdded { task ->
9+
if (task.name.equals("preBuild")) {
10+
project(':Common/gpg-sdk').defaultTasks.each { t ->
11+
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12+
}
13+
}
14+
}
15+
316
def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
417

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

samples-android/TrivialQuestNative/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
apply plugin: 'com.android.model.application'
22

3+
// Depend on another project that downloads and unzips the C++ SDK.
4+
evaluationDependsOn(':Common/gpg-sdk')
5+
6+
// As the plugin has created the build tasks, add the gpg-sdk task to
7+
// the task dependencies so it gets done before compiling
8+
tasks.whenTaskAdded { task ->
9+
if (task.name.equals("preBuild")) {
10+
project(':Common/gpg-sdk').defaultTasks.each { t ->
11+
task.dependsOn project(':Common/gpg-sdk').tasks[t]
12+
}
13+
}
14+
}
15+
316
def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
417

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

0 commit comments

Comments
 (0)