浏览代码

build: switch the Android native build rules to autoconf; still a bit rough

but we can now create shared objects for each project; only the testsuite
is not building properly because of issues with STLport, and EglApp is
deactivated because AndroidApp should have precedence.
legacy
Sam Hocevar sam 12 年前
父节点
当前提交
44180ce402
共有 8 个文件被更改,包括 75 次插入30 次删除
  1. +10
    -0
      build/build-android
  2. +11
    -15
      build/lol-build
  3. +13
    -3
      configure.ac
  4. +3
    -1
      src/core.h
  5. +5
    -5
      src/eglapp.cpp
  6. +24
    -4
      src/platform/android/androidapp.cpp
  7. +2
    -0
      src/platform/android/androidapp.h
  8. +7
    -2
      test/Makefile.am

+ 10
- 0
build/build-android 查看文件

@@ -0,0 +1,10 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build bootstrap android-arm
./build/lol-build configure android-arm
./build/lol-build build android-arm


+ 11
- 15
build/lol-build 查看文件

@@ -79,9 +79,6 @@ bootstrap()
ios-arm) ios-arm)
# No bootstrapping needed # No bootstrapping needed
;; ;;
android-arm)
# No bootstrapping needed
;;
*) *)
PATH="$PATH" M4PATH="$M4PATH" ./bootstrap PATH="$PATH" M4PATH="$M4PATH" ./bootstrap
;; ;;
@@ -156,8 +153,17 @@ configure()
# No configuration needed # No configuration needed
;; ;;
android-arm) android-arm)
cd monsterz/android ./configure --host=arm-linux-androideabi ac_cv_exeext=.so \
android update project --path . CPPFLAGS="-Wno-psabi -I$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport -I$ANDROID_NDK_ROOT/sources/cxx-stl/gabi++/include -fpic -fno-exceptions -fno-rtti -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64" \
CFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb" \
CXXFLAGS="-march=armv5te -mtune=xscale -msoft-float -mthumb" \
LOL_LIBS="-L$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi -lstlport_shared -lm -fpic -XCClinker -shared"
# FIXME: is this needed?
# android update project --path .
# ndk-build
# ant compile
# ndk-build distclean
# ant clean
;; ;;
raspi-arm) raspi-arm)
./configure --host=arm-bcm2708hardfp-linux-gnueabi CPPFLAGS="-I$RASPI_SDK_ROOT/firmware/opt/vc/include -I$RASPI_SDK_ROOT/firmware/opt/vc/include/interface/vcos/pthreads" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib" ./configure --host=arm-bcm2708hardfp-linux-gnueabi CPPFLAGS="-I$RASPI_SDK_ROOT/firmware/opt/vc/include -I$RASPI_SDK_ROOT/firmware/opt/vc/include/interface/vcos/pthreads" LDFLAGS="-L$RASPI_SDK_ROOT/firmware/opt/vc/lib"
@@ -209,11 +215,6 @@ build()
cd monsterz/ios cd monsterz/ios
xcodebuild -configuration Release -sdk iphonesimulator4.3 xcodebuild -configuration Release -sdk iphonesimulator4.3
;; ;;
android-arm)
cd monsterz/android
ndk-build
ant compile
;;
*) *)
make -j$LOL_PARALLEL make -j$LOL_PARALLEL
;; ;;
@@ -261,11 +262,6 @@ clean()
cd monsterz/ios cd monsterz/ios
xcodebuild -configuration Release -sdk iphonesimulator4.3 clean xcodebuild -configuration Release -sdk iphonesimulator4.3 clean
;; ;;
android-arm)
cd monsterz/android
ndk-build distclean
ant clean
;;
*) *)
make distclean make distclean
;; ;;


+ 13
- 3
configure.ac 查看文件

@@ -196,8 +196,10 @@ fi


if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
AC_CHECK_HEADER(GLES2/gl2.h, AC_CHECK_HEADER(GLES2/gl2.h,
[AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) [ac_cv_my_have_gl="yes"
ac_cv_my_have_gl="yes"]) AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
AC_CHECK_LIB(GLESv2, glEnable,
[GL_LIBS="${GL_LIBS} -lGLESv2"])])
fi fi


if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
@@ -208,7 +210,7 @@ if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
fi fi


if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
AC_CHECK_LIB(GL, glLoadIdentity, AC_CHECK_LIB(GL, glEnable,
[ac_cv_my_have_gl="yes" [ac_cv_my_have_gl="yes"
AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
GL_LIBS="-lGL"]) GL_LIBS="-lGL"])
@@ -350,6 +352,14 @@ AC_LANG_POP(C++)
AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no") AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")




dnl Use Android? FIXME: super hacks!
ac_cv_my_have_android="no"
AC_CHECK_LIB(log, __android_log_vprint,
[ac_cv_my_have_android="yes"
LOL_LIBS="${LOL_LIBS} -llog -module"])
AM_CONDITIONAL(USE_ANDROID, test "${ac_cv_my_have_android}" != "no")


dnl Use EGL? dnl Use EGL?
ac_cv_my_have_egl="no" ac_cv_my_have_egl="no"
PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:]) PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])


+ 3
- 1
src/core.h 查看文件

@@ -61,9 +61,11 @@ static inline int isnan(float f)
} }
#endif #endif


/* If using NaCl, override main() with our version */ /* If using NaCl or Android, override main() with our version */
#if defined __native_client__ #if defined __native_client__
# define main lol_nacl_main # define main lol_nacl_main
#elif defined __ANDROID__
# define main lol_android_main
#endif #endif


