Skip to content

Commit bda0969

Browse files
committed
Merge branch 'str4d-425-sdl2-bootstrap-android-api' into revamp
2 parents 5986ed6 + 9f4b89c commit bda0969

File tree

7 files changed

+43
-91
lines changed

7 files changed

+43
-91
lines changed

pythonforandroid/bootstraps/pygame/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def run_distribute(self):
2727
shprint(sh.mkdir, dirname)
2828

2929
info('Copying default files')
30-
shprint(sh.cp, '-a', join(src_path, 'default.properties'), '.')
30+
shprint(sh.cp, '-a', join(self.build_dir, 'project.properties'), '.')
3131
shprint(sh.cp, '-a', join(src_path, 'local.properties'), '.')
3232
shprint(sh.cp, '-a', join(src_path, 'build.py'), '.')
3333
shprint(sh.cp, '-a', join(src_path, 'buildlib'), '.')

pythonforandroid/bootstraps/pygame/build/default.properties

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

pythonforandroid/bootstraps/sdl2/build/default.properties

Lines changed: 0 additions & 11 deletions
This file was deleted.

pythonforandroid/bootstraps/sdl2/build/project.properties

Lines changed: 0 additions & 14 deletions
This file was deleted.

pythonforandroid/bootstraps/sdl2python3/build/default.properties

Lines changed: 0 additions & 11 deletions
This file was deleted.

pythonforandroid/bootstraps/sdl2python3/build/project.properties

Lines changed: 0 additions & 14 deletions
This file was deleted.

pythonforandroid/toolchain.py

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ def is_exe(fpath):
205205
return exe_file
206206

207207
return None
208-
209-
208+
209+
210210
@contextlib.contextmanager
211211
def current_directory(new_dir):
212212
cur_dir = getcwd()
@@ -217,7 +217,7 @@ def current_directory(new_dir):
217217
logger.info(''.join((Fore.CYAN, '<- directory context ', cur_dir,
218218
Fore.RESET)))
219219
chdir(cur_dir)
220-
220+
221221

222222

223223
def cache_execution(f):
@@ -327,9 +327,9 @@ def get_env(self):
327327
env["CFLAGS"] = " ".join([
328328
"-DANDROID", "-mandroid", "-fomit-frame-pointer",
329329
"--sysroot", self.ctx.ndk_platform])
330-
330+
331331
env["CXXFLAGS"] = env["CFLAGS"]
332-
332+
333333
env["LDFLAGS"] = " ".join(['-lm'])
334334

335335
py_platform = sys.platform
@@ -366,7 +366,7 @@ def get_env(self):
366366
env['READELF'] = '{}-readelf'.format(toolchain_prefix)
367367

