Skip to content

Commit

Permalink
Bump SDL2 to 2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Thiem committed Jan 15, 2019
1 parent 81a8bf6 commit c24a148
Show file tree
Hide file tree
Showing 19 changed files with 4,858 additions and 605 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ prune doc/build
recursive-include pythonforandroid *.py *.tmpl biglink liblink
recursive-include pythonforandroid/recipes *.py *.patch *.c *.pyx Setup *.h

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

prune .git
prune pythonforandroid/bootstraps/pygame/build/libs
6 changes: 4 additions & 2 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ the latest usable NDK version is r10e, which can be downloaded here:
release with the legacy version of python is version
`0.6.0 <https://github.com/kivy/python-for-android/archive/0.6.0.zip>`_.

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

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

Expand Down
40 changes: 39 additions & 1 deletion pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import subprocess
import sys
import tarfile
import tempfile
import time
from zipfile import ZipFile

Expand Down Expand Up @@ -275,8 +276,17 @@ def make_package(args):
# construct a python27.zip
make_python_zip()

# Add extra environment variable file into tar-able directory:
env_vars_tarpath = tempfile.mkdtemp(prefix="p4a-extra-env-")
with open(os.path.join(env_vars_tarpath, "p4a_env_vars.txt"), "w") as f:
f.write("P4A_IS_WINDOWED=" + str(args.windowed) + "\n")
if hasattr(args, "orientation"):
f.write("P4A_ORIENTATION=" + str(args.orientation) + "\n")
f.write("P4A_NUMERIC_VERSION=" + str(args.numeric_version) + "\n")
f.write("P4A_MINSDK=" + str(args.min_sdk_version) + "\n")

# Package up the private data (public not supported).
tar_dirs = []
tar_dirs = [env_vars_tarpath]
if args.private:
tar_dirs.append(args.private)
for python_bundle_dir in ('private', 'crystax_python', '_python_bundle'):
Expand All @@ -289,6 +299,9 @@ def make_package(args):
join(assets_dir, 'private.mp3'), tar_dirs, args.ignore_path,
optimize_python=args.optimize_python)

# Remove extra env vars tar-able directory:
shutil.rmtree(env_vars_tarpath)

# Prepare some variables for templating process
res_dir = "src/main/res"
if get_bootstrap_name() == "webview":
Expand Down Expand Up @@ -498,6 +511,31 @@ def make_package(args):
if exists('build.properties'):
os.remove('build.properties')

# Apply java source patches if any are present:
if exists(join('src', 'patches')):
print("Applying Java source code patches...")
for patch_name in os.listdir(join('src', 'patches')):
patch_path = join('src', 'patches', patch_name)
print("Applying patch: " + str(patch_path))
try:
subprocess.check_output([
# -N: insist this is FORWARd patch, don't reverse apply
# -p1: strip first path component
# -t: batch mode, don't ask questions
"patch", "-N", "-p1", "-t", "-i", patch_path
])
except subprocess.CalledProcessError as e:
if e.returncode == 1:
# Return code 1 means it didn't apply, this will
# usually mean it is already applied.
print("Warning: failed to apply patch (" +
"exit code 1), " +
"assuming it is already applied: " +
str(patch_path)
)
else:
raise e


def parse_args(args=None):
global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,48 @@ int main(int argc, char *argv[]) {
int ret = 0;
FILE *fd;

setenv("P4A_BOOTSTRAP", bootstrap_name, 1); // env var to identify p4a to applications

LOGP("Initializing Python for Android");

// Set a couple of built-in environment vars:
setenv("P4A_BOOTSTRAP", bootstrap_name, 1); // env var to identify p4a to applications
env_argument = getenv("ANDROID_ARGUMENT");
setenv("ANDROID_APP_PATH", env_argument, 1);
env_entrypoint = getenv("ANDROID_ENTRYPOINT");
env_logname = getenv("PYTHON_NAME");

if (!getenv("ANDROID_UNPACK")) {
/* ANDROID_UNPACK currently isn't set in services */
setenv("ANDROID_UNPACK", env_argument, 1);
}

if (env_logname == NULL) {
env_logname = "python";
setenv("PYTHON_NAME", "python", 1);
}

// Set additional file-provided environment vars:
LOGP("Setting additional env vars from p4a_env_vars.txt");
char env_file_path[256];
snprintf(env_file_path, sizeof(env_file_path),
"%s/p4a_env_vars.txt", getenv("ANDROID_UNPACK"));
FILE *env_file_fd = fopen(env_file_path, "r");
if (env_file_fd) {
char* line = NULL;
size_t len = 0;
while ((read = getline(&line, &len, env_file_fd)) != -1) {
if (strlen(line) > 0) {
size_t eq_pos = strpos(line, "=", 0);
if (eq_pos > 0) {
char env_name[256];
strncpy(env_name, line, 256);
env_name[eq_pos] = 0;
setenv(env_name, (char*)(line + eq_pos + 1));
}
}
}
fclose(env_file_fd);
} else {
LOGP("Warning: no p4a_env_vars.txt found / failed to open!");
}

LOGP("Changing directory to the one provided by ANDROID_ARGUMENT");
LOGP(env_argument);
chdir(env_argument);
Expand Down
Loading

0 comments on commit c24a148

Please sign in to comment.