Skip to content

Commit

Permalink
Changes to support automated building of samples via Gradle.
Browse files Browse the repository at this point in the history
Change-Id: Ib3698e18d4cc478c749335e70c1fa4f367c5d766
  • Loading branch information
claywilkinson committed Jan 7, 2016
1 parent 7c19ff5 commit 1aa2c6d
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 72 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ libs/
local.properties
obj/
.settings/

.gradle/
build/

samples-android/Common/gpg-sdk/gpg-cpp-sdk/
samples-android/Common/gpg-sdk/gpg_cpp_sdk.zip
6 changes: 3 additions & 3 deletions samples-android/ButtonClicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')

def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
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"]
// used to set stl and location of libgpg.a
Expand Down Expand Up @@ -38,8 +38,8 @@ model {
jni {
dependencies {
library "gpg" linkage "static"
project ":cpufeatures" linkage "static"
project ":native_app_glue" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
Expand Down
9 changes: 9 additions & 0 deletions samples-android/ButtonClicker/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Google Play game services IDs.
Replace this file with the games-ids.xml downloaded from the Play Game Console.
-->
<resources>
<string name="app_id">REPLACE_ME</string>
</resources>

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<resources>

<string name="app_name">ButtonClicker</string>
<string name="app_id">REPLACE_ME</string>

</resources>
8 changes: 4 additions & 4 deletions samples-android/CollectAllTheStarsNative/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')

def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
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"]
// used to set stl and location of libgpg.a
Expand Down Expand Up @@ -39,8 +39,8 @@ model {
jni {
dependencies {
library "gpg" linkage "static"
project ":cpufeatures" linkage "static"
project ":native_app_glue" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
Expand Down Expand Up @@ -80,4 +80,4 @@ model {
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services:8.3.0'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Google Play game services IDs.
Save this file as res/values/games-ids.xml in your project.
-->
<resources>
<string name="app_id">REPLACE_ME</string>
</resources>

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<resources>
<string name="app_name">CollectAllTheStarsNative</string>
<string name="app_id">REPLACE_ME</string>
</resources>
</resources>
57 changes: 56 additions & 1 deletion samples-android/Common/native_app_glue/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ model {
}

android.ndk {
abiFilters.addAll(["armeabi", "armeabi-v7a", "x86", "arm64-v8a"])
moduleName = "native_app_glue"
}

android.sources {
main {
jni {
Expand All @@ -27,3 +28,57 @@ 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') {
task.enabled = false
}
}
4 changes: 2 additions & 2 deletions samples-android/Minimalist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')

def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
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"]
// used to set stl and location of libgpg.a
Expand Down Expand Up @@ -40,7 +40,7 @@ model {
jni {
dependencies {
library "gpg" linkage "static"
project ":native_app_glue" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
Expand Down
8 changes: 4 additions & 4 deletions samples-android/TbmpSkeletonNative/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')

def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
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"]
// used to set stl and location of libgpg.a
Expand Down Expand Up @@ -42,8 +42,8 @@ model {
jni {
dependencies {
library "gpg" linkage "static"
project ":cpufeatures" linkage "static"
project ":native_app_glue" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
Expand Down Expand Up @@ -84,4 +84,4 @@ model {
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services:8.3.0'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Google Play game services IDs.
Save this file as res/values/games-ids.xml in your project.
-->
<resources>
<string name="app_id">REPLACE_ME</string>
</resources>

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<resources>

<string name="app_name">TBMPSkeleton</string>
<string name="app_id">REPLACE_ME</string>

</resources>
</resources>
6 changes: 3 additions & 3 deletions samples-android/Teapot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')

def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
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"]
// used to set stl and location of libgpg.a
Expand Down Expand Up @@ -38,8 +38,8 @@ model {
jni {
dependencies {
library "gpg" linkage "static"
project ":cpufeatures" linkage "static"
project ":native_app_glue" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
Expand Down
3 changes: 1 addition & 2 deletions samples-android/Teapot/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
package="com.google.example.nativegame"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application
android:debuggable="true"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
Expand Down
25 changes: 18 additions & 7 deletions samples-android/Teapot/src/main/jni/NativeGameActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
#define JUIHELPER_CLASS_NAME "com.sample.helper.JUIHelper"
// Share object name of helper function library
#define HELPER_CLASS_SONAME "NativeGameActivity"
// Replace this with one of your non-incremental achievements.
#define TEST_ACHIEVEMENT_ID "REPLACE_ME"
// Replace this with one of your leaderboards.
#define TEST_LEADERBOARD_ID "REPLACE_ME"

//------------------------------------------------------------------------------
// Shared state for our app.
Expand Down Expand Up @@ -156,7 +152,12 @@ void Engine::InitUI() {
[this](jui_helper::JUIView *view, const int32_t message) {
LOGI("Button click: %d", message);
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
StateManager::UnlockAchievement(TEST_ACHIEVEMENT_ID);
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("achievement_prime");
if( id == "" || id == "ReplaceMe") {
LOGI("Invalid achievement ID!, please check res/values/ids.xml");
return;
}
StateManager::UnlockAchievement(id.c_str());
}
});
jui_helper::JUIWindow::GetInstance()->AddView(button_achievement);
Expand Down Expand Up @@ -212,7 +213,12 @@ void Engine::InitUI() {
[this](jui_helper::JUIView *view, const int32_t message) {
LOGI("Button click: %d", message);
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
StateManager::SubmitHighScore(TEST_LEADERBOARD_ID, current_score_);
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("leaderboard_easy");
if( id == "" || id == "ReplaceMe") {
LOGI("Invalid Leaderboard ID!, please check res/values/ids.xml");
return;
}
StateManager::SubmitHighScore(id.c_str(), current_score_);
}
});
jui_helper::JUIWindow::GetInstance()->AddView(button_submit_high_score);
Expand All @@ -229,7 +235,12 @@ void Engine::InitUI() {
[this](jui_helper::JUIView *view, const int32_t message) {
LOGI("Button click: %d", message);
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
StateManager::ShowLeaderboard(TEST_LEADERBOARD_ID);
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("leaderboard_easy");
if( id == "" || id == "ReplaceMe") {
LOGI("Invalid Leaderboard ID!, please check res/values/ids.xml");
return;
}
StateManager::ShowLeaderboard(id.c_str());
}
});
jui_helper::JUIWindow::GetInstance()->AddView(button_show_leaderboard_ui);
Expand Down
9 changes: 8 additions & 1 deletion samples-android/Teapot/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Google Play game services IDs.
Save this file as res/values/games-ids.xml in your project.
-->
<resources>
<string name="app_id">REPLACE_ME</string>
<string name="app_id">ReplaceMe</string>
<string name="achievement_prime">ReplaceMe</string>
<string name="leaderboard_easy">ReplaceMe</string>
</resources>
6 changes: 3 additions & 3 deletions samples-android/TrivialQuestNative/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')

def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
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"]
// used to set stl and location of libgpg.a
Expand Down Expand Up @@ -39,8 +39,8 @@ model {
jni {
dependencies {
library "gpg" linkage "static"
project ":cpufeatures" linkage "static"
project ":native_app_glue" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ void Engine::InitUI() {
button_green_->SetCallback(
[this](jui_helper::JUIView * view, const int32_t message) {
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("green_event_id");
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_green");
if( id == "" || id == "ReplaceMe")
{
LOGI("Invalid Event ID!, please check res/values/strings.xml");
LOGI("Invalid Event ID!, please check res/values/ids.xml");
return;
}
service_->Events().Increment(id.c_str());
Expand All @@ -328,10 +328,10 @@ void Engine::InitUI() {
button_yellow_->SetCallback(
[this](jui_helper::JUIView * view, const int32_t message) {
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("yellow_event_id");
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_yellow");
if( id == "" || id == "ReplaceMe")
{
LOGI("Invalid Event ID!, please check res/values/strings.xml");
LOGI("Invalid Event ID!, please check res/values/ids.xml");
return;
}
service_->Events().Increment(id.c_str());
Expand All @@ -351,10 +351,10 @@ void Engine::InitUI() {
button_blue_->SetCallback(
[this](jui_helper::JUIView * view, const int32_t message) {
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("blue_event_id");
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_blue");
if( id == "" || id == "ReplaceMe")
{
LOGI("Invalid Event ID!, please check res/values/strings.xml");
LOGI("Invalid Event ID!, please check res/values/ids.xml");
return;
}
service_->Events().Increment(id.c_str());
Expand All @@ -374,10 +374,10 @@ void Engine::InitUI() {
button_red_->SetCallback(
[this](jui_helper::JUIView * view, const int32_t message) {
if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("red_event_id");
std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_red");
if( id == "" || id == "ReplaceMe")
{
LOGI("Invalid Event ID!, please check res/values/strings.xml");
LOGI("Invalid Event ID!, please check res/values/ids.xml");
return;
}
service_->Events().Increment(id.c_str());
Expand Down
Loading

0 comments on commit 1aa2c6d

Please sign in to comment.