@@ -206,8 +206,8 @@ def is_exe(fpath):
206
206
return exe_file
207
207
208
208
return None
209
-
210
-
209
+
210
+
211
211
@contextlib .contextmanager
212
212
def current_directory (new_dir ):
213
213
cur_dir = getcwd ()
@@ -218,7 +218,7 @@ def current_directory(new_dir):
218
218
logger .info ('' .join ((Fore .CYAN , '<- directory context ' , cur_dir ,
219
219
Fore .RESET )))
220
220
chdir (cur_dir )
221
-
221
+
222
222
223
223
224
224
def cache_execution (f ):
@@ -328,9 +328,9 @@ def get_env(self):
328
328
env ["CFLAGS" ] = " " .join ([
329
329
"-DANDROID" , "-mandroid" , "-fomit-frame-pointer" ,
330
330
"--sysroot" , self .ctx .ndk_platform ])
331
-
331
+
332
332
env ["CXXFLAGS" ] = env ["CFLAGS" ]
333
-
333
+
334
334
env ["LDFLAGS" ] = " " .join (['-lm' ])
335
335
336
336
py_platform = sys .platform
@@ -367,7 +367,7 @@ def get_env(self):
367
367
env ['READELF' ] = '{}-readelf' .format (toolchain_prefix )
368
368
369
369
hostpython_recipe = Recipe .get_recipe ('hostpython2' , self .ctx )
370
-
370
+
371
371
# AND: This hardcodes python version 2.7, needs fixing
372
372
# AND: This also hardcodes armeabi, which isn't even correct, don't forget to fix!
373
373
env ['BUILDLIB_PATH' ] = join (hostpython_recipe .get_build_dir ('armeabi' ),
@@ -417,7 +417,7 @@ class ArchAndroid(Arch):
417
417
# triple = "aarch64-apple-darwin13"
418
418
# version_min = "-miphoneos-version-min=7.0"
419
419
# sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip()
420
-
420
+
421
421
422
422
class Graph (object ):
423
423
# Taken from the old python-for-android/depsort
@@ -665,7 +665,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
665
665
if sdk_dir is None : # This is the old P4A-specific var
666
666
sdk_dir = environ .get ('ANDROIDSDK' , None )
667
667
if sdk_dir is None : # This seems used more conventionally
668
- sdk_dir = environ .get ('ANDROID_HOME' , None )
668
+ sdk_dir = environ .get ('ANDROID_HOME' , None )
669
669
if sdk_dir is None : # Checks in the buildozer SDK dir, useful
670
670
# for debug tests of p4a
671
671
possible_dirs = glob .glob (expanduser (join (
@@ -682,7 +682,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
682
682
warning ('Android SDK dir was not specified, exiting.' )
683
683
exit (1 )
684
684
self .sdk_dir = realpath (sdk_dir )
685
-
685
+
686
686
# Check what Android API we're using
687
687
android_api = None
688
688
if user_android_api :
@@ -913,7 +913,7 @@ def __init__(self):
913
913
self .archs = (
914
914
ArchAndroid (self ),
915
915
)
916
-
916
+
917
917
ensure_dir (join (self .build_dir , 'bootstrap_builds' ))
918
918
ensure_dir (join (self .build_dir , 'other_builds' )) # where everything else is built
919
919
@@ -1013,7 +1013,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1013
1013
extra_dist_dirs : list
1014
1014
Any extra directories in which to search for dists.
1015
1015
require_perfect_match : bool
1016
- If True, will only match distributions with precisely the
1016
+ If True, will only match distributions with precisely the
1017
1017
correct set of recipes.
1018
1018
'''
1019
1019
@@ -1022,7 +1022,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1022
1022
# possibilities
1023
1023
1024
1024
existing_dists = Distribution .get_distributions (ctx )
1025
-
1025
+
1026
1026
needs_build = True # whether the dist needs building, will be returned
1027
1027
1028
1028
possible_dists = existing_dists
@@ -1047,7 +1047,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1047
1047
pretty_log_dists (possible_dists )
1048
1048
else :
1049
1049
info ('No existing dists meet the given requirements!' )
1050
-
1050
+
1051
1051
1052
1052
# If any dist has perfect recipes, return it
1053
1053
for dist in possible_dists :
@@ -1073,7 +1073,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1073
1073
# 'sdl2_mixer', 'sdl2_ttf',
1074
1074
# 'python2', 'sdl2',
1075
1075
# 'pyjniussdl2', 'kivysdl2'],
1076
- # 'https://github.com/inclement/sdl2-example-dist/archive/master.zip'),
1076
+ # 'https://github.com/inclement/sdl2-example-dist/archive/master.zip'),
1077
1077
# ]
1078
1078
# _possible_dists = []
1079
1079
# for dist_name, dist_recipes, dist_url in online_dists:
@@ -1086,7 +1086,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1086
1086
# dist.url = dist_url
1087
1087
# _possible_dists.append(dist)
1088
1088
# # if _possible_dists
1089
-
1089
+
1090
1090
1091
1091
# If we got this far, we need to build a new dist
1092
1092
dist = Distribution (ctx )
@@ -1180,7 +1180,7 @@ class Bootstrap(object):
1180
1180
satisfies user requirements. If False, it will not be returned
1181
1181
from Bootstrap.get_bootstrap_from_recipes.
1182
1182
'''
1183
-
1183
+
1184
1184
# Other things a Bootstrap might need to track (maybe separately):
1185
1185
# ndk_main.c
1186
1186
# whitelist.txt
@@ -1194,7 +1194,7 @@ def dist_dir(self):
1194
1194
'is None' .format (self , self ))
1195
1195
exit (1 )
1196
1196
return self .distribution .dist_dir
1197
-
1197
+
1198
1198
1199
1199
@property
1200
1200
def jni_dir (self ):
@@ -1221,6 +1221,9 @@ def prepare_build_dir(self):
1221
1221
# 'bootstrap_templates',
1222
1222
# self.name),
1223
1223
self .build_dir )
1224
+ with current_directory (self .build_dir ):
1225
+ with open ('project.properties' , 'w' ) as fileh :
1226
+ fileh .write ('target=android-{}' .format (self .ctx .android_api ))
1224
1227
1225
1228
def prepare_dist_dir (self , name ):
1226
1229
# self.dist_dir = self.get_dist_dir(name)
@@ -1646,7 +1649,7 @@ def unpack(self, arch):
1646
1649
return
1647
1650
1648
1651
filename = shprint (sh .basename , self .versioned_url ).stdout [:- 1 ].decode ('utf-8' )
1649
-
1652
+
1650
1653
# AND: TODO: Use tito's better unpacking method
1651
1654
with current_directory (build_dir ):
1652
1655
directory_name = self .get_build_dir (arch )
@@ -1806,8 +1809,8 @@ def clean_build(self, arch=None):
1806
1809
else :
1807
1810
warning (('Attempted to clean build for {} but build'
1808
1811
'did not exist' ).format (self .name ))
1809
-
1810
-
1812
+
1813
+
1811
1814
1812
1815
@classmethod
1813
1816
def list_recipes (cls ):
@@ -1885,7 +1888,7 @@ def get_jni_dir(self):
1885
1888
# info_main('Unpacking {} for {}'.format(self.name, arch))
1886
1889
# info('{} is included in the bootstrap, unpacking currently '
1887
1890
# 'unnecessary, so skipping'.format(self.name))
1888
-
1891
+
1889
1892
1890
1893
class PythonRecipe (Recipe ):
1891
1894
site_packages_name = None # The name of the module in
@@ -1905,9 +1908,9 @@ def should_build(self):
1905
1908
return False
1906
1909
info ('{} apparently isn\' t already in site-packages' .format (name ))
1907
1910
return True
1908
-
1909
1911
1910
-
1912
+
1913
+
1911
1914
def build_arch (self , arch ):
1912
1915
'''Install the Python module by calling setup.py install with
1913
1916
the target Python dir.'''
@@ -1952,15 +1955,15 @@ def build_arch(self, arch):
1952
1955
1953
1956
def build_compiled_components (self , arch ):
1954
1957
info ('Building compiled components in {}' .format (self .name ))
1955
-
1958
+
1956
1959
env = self .get_recipe_env (arch )
1957
1960
with current_directory (self .get_build_dir (arch .arch )):
1958
1961
hostpython = sh .Command (self .ctx .hostpython )
1959
1962
shprint (hostpython , 'setup.py' , 'build_ext' , '-v' )
1960
1963
build_dir = glob .glob ('build/lib.*' )[0 ]
1961
1964
shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
1962
1965
env ['STRIP' ], '{}' , ';' , _env = env )
1963
-
1966
+
1964
1967
1965
1968
class CythonRecipe (PythonRecipe ):
1966
1969
pre_build_ext = False
@@ -2006,7 +2009,7 @@ def build_cython_components(self, arch):
2006
2009
env ['STRIP' ], '{}' , ';' , _env = env )
2007
2010
print ('stripped!?' )
2008
2011
# exit(1)
2009
-
2012
+
2010
2013
# def cythonize_file(self, filename):
2011
2014
# if filename.startswith(self.build_dir):
2012
2015
# filename = filename[len(self.build_dir) + 1:]
@@ -2087,7 +2090,7 @@ def build_recipes(build_order, python_modules, ctx):
2087
2090
info ('{} said it is already built, skipping' .format (recipe .name ))
2088
2091
2089
2092
# 4) biglink everything
2090
- # AND: Should make this optional (could use
2093
+ # AND: Should make this optional (could use
2091
2094
info_main ('# Biglinking object files' )
2092
2095
biglink (ctx , arch )
2093
2096
@@ -2099,7 +2102,7 @@ def build_recipes(build_order, python_modules, ctx):
2099
2102
2100
2103
info_main ('# Installing pure Python modules' )
2101
2104
run_pymodules_install (ctx , python_modules )
2102
-
2105
+
2103
2106
return
2104
2107
2105
2108
def run_pymodules_install (ctx , modules ):
@@ -2130,7 +2133,7 @@ def run_pymodules_install(ctx, modules):
2130
2133
shprint (sh .bash , '-c' , (
2131
2134
"source venv/bin/activate && env CC=/bin/false CXX=/bin/false"
2132
2135
"PYTHONPATH= pip install --target '{}' -r requirements.txt" ).format (ctx .get_site_packages_dir ()))
2133
-
2136
+
2134
2137
def biglink (ctx , arch ):
2135
2138
# First, collate object files from each recipe
2136
2139
info ('Collating object files from each recipe' )
@@ -2149,7 +2152,7 @@ def biglink(ctx, arch):
2149
2152
info ('{} recipe has object files, copying' .format (recipe .name ))
2150
2153
files .append (obj_dir )
2151
2154
shprint (sh .cp , '-r' , * files )
2152
-
2155
+
2153
2156
# AND: Shouldn't hardcode ArchAndroid! In reality need separate
2154
2157
# build dirs for each arch
2155
2158
arch = ArchAndroid (ctx )
@@ -2207,7 +2210,7 @@ def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
2207
2210
link = '-L{}' .format (dir )
2208
2211
if link not in unique_args :
2209
2212
unique_args .append (link )
2210
-
2213
+
2211
2214
# print('Biglink create %s library' % soname)
2212
2215
# print('Biglink arguments:')
2213
2216
# for arg in unique_args:
@@ -2450,10 +2453,10 @@ def __init__(self):
2450
2453
'perfectly match those requested.' ),
2451
2454
type = bool , default = False )
2452
2455
2453
-
2456
+
2454
2457
args , unknown = parser .parse_known_args (sys .argv [1 :])
2455
2458
self .dist_args = args
2456
-
2459
+
2457
2460
if args .debug :
2458
2461
logger .setLevel (logging .DEBUG )
2459
2462
self .sdk_dir = args .sdk_dir
@@ -2476,7 +2479,7 @@ def __init__(self):
2476
2479
# warning('Received --allow_build but this arg currently is not '
2477
2480
# 'handled, exiting.')
2478
2481
# exit(1)
2479
-
2482
+
2480
2483
if not hasattr (self , args .command ):
2481
2484
print ('Unrecognized command' )
2482
2485
parser .print_help ()
@@ -2562,7 +2565,7 @@ def clean_dists(self, args):
2562
2565
ctx = Context ()
2563
2566
if exists (ctx .dist_dir ):
2564
2567
shutil .rmtree (ctx .dist_dir )
2565
-
2568
+
2566
2569
def clean_builds (self , args ):
2567
2570
'''Delete all build caches for each recipe, python-install, java code
2568
2571
and compiled libs collection.
@@ -2602,7 +2605,7 @@ def clean_recipe_build(self, args):
2602
2605
recipe = Recipe .get_recipe (args .recipe , self .ctx )
2603
2606
info ('Cleaning build for {} recipe.' .format (recipe .name ))
2604
2607
recipe .clean_build ()
2605
-
2608
+
2606
2609
2607
2610
def clean_download_cache (self , args ):
2608
2611
@@ -2720,7 +2723,7 @@ def apk(self, args):
2720
2723
info ('More than one built APK found...guessing you '
2721
2724
'just built {}' .format (apks [- 1 ]))
2722
2725
shprint (sh .cp , apks [- 1 ], './' )
2723
-
2726
+
2724
2727
2725
2728
@require_prebuilt_dist
2726
2729
def create (self , args ):
@@ -2799,7 +2802,7 @@ def sdk_tools(self, args):
2799
2802
for line in output :
2800
2803
sys .stdout .write (line )
2801
2804
sys .stdout .flush ()
2802
-
2805
+
2803
2806
def adb (self , args ):
2804
2807
'''Runs the adb binary from the detected SDK directory, passing all
2805
2808
arguments straight to it. This is intended as a convenience
0 commit comments