Skip to content

Commit 4cd5853

Browse files
hevrardpaulthomson
authored andcommitted
Update and refactor GLES worker gradle scripts to build with recent Android SDK (#118)
1 parent 11b164a commit 4cd5853

File tree

12 files changed

+135
-307
lines changed

12 files changed

+135
-307
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ matrix:
2626
dist: trusty
2727
sudo: required
2828
env:
29+
- TITLE="GraphicsFuzz and GLES workers"
2930
- INSTALL_SCRIPT="build/travis/1-install-deps-travis.sh"
3031
- BUILD_SCRIPT="python3.6 build/travis/build.py"
3132
- RELEASE_SCRIPT="python3.6 build/travis/release.py"
3233
- os: linux
3334
dist: trusty
3435
sudo: required
3536
env:
36-
- INSTALL_SCRIPT="build/ci_vulkan_worker/1-install-deps-travis.sh"
37+
- TITLE="Vulkan worker"
38+
- INSTALL_SCRIPT="build/travis/1-install-deps-travis.sh"
3739
- BUILD_SCRIPT="build/ci_vulkan_worker/2-build-travis.sh"
3840
- RELEASE_SCRIPT="python3.6 build/travis/release.py"
3941
- ANDROID_NDK_HOME=/opt/android-sdk/ndk-bundle

build/ci_vulkan_worker/1-install-deps-travis.sh

-82
This file was deleted.

build/travis/1-install-deps-travis.sh

+28-8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ if [ "$(uname)" == "Darwin" ];
2828
then
2929
brew install python3 unzip wget
3030
GITHUB_RELEASE_TOOL_ARCH="darwin_amd64"
31+
ANDROID_HOST_PLATFORM="darwin"
3132
fi
3233

3334
if [ "$(uname)" == "Linux" ];
@@ -36,6 +37,7 @@ then
3637
sudo apt-get update -q
3738
sudo apt-get install python3.6 unzip wget -y
3839
GITHUB_RELEASE_TOOL_ARCH="linux_amd64"
40+
ANDROID_HOST_PLATFORM="linux"
3941
fi
4042

4143

@@ -44,17 +46,35 @@ wget "https://github.com/${GITHUB_RELEASE_TOOL_USER}/github-release/releases/dow
4446
tar xf "github-release_${GITHUB_RELEASE_TOOL_VERSION}_${GITHUB_RELEASE_TOOL_ARCH}.tar.gz"
4547
popd
4648

47-
# Android SDK
4849

49-
export ANDROID_TOOLS_FILENAME="tools_r25.2.3-linux.zip"
50-
export ANDROID_API_LEVELS="platforms;android-23"
51-
export ANDROID_BUILD_TOOLS_VERSION="25.0.0"
52-
export ANDROID_TOOLS_URL="http://dl.google.com/android/repository/${ANDROID_TOOLS_FILENAME}"
50+
# Android SDK (host platform is linux, darwin, or windows).
51+
52+
ANDROID_TOOLS_FILENAME="sdk-tools-${ANDROID_HOST_PLATFORM}-4333796.zip"
53+
ANDROID_NDK_FILENAME="android-ndk-r18b-${ANDROID_HOST_PLATFORM}-x86_64.zip"
54+
ANDROID_PLATFORM_TOOLS_FILENAME="platform-tools_r28.0.1-${ANDROID_HOST_PLATFORM}.zip"
5355

5456
mkdir -p "${ANDROID_HOME}"
5557
pushd "${ANDROID_HOME}"
56-
wget -q "${ANDROID_TOOLS_URL}"
57-
unzip "${ANDROID_TOOLS_FILENAME}"
58+
59+
# Android: "sdk-tools.zip" "tools":
60+
wget -q "http://dl.google.com/android/repository/${ANDROID_TOOLS_FILENAME}"
61+
unzip -q "${ANDROID_TOOLS_FILENAME}"
5862
rm "${ANDROID_TOOLS_FILENAME}"
59-
echo y | sdkmanager "extras;android;m2repository" "tools" "platform-tools" "${ANDROID_API_LEVELS}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}"
63+
64+
# Android "android-ndk.zip" "ndk-bundle"
65+
wget -q "https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}"
66+
unzip -q "${ANDROID_NDK_FILENAME}"
67+
rm "${ANDROID_NDK_FILENAME}"
68+
mv android-ndk-*/ ndk-bundle
69+
70+
# Android "platform-tools.zip" "platform-tools"
71+
wget -q "https://dl.google.com/android/repository/${ANDROID_PLATFORM_TOOLS_FILENAME}"
72+
unzip -q "${ANDROID_PLATFORM_TOOLS_FILENAME}"
73+
rm "${ANDROID_PLATFORM_TOOLS_FILENAME}"
74+
75+
# Android "platforms" and "build-tools"
76+
echo y | sdkmanager \
77+
"platforms;android-26" \
78+
"build-tools;28.0.2"
79+
6080
popd

build/travis/build.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616

1717
import os
18+
import sys
1819
import subprocess
1920
import shutil
2021
import licenses
@@ -46,6 +47,8 @@ def check_call_filter(cmd):
4647
continue
4748
print(line, end="")
4849
return_code = proc.wait()
50+
print("")
51+
sys.stdout.flush()
4952
assert return_code == 0
5053

5154

@@ -95,7 +98,7 @@ def go():
9598
os.chdir(path("platforms", "libgdx", "OGLTesting"))
9699

97100
# Build desktop worker.
98-
subprocess.call(
101+
subprocess.check_call(
99102
["./gradlew", "desktop:dist"])
100103

101104
# Copy desktop worker.
@@ -105,12 +108,12 @@ def go():
105108
)
106109

107110
# Build Android worker
108-
subprocess.call(
111+
subprocess.check_call(
109112
["./gradlew", "android:assembleDebug"])
110113

111114
# Copy Android worker.
112115
shutil.copy2(
113-
path("android", "build", "outputs", "apk", "android-debug.apk"),
116+
path("android", "build", "outputs", "apk", "debug", "android-debug.apk"),
114117
path(source_root, "out", "android-gles-worker.apk")
115118
)
116119

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
1+
2+
buildscript {
3+
repositories {
4+
mavenLocal()
5+
mavenCentral()
6+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
7+
jcenter()
8+
google()
9+
}
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:3.2.0'
12+
}
13+
}
14+
15+
apply plugin: "com.android.application"
16+
17+
configurations { natives }
18+
19+
dependencies {
20+
implementation project(":core")
21+
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
22+
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
23+
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
24+
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
25+
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
26+
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
27+
implementation "com.android.support:appcompat-v7:23.4.0"
28+
implementation files("../../../../android-client-dep/target/android-client-dep-1.0.jar")
29+
}
30+
131
android {
2-
buildToolsVersion "25"
3-
compileSdkVersion 23
32+
compileSdkVersion 26
33+
34+
defaultConfig {
35+
applicationId "com.graphicsfuzz.libgdxclient"
36+
minSdkVersion 24
37+
targetSdkVersion 26
38+
versionCode 1
39+
versionName '0.0.1'
40+
}
41+
buildTypes {
42+
release {
43+
minifyEnabled false
44+
proguardFiles getDefaultProguardFile('proguard-android.txt'),
45+
'proguard-rules.pro'
46+
}
47+
}
448
sourceSets {
549
main {
650
manifest.srcFile 'AndroidManifest.xml'
@@ -13,22 +57,13 @@ android {
1357
}
1458

1559
}
16-
defaultConfig {
17-
applicationId "com.graphicsfuzz.libgdxclient"
18-
minSdkVersion 18
19-
targetSdkVersion 23
20-
}
21-
lintOptions {
22-
checkReleaseBuilds false
23-
abortOnError false
24-
}
2560
}
2661

2762

2863
// called every time gradle gets executed, takes the native dependencies of
2964
// the natives configuration, and extracts them to the proper libs/ folders
3065
// so they get packed with the APK.
31-
task copyAndroidNatives() {
66+
task copyAndroidNatives() {
3267
file("libs/armeabi/").mkdirs();
3368
file("libs/armeabi-v7a/").mkdirs();
3469
file("libs/arm64-v8a/").mkdirs();
@@ -38,7 +73,7 @@ task copyAndroidNatives() {
3873
configurations.natives.files.each { jar ->
3974
def outputDir = null
4075
if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
41-
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
76+
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
4277
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
4378
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
4479
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
@@ -52,78 +87,3 @@ task copyAndroidNatives() {
5287
}
5388
}
5489

55-
task run(type: Exec) {
56-
def path
57-
def localProperties = project.file("../local.properties")
58-
if (localProperties.exists()) {
59-
Properties properties = new Properties()
60-
localProperties.withInputStream { instr ->
61-
properties.load(instr)
62-
}
63-
def sdkDir = properties.getProperty('sdk.dir')
64-
if (sdkDir) {
65-
path = sdkDir
66-
} else {
67-
path = "$System.env.ANDROID_HOME"
68-
}
69-
} else {
70-
path = "$System.env.ANDROID_HOME"
71-
}
72-
73-
def adb = path + "/platform-tools/adb"
74-
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.graphicsfuzz.libgdxclient/com.graphicsfuzz.libgdxclient.AndroidLauncher'
75-
}
76-
77-
// sets up the Android Eclipse project, using the old Ant based build.
78-
eclipse {
79-
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
80-
// ignores any nodes added in classpath.file.withXml
81-
sourceSets {
82-
main {
83-
java.srcDirs "src", 'gen'
84-
}
85-
}
86-
87-
jdt {
88-
sourceCompatibility = 1.6
89-
targetCompatibility = 1.6
90-
}
91-
92-
classpath {
93-
plusConfigurations += [ project.configurations.compile ]
94-
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
95-
}
96-
97-
project {
98-
name = appName + "-android"
99-
natures 'com.android.ide.eclipse.adt.AndroidNature'
100-
buildCommands.clear();
101-
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
102-
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
103-
buildCommand "org.eclipse.jdt.core.javabuilder"
104-
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
105-
}
106-
}
107-
108-
// sets up the Android Idea project, using the old Ant based build.
109-
idea {
110-
module {
111-
sourceDirs += file("src");
112-
scopes = [ COMPILE: [plus:[project.configurations.compile]]]
113-
114-
iml {
115-
withXml {
116-
def node = it.asNode()
117-
def builder = NodeBuilder.newInstance();
118-
builder.current = node;
119-
builder.component(name: "FacetManager") {
120-
facet(type: "android", name: "Android") {
121-
configuration {
122-
option(name: "UPDATE_PROPERTY_FILES", value:"true")
123-
}
124-
}
125-
}
126-
}
127-
}
128-
}
129-
}

platforms/libgdx/OGLTesting/android/project.properties

-14
This file was deleted.

0 commit comments

Comments
 (0)