@@ -205,8 +205,8 @@ def is_exe(fpath):
205
205
return exe_file
206
206
207
207
return None
208
-
209
-
208
+
209
+
210
210
@contextlib .contextmanager
211
211
def current_directory (new_dir ):
212
212
cur_dir = getcwd ()
@@ -217,7 +217,7 @@ def current_directory(new_dir):
217
217
logger .info ('' .join ((Fore .CYAN , '<- directory context ' , cur_dir ,
218
218
Fore .RESET )))
219
219
chdir (cur_dir )
220
-
220
+
221
221
222
222
223
223
def cache_execution (f ):
@@ -327,9 +327,9 @@ def get_env(self):
327
327
env ["CFLAGS" ] = " " .join ([
328
328
"-DANDROID" , "-mandroid" , "-fomit-frame-pointer" ,
329
329
"--sysroot" , self .ctx .ndk_platform ])
330
-
330
+
331
331
env ["CXXFLAGS" ] = env ["CFLAGS" ]
332
-
332
+
333
333
env ["LDFLAGS" ] = " " .join (['-lm' ])
334
334
335
335
py_platform = sys .platform
@@ -366,7 +366,7 @@ def get_env(self):
366
366
env ['READELF' ] = '{}-readelf' .format (toolchain_prefix )
367
367
368
368
hostpython_recipe = Recipe .get_recipe ('hostpython2' , self .ctx )
369
-
369
+
370
370
# AND: This hardcodes python version 2.7, needs fixing
371
371
# AND: This also hardcodes armeabi, which isn't even correct, don't forget to fix!
372
372
env ['BUILDLIB_PATH' ] = join (hostpython_recipe .get_build_dir ('armeabi' ),
@@ -416,7 +416,7 @@ class ArchAndroid(Arch):
416
416
# triple = "aarch64-apple-darwin13"
417
417
# version_min = "-miphoneos-version-min=7.0"
418
418
# sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip()
419
-
419
+
420
420
421
421
class Graph (object ):
422
422
# Taken from the old python-for-android/depsort
@@ -664,7 +664,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
664
664
if sdk_dir is None : # This is the old P4A-specific var
665
665
sdk_dir = environ .get ('ANDROIDSDK' , None )
666
666
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 )
668
668
if sdk_dir is None : # Checks in the buildozer SDK dir, useful
669
669
# for debug tests of p4a
670
670
possible_dirs = glob .glob (expanduser (join (
@@ -681,7 +681,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
681
681
warning ('Android SDK dir was not specified, exiting.' )
682
682
exit (1 )
683
683
self .sdk_dir = realpath (sdk_dir )
684
-
684
+
685
685
# Check what Android API we're using
686
686
android_api = None
687
687
if user_android_api :
@@ -799,7 +799,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
799
799
if not exists (self .ndk_platform ):
800
800
warning ('ndk_platform doesn\' t exist' )
801
801
ok = False
802
-
802
+
803
803
virtualenv = None
804
804
if virtualenv is None :
805
805
virtualenv = sh .which ('virtualenv2' )
@@ -826,7 +826,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
826
826
if not self .cython :
827
827
ok = False
828
828
warning ("Missing requirement: cython is not installed" )
829
-
829
+
830
830
# Modify the path so that sh finds modules appropriately
831
831
py_platform = sys .platform
832
832
if py_platform in ['linux2' , 'linux3' ]:
@@ -890,7 +890,7 @@ def __init__(self):
890
890
self .archs = (
891
891
ArchAndroid (self ),
892
892
)
893
-
893
+
894
894
ensure_dir (join (self .build_dir , 'bootstrap_builds' ))
895
895
ensure_dir (join (self .build_dir , 'other_builds' )) # where everything else is built
896
896
@@ -990,7 +990,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
990
990
extra_dist_dirs : list
991
991
Any extra directories in which to search for dists.
992
992
require_perfect_match : bool
993
- If True, will only match distributions with precisely the
993
+ If True, will only match distributions with precisely the
994
994
correct set of recipes.
995
995
'''
996
996
@@ -999,7 +999,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
999
999
# possibilities
1000
1000
1001
1001
existing_dists = Distribution .get_distributions (ctx )
1002
-
1002
+
1003
1003
needs_build = True # whether the dist needs building, will be returned
1004
1004
1005
1005
possible_dists = existing_dists
@@ -1024,7 +1024,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1024
1024
pretty_log_dists (possible_dists )
1025
1025
else :
1026
1026
info ('No existing dists meet the given requirements!' )
1027
-
1027
+
1028
1028
1029
1029
# If any dist has perfect recipes, return it
1030
1030
for dist in possible_dists :
@@ -1050,7 +1050,7 @@ def get_distribution(cls, ctx, name=None, recipes=[], allow_download=True,
1050
1050
# 'sdl2_mixer', 'sdl2_ttf',
1051
1051
# 'python2', 'sdl2',
1052
1052
# 'pyjniussdl2', 'kivysdl2'],
1053
- # 'https://github.com/inclement/sdl2-example-dist/archive/master.zip'),
1053
+ # 'https://github.com/inclement/sdl2-example-dist/archive/master.zip'),
1054
1054
# ]
1055
1055
# _possible_dists = []
1056
1056
# 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,
1063
1063
# dist.url = dist_url
1064
1064
# _possible_dists.append(dist)
1065
1065
# # if _possible_dists
1066
-
1066
+
1067
1067
1068
1068
# If we got this far, we need to build a new dist
1069
1069
dist = Distribution (ctx )
@@ -1157,7 +1157,7 @@ class Bootstrap(object):
1157
1157
satisfies user requirements. If False, it will not be returned
1158
1158
from Bootstrap.get_bootstrap_from_recipes.
1159
1159
'''
1160
-
1160
+
1161
1161
# Other things a Bootstrap might need to track (maybe separately):
1162
1162
# ndk_main.c
1163
1163
# whitelist.txt
@@ -1171,7 +1171,7 @@ def dist_dir(self):
1171
1171
'is None' .format (self , self ))
1172
1172
exit (1 )
1173
1173
return self .distribution .dist_dir
1174
-
1174
+
1175
1175
1176
1176
@property
1177
1177
def jni_dir (self ):
@@ -1198,6 +1198,9 @@ def prepare_build_dir(self):
1198
1198
# 'bootstrap_templates',
1199
1199
# self.name),
1200
1200
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 ))
1201
1204
1202
1205
def prepare_dist_dir (self , name ):
1203
1206
# self.dist_dir = self.get_dist_dir(name)
@@ -1598,7 +1601,7 @@ def unpack(self, arch):
1598
1601
return
1599
1602
1600
1603
filename = shprint (sh .basename , self .versioned_url ).stdout [:- 1 ].decode ('utf-8' )
1601
-
1604
+
1602
1605
# AND: TODO: Use tito's better unpacking method
1603
1606
with current_directory (build_dir ):
1604
1607
directory_name = self .get_build_dir (arch )
@@ -1750,8 +1753,8 @@ def clean_build(self, arch=None):
1750
1753
else :
1751
1754
warning (('Attempted to clean build for {} but build'
1752
1755
'did not exist' ).format (self .name ))
1753
-
1754
-
1756
+
1757
+
1755
1758
1756
1759
@classmethod
1757
1760
def list_recipes (cls ):
@@ -1829,7 +1832,7 @@ def get_jni_dir(self):
1829
1832
# info_main('Unpacking {} for {}'.format(self.name, arch))
1830
1833
# info('{} is included in the bootstrap, unpacking currently '
1831
1834
# 'unnecessary, so skipping'.format(self.name))
1832
-
1835
+
1833
1836
1834
1837
class PythonRecipe (Recipe ):
1835
1838
site_packages_name = None # The name of the module in
@@ -1849,9 +1852,9 @@ def should_build(self):
1849
1852
return False
1850
1853
info ('{} apparently isn\' t already in site-packages' .format (name ))
1851
1854
return True
1852
-
1853
1855
1854
-
1856
+
1857
+
1855
1858
def build_arch (self , arch ):
1856
1859
'''Install the Python module by calling setup.py install with
1857
1860
the target Python dir.'''
@@ -1896,15 +1899,15 @@ def build_arch(self, arch):
1896
1899
1897
1900
def build_compiled_components (self , arch ):
1898
1901
info ('Building compiled components in {}' .format (self .name ))
1899
-
1902
+
1900
1903
env = self .get_recipe_env (arch )
1901
1904
with current_directory (self .get_build_dir (arch .arch )):
1902
1905
hostpython = sh .Command (self .ctx .hostpython )
1903
1906
shprint (hostpython , 'setup.py' , 'build_ext' , '-v' )
1904
1907
build_dir = glob .glob ('build/lib.*' )[0 ]
1905
1908
shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
1906
1909
env ['STRIP' ], '{}' , ';' , _env = env )
1907
-
1910
+
1908
1911
1909
1912
class CythonRecipe (PythonRecipe ):
1910
1913
pre_build_ext = False
@@ -1950,7 +1953,7 @@ def build_cython_components(self, arch):
1950
1953
env ['STRIP' ], '{}' , ';' , _env = env )
1951
1954
print ('stripped!?' )
1952
1955
# exit(1)
1953
-
1956
+
1954
1957
# def cythonize_file(self, filename):
1955
1958
# if filename.startswith(self.build_dir):
1956
1959
# filename = filename[len(self.build_dir) + 1:]
@@ -2031,7 +2034,7 @@ def build_recipes(build_order, python_modules, ctx):
2031
2034
info ('{} said it is already built, skipping' .format (recipe .name ))
2032
2035
2033
2036
# 4) biglink everything
2034
- # AND: Should make this optional (could use
2037
+ # AND: Should make this optional (could use
2035
2038
info_main ('# Biglinking object files' )
2036
2039
biglink (ctx , arch )
2037
2040
@@ -2043,7 +2046,7 @@ def build_recipes(build_order, python_modules, ctx):
2043
2046
2044
2047
info_main ('# Installing pure Python modules' )
2045
2048
run_pymodules_install (ctx , python_modules )
2046
-
2049
+
2047
2050
return
2048
2051
2049
2052
def run_pymodules_install (ctx , modules ):
@@ -2074,7 +2077,7 @@ def run_pymodules_install(ctx, modules):
2074
2077
shprint (sh .bash , '-c' , (
2075
2078
"source venv/bin/activate && env CC=/bin/false CXX=/bin/false"
2076
2079
"PYTHONPATH= pip install --target '{}' -r requirements.txt" ).format (ctx .get_site_packages_dir ()))
2077
-
2080
+
2078
2081
def biglink (ctx , arch ):
2079
2082
# First, collate object files from each recipe
2080
2083
info ('Collating object files from each recipe' )
@@ -2093,7 +2096,7 @@ def biglink(ctx, arch):
2093
2096
info ('{} recipe has object files, copying' .format (recipe .name ))
2094
2097
files .append (obj_dir )
2095
2098
shprint (sh .cp , '-r' , * files )
2096
-
2099
+
2097
2100
# AND: Shouldn't hardcode ArchAndroid! In reality need separate
2098
2101
# build dirs for each arch
2099
2102
arch = ArchAndroid (ctx )
@@ -2151,7 +2154,7 @@ def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
2151
2154
link = '-L{}' .format (dir )
2152
2155
if link not in unique_args :
2153
2156
unique_args .append (link )
2154
-
2157
+
2155
2158
# print('Biglink create %s library' % soname)
2156
2159
# print('Biglink arguments:')
2157
2160
# for arg in unique_args:
@@ -2394,10 +2397,10 @@ def __init__(self):
2394
2397
'perfectly match those requested.' ),
2395
2398
type = bool , default = False )
2396
2399
2397
-
2400
+
2398
2401
args , unknown = parser .parse_known_args (sys .argv [1 :])
2399
2402
self .dist_args = args
2400
-
2403
+
2401
2404
if args .debug :
2402
2405
logger .setLevel (logging .DEBUG )
2403
2406
self .sdk_dir = args .sdk_dir
@@ -2420,7 +2423,7 @@ def __init__(self):
2420
2423
# warning('Received --allow_build but this arg currently is not '
2421
2424
# 'handled, exiting.')
2422
2425
# exit(1)
2423
-
2426
+
2424
2427
if not hasattr (self , args .command ):
2425
2428
print ('Unrecognized command' )
2426
2429
parser .print_help ()
@@ -2506,7 +2509,7 @@ def clean_dists(self, args):
2506
2509
ctx = Context ()
2507
2510
if exists (ctx .dist_dir ):
2508
2511
shutil .rmtree (ctx .dist_dir )
2509
-
2512
+
2510
2513
def clean_builds (self , args ):
2511
2514
'''Delete all build caches for each recipe, python-install, java code
2512
2515
and compiled libs collection.
@@ -2546,7 +2549,7 @@ def clean_recipe_build(self, args):
2546
2549
recipe = Recipe .get_recipe (args .recipe , self .ctx )
2547
2550
info ('Cleaning build for {} recipe.' .format (recipe .name ))
2548
2551
recipe .clean_build ()
2549
-
2552
+
2550
2553
2551
2554
def clean_download_cache (self , args ):
2552
2555
@@ -2664,7 +2667,7 @@ def apk(self, args):
2664
2667
info ('More than one built APK found...guessing you '
2665
2668
'just built {}' .format (apks [- 1 ]))
2666
2669
shprint (sh .cp , apks [- 1 ], './' )
2667
-
2670
+
2668
2671
2669
2672
@require_prebuilt_dist
2670
2673
def create (self , args ):
@@ -2743,7 +2746,7 @@ def sdk_tools(self, args):
2743
2746
for line in output :
2744
2747
sys .stdout .write (line )
2745
2748
sys .stdout .flush ()
2746
-
2749
+
2747
2750
def adb (self , args ):
2748
2751
'''Runs the adb binary from the detected SDK directory, passing all
2749
2752
arguments straight to it. This is intended as a convenience
0 commit comments