Skip to content

Commit dc45700

Browse files
committed
bootstrap: readd missing files from legacy bootstrap. Must have been wrong file manipulation during the moves.
1 parent 2c24341 commit dc45700

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+27860
-2
lines changed

bootstrap/legacy/default.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

bootstrap/legacy/jni/Android.mk

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# The namespace in Java file, with dots replaced with underscores
3+
SDL_JAVA_PACKAGE_PATH := org_renpy_android
4+
5+
# Path to shared libraries - Android 1.6 cannot load them properly, thus we have to specify absolute path here
6+
# SDL_SHARED_LIBRARIES_PATH := /data/data/de.schwardtnet.alienblaster/lib
7+
8+
# Path to files with application data - they should be downloaded from Internet on first app run inside
9+
# Java sources, or unpacked from resources (TODO)
10+
# Typically /sdcard/alienblaster
11+
# Or /data/data/de.schwardtnet.alienblaster/files if you're planning to unpack data in application private folder
12+
# Your application will just set current directory there
13+
SDL_CURDIR_PATH := org.renpy.android
14+
15+
# Android Dev Phone G1 has trackball instead of cursor keys, and
16+
# sends trackball movement events as rapid KeyDown/KeyUp events,
17+
# this will make Up/Down/Left/Right key up events with X frames delay,
18+
# so if application expects you to press and hold button it will process the event correctly.
19+
# TODO: create a libsdl config file for that option and for key mapping/on-screen keyboard
20+
SDL_TRACKBALL_KEYUP_DELAY := 1
21+
22+
# If the application designed for higher screen resolution enable this to get the screen
23+
# resized in HW-accelerated way, however it eats a tiny bit of CPU
24+
SDL_VIDEO_RENDER_RESIZE := 0
25+
26+
COMPILED_LIBRARIES := sdl_ttf sdl_image sdl_mixer
27+
28+
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2 -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH)
29+
30+
APPLICATION_ADDITIONAL_LDFLAGS := -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
31+
32+
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=SPACE -DSDL_ANDROID_KEYCODE_1=RETURN -DSDL_ANDROID_KEYCODE_2=LCTRL -DSDL_ANDROID_KEYCODE_3=LALT -DSDL_ANDROID_KEYCODE_4=RETURN
33+
34+
# If SDL_Mixer should link to libMAD
35+
SDL_MIXER_USE_LIBMAD :=
36+
ifneq ($(strip $(filter mad, $(COMPILED_LIBRARIES))),)
37+
SDL_MIXER_USE_LIBMAD := 1
38+
endif
39+
40+
include $(call all-subdir-makefiles)