368368
hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)
369-
369+
370370
# AND: This hardcodes python version 2.7, needs fixing
371371
# AND: This also hardcodes armeabi, which isn't even correct, don't forget to fix!
372372
env['BUILDLIB_PATH'] = join(hostpython_recipe.get_build_dir('armeabi'),
@@ -416,7 +416,7 @@ class ArchAndroid(Arch):
416416
# triple = "aarch64-apple-darwin13"
417417
# version_min = "-miphoneos-version-min=7.0"
418418
# sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip()
419-
419+
420420

421421
class Graph(object):
422422
# Taken from the old python-for-android/depsort
@@ -664,7 +664,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
664664
if sdk_dir is None: # This is the old P4A-specific var
665665
sdk_dir = environ.get('ANDROIDSDK', None)
666666
if sdk_dir is None: # This seems used more conventionally
667-
sdk_dir = environ.get('ANDROID_HOME', None)
667+
sdk_dir = environ.get('ANDROID_HOME', None)
668668
if sdk_dir is None: # Checks in the buildozer SDK dir, useful
669669
# for debug tests of p4a
670670
possible_dirs = glob.glob(expanduser(join(
@@ -681,7 +681,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
681681
warning('Android SDK dir was not specified, exiting.')
682682
exit(1)
683683
self.sdk_dir = realpath(sdk_dir)
684-
684+
685685
# Check what Android API we're using
686686
android_api = None
687687
if user_android_api:
@@ -799,7 +799,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
799799
if not exists(self.ndk_platform):
800800
warning('ndk_platform doesn\'t exist')
801801
ok = False
802-
802+
803803
virtualenv = None
804804
if virtualenv is None:
805805
virtualenv = sh.which('virtualenv2')
@@ -826,7 +826,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
826826
if not self.cython:
827827
ok = False
828828
warning("Missing requirement: cython is not installed")
829-
829+
830830
# Modify the path so that sh finds modules appropriately
831831
py_platform = sys.platform
832832
if py_platform in ['linux2', 'linux3']:
@@ -890,7 +890,7 @@ def __init__(self):
890890
self.archs = (
891891
ArchAndroid(self),
892892
)
893-
893+
894894
ensure_dir(join(self.build_dir, 'bootstrap_builds'))
895895
ensure_dir(join(self.build_dir, 'other_builds')) # where everything else is built
896896

@@ -990,7 +990,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
990990
extra_dist_dirs : list
991991
Any extra directories in which to search for dists.
992992
require_perfect_match : bool
993-
If True, will only match distributions with precisely the
993+
If True, will only match distributions with precisely the
994994
correct set of recipes.
995995
'''
996996

@@ -999,7 +999,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
999999
# possibilities
10001000

10011001
existing_dists = Distribution.get_distributions(ctx)
1002-
1002+
10031003
needs_build = True # whether the dist needs building, will be returned
10041004

10051005
possible_dists = existing_dists
@@ -1024,7 +1024,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
10241024
pretty_log_dists(possible_dists)
10251025
else:
10261026
info('No existing dists meet the given requirements!')
1027-
1027+
10281028

10291029
# If any dist has perfect recipes, return it
10301030
for dist in possible_dists:
@@ -1050,7 +1050,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
10501050
# 'sdl2_mixer', 'sdl2_ttf',
10511051
# 'python2', 'sdl2',
10521052
# 'pyjniussdl2', 'kivysdl2'],
1053-
# 'https://github.com/inclement/sdl2-example-dist/archive/master.zip'),
1053+
# 'https://github.com/inclement/sdl2-example-dist/archive/master.zip'),
10541054
# ]
10551055
# _possible_dists = []
10561056
# for dist_name, dist_recipes, dist_url in online_dists:
@@ -1063,7 +1063,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
10631063
# dist.url = dist_url
10641064
# _possible_dists.append(dist)
10651065
# # if _possible_dists
1066-
1066+
10671067

10681068
# If we got this far, we need to build a new dist
10691069
dist = Distribution(ctx)
@@ -1157,7 +1157,7 @@ class Bootstrap(object):
11571157
satisfies user requirements. If False, it will not be returned
11581158
from Bootstrap.get_bootstrap_from_recipes.
11591159
'''
1160-
1160+
11611161
# Other things a Bootstrap might need to track (maybe separately):
11621162
# ndk_main.c
11631163
# whitelist.txt
@@ -1171,7 +1171,7 @@ def dist_dir(self):
11711171
'is None'.format(self, self))
11721172
exit(1)
11731173
return self.distribution.dist_dir
1174-
1174+
11751175

11761176
@property
11771177
def jni_dir(self):
@@ -1198,6 +1198,9 @@ def prepare_build_dir(self):
11981198
# 'bootstrap_templates',
11991199
# self.name),
12001200
self.build_dir)
1201+
with current_directory(self.build_dir):
1202+
with open('project.properties', 'w') as fileh:
1203+
fileh.write('target=android-{}'.format(self.ctx.android_api))
12011204

12021205
def prepare_dist_dir(self, name):
12031206
# self.dist_dir = self.get_dist_dir(name)
@@ -1598,7 +1601,7 @@ def unpack(self, arch):
15981601
return
15991602

16001603
filename = shprint(sh.basename, self.versioned_url).stdout[:-1].decode('utf-8')
1601-
1604+
16021605
# AND: TODO: Use tito's better unpacking method
16031606
with current_directory(build_dir):
16041607
directory_name = self.get_build_dir(arch)
@@ -1750,8 +1753,8 @@ def clean_build(self, arch=None):
17501753
else:
17511754
warning(('Attempted to clean build for {} but build'
17521755
'did not exist').format(self.name))
1753-
1754-
1756+
1757+
17551758

17561759
@classmethod
17571760
def list_recipes(cls):
@@ -1833,7 +1836,7 @@ def get_jni_dir(self):
18331836
# info_main('Unpacking {} for {}'.format(self.name, arch))
18341837
# info('{} is included in the bootstrap, unpacking currently '
18351838
# 'unnecessary, so skipping'.format(self.name))
1836-
1839+
18371840

18381841
class PythonRecipe(Recipe):
18391842
site_packages_name = None # The name of the module in
@@ -1853,9 +1856,9 @@ def should_build(self):
18531856
return False
18541857
info('{} apparently isn\'t already in site-packages'.format(name))
18551858
return True
1856-
18571859

1858-
1860+
1861+
18591862
def build_arch(self, arch):
18601863
'''Install the Python module by calling setup.py install with
18611864
the target Python dir.'''
@@ -1900,15 +1903,15 @@ def build_arch(self, arch):
19001903

19011904
def build_compiled_components(self, arch):
19021905
info('Building compiled components in {}'.format(self.name))
1903-
1906+
19041907
env = self.get_recipe_env(arch)
19051908
with current_directory(self.get_build_dir(arch.arch)):
19061909
hostpython = sh.Command(self.ctx.hostpython)
19071910
shprint(hostpython, 'setup.py', 'build_ext', '-v')
19081911
build_dir = glob.glob('build/lib.*')[0]
19091912
shprint(sh.find, build_dir, '-name', '"*.o"', '-exec',
19101913
env['STRIP'], '{}', ';', _env=env)
1911-
1914+
19121915

19131916
class CythonRecipe(PythonRecipe):
19141917
pre_build_ext = False
@@ -1954,7 +1957,7 @@ def build_cython_components(self, arch):
19541957
env['STRIP'], '{}', ';', _env=env)
19551958
print('stripped!?')
19561959
# exit(1)
1957-
1960+
19581961
# def cythonize_file(self, filename):
19591962
# if filename.startswith(self.build_dir):
19601963
# filename = filename[len(self.build_dir) + 1:]
@@ -2035,7 +2038,7 @@ def build_recipes(build_order, python_modules, ctx):
20352038
info('{} said it is already built, skipping'.format(recipe.name))
20362039

20372040
# 4) biglink everything
2038-
# AND: Should make this optional (could use
2041+
# AND: Should make this optional (could use
20392042
info_main('# Biglinking object files')
20402043
biglink(ctx, arch)
20412044

@@ -2047,7 +2050,7 @@ def build_recipes(build_order, python_modules, ctx):
20472050

20482051
info_main('# Installing pure Python modules')
20492052
run_pymodules_install(ctx, python_modules)
2050-
2053+
20512054
return
20522055

20532056
def run_pymodules_install(ctx, modules):
@@ -2078,7 +2081,7 @@ def run_pymodules_install(ctx, modules):
20782081
shprint(sh.bash, '-c', (
20792082
"source venv/bin/activate && env CC=/bin/false CXX=/bin/false"
20802083
"PYTHONPATH= pip install --target '{}' -r requirements.txt").format(ctx.get_site_packages_dir()))
2081-
2084+
20822085
def biglink(ctx, arch):
20832086
# First, collate object files from each recipe
20842087
info('Collating object files from each recipe')
@@ -2097,7 +2100,7 @@ def biglink(ctx, arch):
20972100
info('{} recipe has object files, copying'.format(recipe.name))
20982101
files.append(obj_dir)
20992102
shprint(sh.cp, '-r', *files)
2100-
2103+
21012104
# AND: Shouldn't hardcode ArchAndroid! In reality need separate
21022105
# build dirs for each arch
21032106
arch = ArchAndroid(ctx)
@@ -2155,7 +2158,7 @@ def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
21552158
link = '-L{}'.format(dir)
21562159
if link not in unique_args:
21572160
unique_args.append(link)
2158-
2161+
21592162
# print('Biglink create %s library' % soname)
21602163
# print('Biglink arguments:')
21612164
# for arg in unique_args:
@@ -2405,10 +2408,10 @@ def __init__(self):
24052408
'perfectly match those requested.'),
24062409
type=bool, default=False)
24072410

