Fixed SDL 1.2 compilation, moved chmod/setenv/chdir helpers to separate lib

This commit is contained in:
pelya
2013-10-17 21:16:53 +03:00
parent a649500382
commit 82031cafa0
12 changed files with 48 additions and 56 deletions

View File

@@ -1202,7 +1202,7 @@ else
MultiABI="$MultiABI" # Eh okay
fi
LibrariesToLoad="\\\"sdl-$LibSdlVersion\\\""
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"sdl-$LibSdlVersion\\\""
StaticLibraries=`grep 'APP_AVAILABLE_STATIC_LIBS' project/jni/SettingsTemplate.mk | sed 's/.*=\(.*\)/\1/'`
for lib in $CompiledLibraries; do
process=true
@@ -1359,7 +1359,7 @@ $SEDI "s/public static String AppMainLibraries.*/public static String AppMainLib
echo Patching project/jni/Settings.mk
echo '# DO NOT EDIT THIS FILE - it is automatically generated, edit file SettingsTemplate.mk' > project/jni/Settings.mk
cat project/jni/SettingsTemplate.mk | \
sed "s/APP_MODULES := .*/APP_MODULES := application sdl-$LibSdlVersion sdl_main stlport jpeg png ogg flac vorbis freetype $CompiledLibraries/" | \
sed "s/APP_MODULES := .*/APP_MODULES := application sdl-$LibSdlVersion sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype $CompiledLibraries/" | \
sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" | \
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
@@ -1397,7 +1397,7 @@ rm -rf project/$OUT/local/*/objs*/sdl-*/src/video/SDL_video.o
rm -rf project/$OUT/local/*/objs*/sdl-*/SDL_renderer_gles.o
rm -rf project/$OUT/local/*/objs*/sdl_*
# Do not rebuild several huge libraries that do not depend on SDL version
for LIB in freetype intl jpeg png lua mad stlport tremor xerces xml2 curl lua mikmod \
for LIB in freetype intl jpeg png lua mad tremor xerces xml2 curl lua mikmod \
boost boost_signals boost_thread boost_filesystem boost_date_time boost_system boost_regex boost_iostreams boost_program_options \
ffmpeg swscale avcodec avdevice avresample avutil avfilter swresample avformat; do
for ARCH in armeabi armeabi-v7a; do

View File

@@ -1057,7 +1057,7 @@ public class MainActivity extends SDLActivity
out.flush();
out.close();
//Settings.nativeChmod(path, 0755); -> TODO: DOes not work yet.
Settings.nativeChmod(path, 0755);
//String chmod[] = { "/system/bin/chmod", "0755", path };
@@ -1074,7 +1074,7 @@ public class MainActivity extends SDLActivity
public static void LoadApplicationLibrary(final Context context)
{
//Settings.nativeChdir(Globals.DataDir);
Settings.nativeChdir(Globals.DataDir);
for(String l : Globals.AppMainLibraries)
{
try

View File

@@ -1,6 +1,6 @@
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
APP_MODULES := application sdl-1.2 sdl_main stlport jpeg png ogg flac vorbis freetype tremor ogg
APP_MODULES := application sdl-1.2 sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg
# To filter out static libs from all libs in makefile
APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu

View File

@@ -432,34 +432,8 @@ int SDLCALL SDL_ANDROID_RequestNewAdvertisement(void)
return 1;
}
/*
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
// Dummy callback for SDL2 to satisfy linker
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
void SDL_Android_Init(JNIEnv* env, jclass cls)
{
jboolean iscopy;
const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy);
const char *value = (*env)->GetStringUTFChars(env, j_value, &iscopy);
setenv(name, value, 1);
(*env)->ReleaseStringUTFChars(env, j_name, name);
(*env)->ReleaseStringUTFChars(env, j_value, value);
}
JNIEXPORT jint JNICALL
JAVA_EXPORT_NAME(Settings_nativeChmod) ( JNIEnv* env, jobject thiz, jstring j_name, jint mode )
{
jboolean iscopy;
const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy);
int ret = chmod(name, mode);
(*env)->ReleaseStringUTFChars(env, j_name, name);
return (ret == 0);
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeChdir) ( JNIEnv* env, jobject thiz, jstring j_dir )
{
jboolean iscopy;
const char *dirname = (*env)->GetStringUTFChars(env, j_dir, &iscopy);
chdir(dirname);
(*env)->ReleaseStringUTFChars(env, j_dir, dirname);
}*/

View File

@@ -13,7 +13,7 @@ LOCAL_CFLAGS := -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) -DSDL_CURDIR_PA
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := sdl_main.c SDL_android_main.cpp repoNatives.c
LOCAL_SRC_FILES := sdl_main.c SDL_android_main.cpp
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) application
LOCAL_LDLIBS := -llog

View File

@@ -0,0 +1,21 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sdl_native_helpers
ifndef SDL_JAVA_PACKAGE_PATH
$(error Please define SDL_JAVA_PACKAGE_PATH to the path of your Java package with dots replaced with underscores, for example "com_example_SanAngeles")
endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include
LOCAL_CFLAGS := -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) -DSDL_CURDIR_PATH=\"$(SDL_CURDIR_PATH)\"
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := repoNatives.c
LOCAL_SHARED_LIBRARIES :=
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

View File

@@ -0,0 +1,13 @@
/* JNI-C++ wrapper stuff */
#ifndef _JNI_WRAPPER_STUFF_H_
#define _JNI_WRAPPER_STUFF_H_
#ifndef SDL_JAVA_PACKAGE_PATH
#error You have to define SDL_JAVA_PACKAGE_PATH to your package path with dots replaced with underscores, for example "com_example_SanAngeles"
#endif
#define JAVA_EXPORT_NAME2(name,package) Java_##package##_##name
#define JAVA_EXPORT_NAME1(name,package) JAVA_EXPORT_NAME2(name,package)
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)
#endif

View File

@@ -1,27 +1,11 @@
#include <jni.h>
#include <android/log.h>
//#include <GLES/gl.h>
//#include <GLES/glext.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <math.h>
#include <string.h> // for memset()
/*#include "SDL_config.h"
#include "SDL_version.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_mutex.h"
#include "SDL_thread.h"
#include "SDL_android.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "../SDL_sysvideo.h"
#include "SDL_androidvideo.h"*/
#include "jniwrapperstuff.h"