bootstrap/legacy/jni/Application.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
APP_PROJECT_PATH := $(call my-dir)/..
2+
3+
# Available libraries: mad sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx intl
4+
# sdl_mixer depends on tremor and optionally mad
5+
# sdl_image depends on png and jpeg
6+
# sdl_ttf depends on freetype
7+
8+
APP_MODULES := application sdl sdl_main tremor png jpeg freetype sdl_ttf sdl_image sqlite3
9+
10+
APP_ABI := $(ARCH)
11+
APP_STL := gnustl_static
12+
APP_CFLAGS += $(OFLAG)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
5+
LOCAL_MODULE := application
6+
7+
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell find $(LOCAL_PATH)/src/ -type d))
8+
9+
LOCAL_CFLAGS := $(foreach D, $(APP_SUBDIRS), -I$(LOCAL_PATH)/$(D)) \
10+
-I$(LOCAL_PATH)/../sdl/include \
11+
-I$(LOCAL_PATH)/../sdl_mixer \
12+
-I$(LOCAL_PATH)/../sdl_image \
13+
-I$(LOCAL_PATH)/../sdl_ttf \
14+
-I$(LOCAL_PATH)/../sdl_net \
15+
-I$(LOCAL_PATH)/../sdl_blitpool \
16+
-I$(LOCAL_PATH)/../sdl_gfx \
17+
-I$(LOCAL_PATH)/../png \
18+
-I$(LOCAL_PATH)/../jpeg \
19+
-I$(LOCAL_PATH)/../intl \
20+
-I$(LOCAL_PATH)/.. \
21+
-I$(LOCAL_PATH)/../../../build/python-install/include/python2.7
22+
23+
24+
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)
25+
26+
#Change C++ file extension as appropriate
27+
LOCAL_CPP_EXTENSION := .cpp
28+
29+
LOCAL_SRC_FILES := $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
30+
# Uncomment to also add C sources
31+
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
32+
33+
LOCAL_SHARED_LIBRARIES := sdl $(COMPILED_LIBRARIES)
34+
35+
LOCAL_STATIC_LIBRARIES := jpeg png
36+
37+
LOCAL_LDLIBS := -lpython2.7 -lGLESv1_CM -ldl -llog -lz
38+
39+
LOCAL_LDFLAGS += -L$(LOCAL_PATH)/../../../build/python-install/lib $(APPLICATION_ADDITIONAL_LDFLAGS)
40+
41+
LIBS_WITH_LONG_SYMBOLS := $(strip $(shell \
42+
for f in $(LOCAL_PATH)/../../libs/$ARCH/*.so ; do \
43+
if echo $$f | grep "libapplication[.]so" > /dev/null ; then \
44+
continue ; \
45+
fi ; \
46+
if [ -e "$$f" ] ; then \
47+
if nm -g $$f | cut -c 12- | egrep '.{128}' > /dev/null ; then \
48+
echo $$f | grep -o 'lib[^/]*[.]so' ; \
49+
fi ; \
50+
fi ; \
51+
done \
52+
) )
53+
54+
ifneq "$(LIBS_WITH_LONG_SYMBOLS)" ""
55+
$(foreach F, $(LIBS_WITH_LONG_SYMBOLS), \
56+
$(info Library $(F): abusing symbol names are: \
57+
$(shell nm -g $(LOCAL_PATH)/../../libs/$ARCH/$(F) | cut -c 12- | egrep '.{128}' ) ) \
58+
$(info Library $(F) contains symbol names longer than 128 bytes, \
59+
YOUR CODE WILL DEADLOCK WITHOUT ANY WARNING when you'll access such function - \
60+
please make this library static to avoid problems. ) )
61+
$(error Detected libraries with too long symbol names. Remove all files under project/libs/$ARCH, make these libs static, and recompile)
62+
endif
63+
64+
include $(BUILD_SHARED_LIBRARY)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
3+
# Set here your own NDK path if needed
4+
# export PATH=$PATH:~/src/endless_space/android-ndk-r4
5+
6+
IFS='
7+
'
8+
9+
NDK=`which ndk-build`
10+
NDK=`dirname $NDK`
11+
GCCVER=4.4.0
12+
PLATFORMVER=android-8
13+
LOCAL_PATH=`dirname $0`
14+
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
15+
16+
# Hacks for broken configure scripts
17+
ln -sf libsdl_mixer.so $LOCAL_PATH/../../bin/ndk/local/armeabi/libSDL_mixer.so
18+
ln -sf libsdl_mixer.so $LOCAL_PATH/../../bin/ndk/local/armeabi/libSDL_Mixer.so
19+
ln -sf libsdl_net.so $LOCAL_PATH/../../bin/ndk/local/armeabi/libSDL_net.so
20+
21+
CFLAGS="-I$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/include \
22+
-fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums \
23+
-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID \
24+
-Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os \
25+
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
26+
-Wa,--noexecstack -O2 -DNDEBUG -g \
27+
`grep '[-]I[$][(]LOCAL_PATH[)]/[.][.]/' $LOCAL_PATH/Android.mk | tr '\n' ' ' | sed 's/[\\]//g' | sed \"s@[\$][(]LOCAL_PATH[)]/@$LOCAL_PATH/@g\" | sed 's/[ ][ ]*/ /g'`"
28+
29+
LDFLAGS="-nostdlib -Wl,-soname,libapplication.so -Wl,-shared,-Bsymbolic \
30+
-Wl,--whole-archive -Wl,--no-whole-archive \
31+
$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/lib/gcc/arm-eabi/4.4.0/libgcc.a \
32+
`echo $LOCAL_PATH/../../bin/ndk/local/armeabi/*.so | sed "s@$LOCAL_PATH/../../bin/ndk/local/armeabi/libsdl_main.so@@" | sed "s@$LOCAL_PATH/../../bin/ndk/local/armeabi/libapplication.so@@"` \
33+
$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib/libc.so \
34+
$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib/libstdc++.so \
35+
$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib/libm.so \
36+
-Wl,--no-undefined -Wl,-z,noexecstack \
37+
-L$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib \
38+
-lGLESv1_CM -ldl -llog -lz \
39+
-Wl,-rpath-link=$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib \
40+
-L$LOCAL_PATH/../../bin/ndk/local/armeabi"
41+
42+
env PATH=$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin:$LOCAL_PATH:$PATH \
43+
CFLAGS="$CFLAGS" \
44+
CXXFLAGS="$CFLAGS" \
45+
LDFLAGS="$LDFLAGS" \
46+
CC="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-gcc" \
47+
CXX="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-g++" \
48+
RANLIB="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-ranlib" \
49+
LD="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-gcc" \
50+
AR="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-ar" \
51+
CPP="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-cpp $CFLAGS" \
52+
NM="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-nm" \
53+
AS="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-as" \
54+
STRIP="$NDK/build/prebuilt/linux-x86/arm-eabi-$GCCVER/bin/arm-eabi-strip" \
55+
./configure --host=arm-eabi "$@"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
/* JNI-C++ wrapper stuff */
3+
#ifndef _JNI_WRAPPER_STUFF_H_
4+
#define _JNI_WRAPPER_STUFF_H_
5+
6+
#ifndef SDL_JAVA_PACKAGE_PATH
7+
#error You have to define SDL_JAVA_PACKAGE_PATH to your package path with dots replaced with underscores, for example "com_example_SanAngeles"
8+
#endif
9+
#define JAVA_EXPORT_NAME2(name,package) Java_##package##_##name
10+
#define JAVA_EXPORT_NAME1(name,package) JAVA_EXPORT_NAME2(name,package)
11+
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)
12+
13+
#endif
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
#define PY_SSIZE_T_CLEAN
2+
#include "Python.h"
3+
#ifndef Py_PYTHON_H
4+
#error Python headers needed to compile C extensions, please install development version of Python.
5+
#else
6+
7+
#include <stdio.h>
8+
#include <stdlib.h>
9+
#include <unistd.h>
10+
#include <jni.h>
11+
#include "SDL.h"
12+
#include "android/log.h"
13+
#include "jniwrapperstuff.h"
14+
15+
#define LOG(x) __android_log_write(ANDROID_LOG_INFO, "python", (x))
16+
17+
static PyObject *androidembed_log(PyObject *self, PyObject *args) {
18+
char *logstr = NULL;
19+
if (!PyArg_ParseTuple(args, "s", &logstr)) {
20+
return NULL;
21+
}
22+
LOG(logstr);
23+
Py_RETURN_NONE;
24+
}
25+
26+
static PyMethodDef AndroidEmbedMethods[] = {
27+
{"log", androidembed_log, METH_VARARGS,
28+
"Log on android platform"},
29+
{NULL, NULL, 0, NULL}
30+
};
31+
32+
PyMODINIT_FUNC initandroidembed(void) {
33+
(void) Py_InitModule("androidembed", AndroidEmbedMethods);
34+
}
35+
36+
int file_exists(const char * filename)
37+
{
38+
FILE *file;
39+
if (file = fopen(filename, "r")) {
40+
fclose(file);
41+
return 1;
42+
}
43+
return 0;
44+
}
45+
46+
int main(int argc, char **argv) {
47+
48+
char *env_argument = NULL;
49+
int ret = 0;
50+
FILE *fd;
51+
52+
LOG("Initialize Python for Android");
53+
env_argument = getenv("ANDROID_ARGUMENT");
54+
setenv("ANDROID_APP_PATH", env_argument, 1);
55+
//setenv("PYTHONVERBOSE", "2", 1);
56+
Py_SetProgramName(argv[0]);
57+
Py_Initialize();
58+
PySys_SetArgv(argc, argv);
59+
60+
/* ensure threads will work.
61+
*/
62+
PyEval_InitThreads();
63+
64+
/* our logging module for android
65+
*/
66+
initandroidembed();
67+
68+
/* inject our bootstrap code to redirect python stdin/stdout
69+
* replace sys.path with our path
70+
*/
71+
PyRun_SimpleString(
72+
"import sys, posix\n" \
73+
"private = posix.environ['ANDROID_PRIVATE']\n" \
74+
"argument = posix.environ['ANDROID_ARGUMENT']\n" \
75+
"sys.path[:] = [ \n" \
76+
" private + '/lib/python27.zip', \n" \
77+
" private + '/lib/python2.7/', \n" \
78+
" private + '/lib/python2.7/lib-dynload/', \n" \
79+
" private + '/lib/python2.7/site-packages/', \n" \
80+
" argument ]\n" \
81+
"import androidembed\n" \
82+
"class LogFile(object):\n" \
83+
" def __init__(self):\n" \
84+
" self.buffer = ''\n" \
85+
" def write(self, s):\n" \
86+
" s = self.buffer + s\n" \
87+
" lines = s.split(\"\\n\")\n" \
88+
" for l in lines[:-1]:\n" \
89+
" androidembed.log(l)\n" \
90+
" self.buffer = lines[-1]\n" \
91+
" def flush(self):\n" \
92+
" return\n" \
93+
"sys.stdout = sys.stderr = LogFile()\n" \
94+
"import site; print site.getsitepackages()\n"\
95+
"print 'Android path', sys.path\n" \
96+
"print 'Android kivy bootstrap done. __name__ is', __name__");
97+
98+
/* run it !
99+
*/
100+
LOG("Run user program, change dir and execute main.py");
101+
chdir(env_argument);
102+
103+
/* search the initial main.py
104+
*/
105+
char *main_py = "main.pyo";
106+
if ( file_exists(main_py) == 0 ) {
107+
if ( file_exists("main.py") )
108+
main_py = "main.py";
109+
else
110+
main_py = NULL;
111+
}
112+
113+
if ( main_py == NULL ) {
114+
LOG("No main.pyo / main.py found.");
115+
return -1;
116+
}
117+
118+
fd = fopen(main_py, "r");
119+
if ( fd == NULL ) {
120+
LOG("Open the main.py(o) failed");
121+
return -1;
122+
}
123+
124+
/* run python !
125+
*/
126+
ret = PyRun_SimpleFile(fd, main_py);
127+
128+
if (PyErr_Occurred() != NULL) {
129+
ret = 1;
130+
PyErr_Print(); /* This exits with the right code if SystemExit. */
131+
if (Py_FlushLine())
132+
PyErr_Clear();
133+
}
134+
135+
/* close everything
136+
*/
137+
Py_Finalize();
138+
fclose(fd);
139+
140+
LOG("Python for android ended.");
141+
return ret;
142+
}
143+
144+
JNIEXPORT void JNICALL JAVA_EXPORT_NAME(PythonService_nativeStart) ( JNIEnv* env, jobject thiz,
145+
jstring j_android_private,
146+
jstring j_android_argument,
147+
jstring j_python_home,
148+
jstring j_python_path,
149+
jstring j_arg )
150+
{
151+
jboolean iscopy;
152+
const char *android_private = (*env)->GetStringUTFChars(env, j_android_private, &iscopy);
153+
const char *android_argument = (*env)->GetStringUTFChars(env, j_android_argument, &iscopy);
154+
const char *python_home = (*env)->GetStringUTFChars(env, j_python_home, &iscopy);
155+
const char *python_path = (*env)->GetStringUTFChars(env, j_python_path, &iscopy);
156+
const char *arg = (*env)->GetStringUTFChars(env, j_arg, &iscopy);
157+
158+
setenv("ANDROID_PRIVATE", android_private, 1);
159+
setenv("ANDROID_ARGUMENT", android_argument, 1);
160+
setenv("PYTHONOPTIMIZE", "2", 1);
161+
setenv("PYTHONHOME", python_home, 1);
162+
setenv("PYTHONPATH", python_path, 1);
163+
setenv("PYTHON_SERVICE_ARGUMENT", arg, 1);
164+
165+
char *argv[] = { "service" };
166+
/* ANDROID_ARGUMENT points to service subdir,
167+
* so main() will run main.py from this dir
168+
*/
169+
main(1, argv);
170+
}
171+
172+
#endif

0 commit comments

Comments
 (0)