2408-
2411+
24092412
args, unknown = parser.parse_known_args(sys.argv[1:])
24102413
self.dist_args = args
2411-
2414+
24122415
if args.debug:
24132416
logger.setLevel(logging.DEBUG)
24142417
self.sdk_dir = args.sdk_dir
@@ -2431,7 +2434,7 @@ def __init__(self):
24312434
# warning('Received --allow_build but this arg currently is not '
24322435
# 'handled, exiting.')
24332436
# exit(1)
2434-
2437+
24352438
if not hasattr(self, args.command):
24362439
print('Unrecognized command')
24372440
parser.print_help()
@@ -2517,7 +2520,7 @@ def clean_dists(self, args):
25172520
ctx = Context()
25182521
if exists(ctx.dist_dir):
25192522
shutil.rmtree(ctx.dist_dir)
2520-
2523+
25212524
def clean_builds(self, args):
25222525
'''Delete all build caches for each recipe, python-install, java code
25232526
and compiled libs collection.
@@ -2557,7 +2560,7 @@ def clean_recipe_build(self, args):
25572560
recipe = Recipe.get_recipe(args.recipe, self.ctx)
25582561
info('Cleaning build for {} recipe.'.format(recipe.name))
25592562
recipe.clean_build()
2560-
2563+
25612564

25622565
def clean_download_cache(self, args):
25632566

@@ -2675,7 +2678,7 @@ def apk(self, args):
26752678
info('More than one built APK found...guessing you '
26762679
'just built {}'.format(apks[-1]))
26772680
shprint(sh.cp, apks[-1], './')
2678-
2681+
26792682

26802683
@require_prebuilt_dist
26812684
def create(self, args):

0 commit comments

Comments
 (0)