/* If using SDL on Windows or OS X, let it override main() */ /* If using SDL on Windows or OS X, let it override main() */


+ 5
- 5
src/eglapp.cpp 查看文件

@@ -12,7 +12,7 @@
# include "config.h" # include "config.h"
#endif #endif


#if defined USE_EGL #if defined USE_EGL && !defined __ANDROID__
# if defined HAVE_BCM_HOST_H # if defined HAVE_BCM_HOST_H
# include <bcm_host.h> # include <bcm_host.h>
# else # else
@@ -40,7 +40,7 @@ class EglAppData
friend class EglApp; friend class EglApp;


private: private:
#if defined USE_EGL #if defined USE_EGL && !defined __ANDROID__
EGLDisplay egl_dpy; EGLDisplay egl_dpy;
EGLContext egl_ctx; EGLContext egl_ctx;
EGLSurface egl_surf; EGLSurface egl_surf;
@@ -61,7 +61,7 @@ private:
EglApp::EglApp(char const *title, ivec2 res, float fps) : EglApp::EglApp(char const *title, ivec2 res, float fps) :
data(new EglAppData()) data(new EglAppData())
{ {
#if defined USE_EGL #if defined USE_EGL && !defined __ANDROID__
# if defined HAVE_BCM_HOST_H # if defined HAVE_BCM_HOST_H
bcm_host_init(); bcm_host_init();


@@ -230,7 +230,7 @@ void EglApp::Run()
{ {
/* Tick the renderer, show the frame and clamp to desired framerate. */ /* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw(); Ticker::TickDraw();
#if defined USE_EGL #if defined USE_EGL && !defined __ANDROID__
eglSwapBuffers(data->egl_dpy, data->egl_surf); eglSwapBuffers(data->egl_dpy, data->egl_surf);
#endif #endif
} }
@@ -238,7 +238,7 @@ void EglApp::Run()


EglApp::~EglApp() EglApp::~EglApp()
{ {
#if defined USE_EGL #if defined USE_EGL && !defined __ANDROID__
eglDestroyContext(data->egl_dpy, data->egl_ctx); eglDestroyContext(data->egl_dpy, data->egl_ctx);
eglDestroySurface(data->egl_dpy, data->egl_surf); eglDestroySurface(data->egl_dpy, data->egl_surf);
eglTerminate(data->egl_dpy); eglTerminate(data->egl_dpy);


+ 24
- 4
src/platform/android/androidapp.cpp 查看文件

@@ -23,13 +23,19 @@


using namespace lol; using namespace lol;


/* Monsterz-specific */ /* One of these wrappers will be overridden by the user's version */
#include "interface.h" void lol_android_main(void) __attribute__((weak));
void lol_android_main(void) {}
void lol_android_main(int argc, char **argv) __attribute__((weak));
void lol_android_main(int argc, char **argv) {}
void lol_android_main(int argc, char **argv, char **envp) __attribute__((weak));
void lol_android_main(int argc, char **argv, char **envp) {}


namespace lol namespace lol
{ {
JavaVM *g_vm; JavaVM *g_vm;
jobject g_activity; jobject g_activity;
Thread *g_main_thread;


AndroidApp::AndroidApp(char const *title, ivec2 res, float fps) : AndroidApp::AndroidApp(char const *title, ivec2 res, float fps) :
data(0) data(0)
@@ -49,6 +55,20 @@ void AndroidApp::Run()
} }
} }


void *AndroidApp::MainRun(void *data)
{
int argc = 1;
char *argv[] = { "", NULL };
char *env[] = { NULL };

/* Call the user's main() function. One of these will work. */
lol_android_main();
lol_android_main(argc, argv);
lol_android_main(argc, argv, env);

return NULL;
}

AndroidApp::~AndroidApp() AndroidApp::~AndroidApp()
{ {
} }
@@ -76,8 +96,7 @@ Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env)
Ticker::Setup(30.0f); Ticker::Setup(30.0f);
Video::Setup(ivec2(320, 200)); Video::Setup(ivec2(320, 200));


new Interface(); g_main_thread = new Thread(lol::AndroidApp::MainRun, NULL);;
new DebugFps(20, 20);
} }


extern "C" void extern "C" void
@@ -92,6 +111,7 @@ extern "C" void
Java_org_zoy_LolEngine_LolRenderer_nativeDone(JNIEnv* env) Java_org_zoy_LolEngine_LolRenderer_nativeDone(JNIEnv* env)
{ {
/* FIXME: clean up */ /* FIXME: clean up */
delete g_main_thread;
} }


extern "C" void extern "C" void


+ 2
- 0
src/platform/android/androidapp.h 查看文件

@@ -32,6 +32,8 @@ public:
void ShowPointer(bool show); void ShowPointer(bool show);
void Run(); void Run();


static void *MainRun(void *data);

private: private:
AndroidAppData *data; AndroidAppData *data;
}; };


+ 7
- 2
test/Makefile.am 查看文件

@@ -17,9 +17,14 @@ CLEANFILES = $(noinst_PROGRAMS:%$(EXEEXT)=%.self) \


EXTRA_DIST = data/gradient.png EXTRA_DIST = data/gradient.png


noinst_PROGRAMS = quad benchsuite testsuite btphystest noinst_PROGRAMS = quad benchsuite $(testsuite) btphystest


TESTS = testsuite TESTS = $(testsuite)

# Conditionally built for now because of STLport issues
if !USE_ANDROID
testsuite = testsuite
endif


testsuite_SOURCES = testsuite.cpp \ testsuite_SOURCES = testsuite.cpp \
unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \ unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \


||||||
x
 
000:0
正在加载...
取消
保存