Skip to content

Commit c24a148

Browse files
author
Jonas Thiem
committed
Bump SDL2 to 2.0.9
1 parent 81a8bf6 commit c24a148

File tree

19 files changed

+4858
-605
lines changed

19 files changed

+4858
-605
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ prune doc/build
77
recursive-include pythonforandroid *.py *.tmpl biglink liblink
88
recursive-include pythonforandroid/recipes *.py *.patch *.c *.pyx Setup *.h
99

10-
recursive-include pythonforandroid/bootstraps *.properties *.xml *.java *.tmpl *.txt *.png *.aidl *.py *.sh *.c *.h *.html
10+
recursive-include pythonforandroid/bootstraps *.properties *.xml *.java *.tmpl *.txt *.png *.aidl *.py *.sh *.c *.h *.html *.patch
1111

1212
prune .git
1313
prune pythonforandroid/bootstraps/pygame/build/libs

doc/source/quickstart.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ the latest usable NDK version is r10e, which can be downloaded here:
114114
release with the legacy version of python is version
115115
`0.6.0 <https://github.com/kivy/python-for-android/archive/0.6.0.zip>`_.
116116

117-
First, install a platform to target (you can also replace ``27`` with
118-
a different platform number, this will be used again later)::
117+
First, install an API platform to target. You can replace ``27`` with
118+
a different platform number, but keep in mind **other API versions
119+
are less well-tested**, and older devices are still supported
120+
(down to the specified *minimum* API/NDK API level):
119121

120122
$SDK_DIR/tools/bin/sdkmanager "platforms;android-27"
121123

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import subprocess
1515
import sys
1616
import tarfile
17+
import tempfile
1718
import time
1819
from zipfile import ZipFile
1920

@@ -275,8 +276,17 @@ def make_package(args):
275276
# construct a python27.zip
276277
make_python_zip()
277278

279+
# Add extra environment variable file into tar-able directory:
280+
env_vars_tarpath = tempfile.mkdtemp(prefix="p4a-extra-env-")
281+
with open(os.path.join(env_vars_tarpath, "p4a_env_vars.txt"), "w") as f:
282+
f.write("P4A_IS_WINDOWED=" + str(args.windowed) + "\n")
283+
if hasattr(args, "orientation"):
284+
f.write("P4A_ORIENTATION=" + str(args.orientation) + "\n")
285+
f.write("P4A_NUMERIC_VERSION=" + str(args.numeric_version) + "\n")
286+
f.write("P4A_MINSDK=" + str(args.min_sdk_version) + "\n")
287+
278288
# Package up the private data (public not supported).
279-
tar_dirs = []
289+
tar_dirs = [env_vars_tarpath]
280290
if args.private:
281291
tar_dirs.append(args.private)
282292
for python_bundle_dir in ('private', 'crystax_python', '_python_bundle'):
@@ -289,6 +299,9 @@ def make_package(args):
289299
join(assets_dir, 'private.mp3'), tar_dirs, args.ignore_path,
290300
optimize_python=args.optimize_python)
291301

302+
# Remove extra env vars tar-able directory:
303+
shutil.rmtree(env_vars_tarpath)
304+
292305
# Prepare some variables for templating process
293306
res_dir = "src/main/res"
294307
if get_bootstrap_name() == "webview":
@@ -498,6 +511,31 @@ def make_package(args):
498511
if exists('build.properties'):
499512
os.remove('build.properties')
500513

514+
# Apply java source patches if any are present:
515+
if exists(join('src', 'patches')):
516+
print("Applying Java source code patches...")
517+
for patch_name in os.listdir(join('src', 'patches')):
518+
patch_path = join('src', 'patches', patch_name)
519+
print("Applying patch: " + str(patch_path))
520+
try:
521+
subprocess.check_output([
522+
# -N: insist this is FORWARd patch, don't reverse apply
523+
# -p1: strip first path component
524+
# -t: batch mode, don't ask questions
525+
"patch", "-N", "-p1", "-t", "-i", patch_path
526+
])
527+
except subprocess.CalledProcessError as e:
528+
if e.returncode == 1:
529+
# Return code 1 means it didn't apply, this will
530+
# usually mean it is already applied.
531+
print("Warning: failed to apply patch (" +
532+
"exit code 1), " +
533+
"assuming it is already applied: " +
534+
str(patch_path)
535+
)
536+
else:
537+
raise e
538+
501539

502540
def parse_args(args=None):
503541
global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON

pythonforandroid/bootstraps/common/build/jni/application/src/start.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,48 @@ int main(int argc, char *argv[]) {
8282
int ret = 0;
8383
FILE *fd;
8484

85-
setenv("P4A_BOOTSTRAP", bootstrap_name, 1); // env var to identify p4a to applications
86-
8785
LOGP("Initializing Python for Android");
86+
87+
// Set a couple of built-in environment vars:
88+
setenv("P4A_BOOTSTRAP", bootstrap_name, 1); // env var to identify p4a to applications
8889
env_argument = getenv("ANDROID_ARGUMENT");
8990
setenv("ANDROID_APP_PATH", env_argument, 1);
9091
env_entrypoint = getenv("ANDROID_ENTRYPOINT");
9192
env_logname = getenv("PYTHON_NAME");
92-
9393
if (!getenv("ANDROID_UNPACK")) {
9494
/* ANDROID_UNPACK currently isn't set in services */
9595
setenv("ANDROID_UNPACK", env_argument, 1);
9696
}
97-
9897
if (env_logname == NULL) {
9998
env_logname = "python";
10099
setenv("PYTHON_NAME", "python", 1);
101100
}
102101

102+
// Set additional file-provided environment vars:
103+
LOGP("Setting additional env vars from p4a_env_vars.txt");
104+
char env_file_path[256];
105+
snprintf(env_file_path, sizeof(env_file_path),
106+
"%s/p4a_env_vars.txt", getenv("ANDROID_UNPACK"));
107+
FILE *env_file_fd = fopen(env_file_path, "r");
108+
if (env_file_fd) {
109+
char* line = NULL;
110+
size_t len = 0;
111+
while ((read = getline(&line, &len, env_file_fd)) != -1) {
112+
if (strlen(line) > 0) {
113+
size_t eq_pos = strpos(line, "=", 0);
114+
if (eq_pos > 0) {
115+
char env_name[256];
116+
strncpy(env_name, line, 256);
117+
env_name[eq_pos] = 0;
118+
setenv(env_name, (char*)(line + eq_pos + 1));
119+
}
120+
}
121+
}
122+
fclose(env_file_fd);
123+
} else {
124+
LOGP("Warning: no p4a_env_vars.txt found / failed to open!");
125+
}
126+
103127
LOGP("Changing directory to the one provided by ANDROID_ARGUMENT");
104128
LOGP(env_argument);
105129
chdir(env_argument);

0 commit comments

Comments
 (0)