aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2016-06-14 16:08:21 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-14 16:08:21 +0000
commit316ef4392455de82413284e9fc40dd2f6540c8a9 (patch)
tree2f094fe2f96ce598eea13c19b331f981592369b0
parente8e6ae2ba8dafa9c9c85fc729d60468683d8ce0e (diff)
parent023b1e2bfd4f605146499a1bdc4de3ac99934a46 (diff)
downloadlibgdx-316ef4392455de82413284e9fc40dd2f6540c8a9.tar.gz
Make libgdx buildable on Android
am: 023b1e2bfd Change-Id: Ib881b599d999a3e62e1f9eecac3d6b158ced3a86
-rw-r--r--Android.mk41
-rw-r--r--gdx/jni/Android.mk36
-rw-r--r--gdx/jni/android/AndroidGL20.cpp4
-rw-r--r--gdx/src/com/badlogic/gdx/utils/GdxBuild.java70
4 files changed, 61 insertions, 90 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 000000000..1219cab06
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,41 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+# --- gdx-core ---
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := gdx-core
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under, gdx/src/)
+LOCAL_JAVA_RESOURCE_DIRS := gdx/src
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# --- gdx-backend-android ---
+
+include $(CLEAR_VARS)
+
+LOCAL_STATIC_ANDROID_LIBRARIES := \
+ android-support-v4
+LOCAL_MODULE := gdx-backend-android
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under, backends/gdx-backend-android/src)
+LOCAL_STATIC_JAVA_LIBRARIES := gdx-core
+LOCAL_JAVA_RESOURCE_DIRS := gdx/src
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(LOCAL_PATH)/gdx/jni/Android.mk \ No newline at end of file
diff --git a/gdx/jni/Android.mk b/gdx/jni/Android.mk
index 85881ad9e..5b1eb61f4 100644
--- a/gdx/jni/Android.mk
+++ b/gdx/jni/Android.mk
@@ -1,23 +1,23 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-
-LOCAL_MODULE := gdx
-LOCAL_C_INCLUDES :=
-
-LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__
-LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__
+
+LOCAL_MODULE := libgdx
+LOCAL_C_INCLUDES :=
+
+LOCAL_CFLAGS := -O2 -Wall
LOCAL_LDLIBS := -lm -lGLESv2 -llog
LOCAL_ARM_MODE := arm
-
-LOCAL_SRC_FILES := android/AndroidGL20.cpp\
- com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.cpp\
- com.badlogic.gdx.graphics.glutils.ETC1.cpp\
- com.badlogic.gdx.math.Matrix4.cpp\
- com.badlogic.gdx.utils.BufferUtils.cpp\
- etc1/etc1_utils.cpp\
- gdx2d/gdx2d.c\
- gdx2d/jpgd.cpp\
- gdx2d/jpgd_c.cpp\
- memcpy_wrap.c
-
+LOCAL_SDK_VERSION := 23
+
+LOCAL_SRC_FILES := android/AndroidGL20.cpp\
+ com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.cpp\
+ com.badlogic.gdx.graphics.glutils.ETC1.cpp\
+ com.badlogic.gdx.math.Matrix4.cpp\
+ com.badlogic.gdx.utils.BufferUtils.cpp\
+ etc1/etc1_utils.cpp\
+ gdx2d/gdx2d.c\
+ gdx2d/jpgd.cpp\
+ gdx2d/jpgd_c.cpp\
+ memcpy_wrap.c
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/gdx/jni/android/AndroidGL20.cpp b/gdx/jni/android/AndroidGL20.cpp
index 6817e8982..d03645827 100644
--- a/gdx/jni/android/AndroidGL20.cpp
+++ b/gdx/jni/android/AndroidGL20.cpp
@@ -695,7 +695,7 @@ JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_android_AndroidGL20_glDraw
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_android_AndroidGL20_glDrawElements__IIII
(JNIEnv *, jobject, jint mode, jint count, jint type, jint indices)
{
- glDrawElements( mode, count, type, (const void*)indices );
+ glDrawElements( mode, count, type, (const void*)(uintptr_t)indices );
}
/*
@@ -2058,7 +2058,7 @@ JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_android_AndroidGL20_glVert
JNIEXPORT void JNICALL Java_com_badlogic_gdx_backends_android_AndroidGL20_glVertexAttribPointer__IIIZII
(JNIEnv *, jobject, jint indx, jint size, jint type, jboolean normalized, jint stride, jint ptr)
{
- glVertexAttribPointer( indx, size, type, normalized, stride, (const void*)ptr );
+ glVertexAttribPointer( indx, size, type, normalized, stride, (const void*)(uintptr_t)ptr );
}
/*
diff --git a/gdx/src/com/badlogic/gdx/utils/GdxBuild.java b/gdx/src/com/badlogic/gdx/utils/GdxBuild.java
deleted file mode 100644
index 06db3cb52..000000000
--- a/gdx/src/com/badlogic/gdx/utils/GdxBuild.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright 2011 See AUTHORS file.
- *
- * 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.
- ******************************************************************************/
-
-package com.badlogic.gdx.utils;
-
-import com.badlogic.gdx.jnigen.AntScriptGenerator;
-import com.badlogic.gdx.jnigen.BuildConfig;
-import com.badlogic.gdx.jnigen.BuildExecutor;
-import com.badlogic.gdx.jnigen.BuildTarget;
-import com.badlogic.gdx.jnigen.BuildTarget.TargetOs;
-import com.badlogic.gdx.jnigen.NativeCodeGenerator;
-
-/** Builds the JNI wrappers via gdx-jnigen.
- * @author mzechner */
-public class GdxBuild {
- public static void main (String[] args) throws Exception {
- String JNI_DIR = "jni";
- String LIBS_DIR = "libs";
-
- // generate C/C++ code
- new NativeCodeGenerator().generate("src", "bin", JNI_DIR, new String[] {"**/*"}, null);
-
- String[] excludeCpp = {"android/**", "iosgl/**"};
-
- // generate build scripts, for win32 only
- // custom target for testing purposes
- BuildTarget win32home = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
- win32home.compilerPrefix = "";
- win32home.buildFileName = "build-windows32home.xml";
- win32home.excludeFromMasterBuildFile = true;
- win32home.cppExcludes = excludeCpp;
- BuildTarget win32 = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
- win32.cppExcludes = excludeCpp;
- BuildTarget win64 = BuildTarget.newDefaultTarget(TargetOs.Windows, true);
- win64.cppExcludes = excludeCpp;
- BuildTarget lin32 = BuildTarget.newDefaultTarget(TargetOs.Linux, false);
- lin32.cppExcludes = excludeCpp;
- BuildTarget lin64 = BuildTarget.newDefaultTarget(TargetOs.Linux, true);
- lin64.cppExcludes = excludeCpp;
- BuildTarget android = BuildTarget.newDefaultTarget(TargetOs.Android, false);
- android.linkerFlags += " -lGLESv2 -llog";
- android.cppExcludes = new String[] {"iosgl/**"};
- BuildTarget mac = BuildTarget.newDefaultTarget(TargetOs.MacOsX, false);
- mac.cppExcludes = excludeCpp;
- BuildTarget mac64 = BuildTarget.newDefaultTarget(TargetOs.MacOsX, true);
- mac64.cppExcludes = excludeCpp;
- BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);
- ios.cppExcludes = new String[] {"android/**"};
- ios.headerDirs = new String[] {"iosgl"};
- new AntScriptGenerator().generate(new BuildConfig("gdx", "../target/native", LIBS_DIR, JNI_DIR), mac, mac64, win32home, win32,
- win64, lin32, lin64, android, ios);
-
- // build natives
- // BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");
- // BuildExecutor.executeAnt("jni/build.xml", "pack-natives -v");
- }
-}