@@ -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 ):
@@ -1833,7 +1836,7 @@ def get_jni_dir(self):
1833
1836
# info_main('Unpacking {} for {}'.format(self.name, arch))
1834
1837
# info('{} is included in the bootstrap, unpacking currently '
1835
1838
# 'unnecessary, so skipping'.format(self.name))
1836
-
1839
+
1837
1840
1838
1841
class PythonRecipe (Recipe ):
1839
1842
site_packages_name = None # The name of the module in
@@ -1853,9 +1856,9 @@ def should_build(self):
1853
1856
return False
1854
1857
info ('{} apparently isn\' t already in site-packages' .format (name ))
1855
1858
return True
1856
-
1857
1859
1858
-
1860
+
1861
+
1859
1862
def build_arch (self , arch ):
1860
1863
'''Install the Python module by calling setup.py install with
1861
1864
the target Python dir.'''
@@ -1900,15 +1903,15 @@ def build_arch(self, arch):
1900
1903
1901
1904
def build_compiled_components (self , arch ):
1902
1905
info ('Building compiled components in {}' .format (self .name ))
1903
-
1906
+
1904
1907
env = self .get_recipe_env (arch )
1905
1908
with current_directory (self .get_build_dir (arch .arch )):
1906
1909
hostpython = sh .Command (self .ctx .hostpython )
1907
1910
shprint (hostpython , 'setup.py' , 'build_ext' , '-v' )
1908
1911
build_dir = glob .glob ('build/lib.*' )[0 ]
1909
1912
shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
1910
1913
env ['STRIP' ], '{}' , ';' , _env = env )
1911
-
1914
+
1912
1915
1913
1916
class CythonRecipe (PythonRecipe ):
1914
1917
pre_build_ext = False
@@ -1954,7 +1957,7 @@ def build_cython_components(self, arch):
1954
1957
env ['STRIP' ], '{}' , ';' , _env = env )
1955
1958
print ('stripped!?' )
1956
1959
# exit(1)
1957
-
1960
+
1958
1961
# def cythonize_file(self, filename):
1959
1962
# if filename.startswith(self.build_dir):
1960
1963
# filename = filename[len(self.build_dir) + 1:]
@@ -2035,7 +2038,7 @@ def build_recipes(build_order, python_modules, ctx):
2035
2038
info ('{} said it is already built, skipping' .format (recipe .name ))
2036
2039
2037
2040
# 4) biglink everything
2038
- # AND: Should make this optional (could use
2041
+ # AND: Should make this optional (could use
2039
2042
info_main ('# Biglinking object files' )
2040
2043
biglink (ctx , arch )
2041
2044
@@ -2047,7 +2050,7 @@ def build_recipes(build_order, python_modules, ctx):
2047
2050
2048
2051
info_main ('# Installing pure Python modules' )
2049
2052
run_pymodules_install (ctx , python_modules )
2050
-
2053
+
2051
2054
return
2052
2055
2053
2056
def run_pymodules_install (ctx , modules ):
@@ -2078,7 +2081,7 @@ def run_pymodules_install(ctx, modules):
2078
2081
shprint (sh .bash , '-c' , (
2079
2082
"source venv/bin/activate && env CC=/bin/false CXX=/bin/false"
2080
2083
"PYTHONPATH= pip install --target '{}' -r requirements.txt" ).format (ctx .get_site_packages_dir ()))
2081
-
2084
+
2082
2085
def biglink (ctx , arch ):
2083
2086
# First, collate object files from each recipe
2084
2087
info ('Collating object files from each recipe' )
@@ -2097,7 +2100,7 @@ def biglink(ctx, arch):
2097
2100
info ('{} recipe has object files, copying' .format (recipe .name ))
2098
2101
files .append (obj_dir )
2099
2102
shprint (sh .cp , '-r' , * files )
2100
-
2103
+
2101
2104
# AND: Shouldn't hardcode ArchAndroid! In reality need separate
2102
2105
# build dirs for each arch
2103
2106
arch = ArchAndroid (ctx )
@@ -2155,7 +2158,7 @@ def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
2155
2158
link = '-L{}' .format (dir )
2156
2159
if link not in unique_args :
2157
2160
unique_args .append (link )
2158
-
2161
+
2159
2162
# print('Biglink create %s library' % soname)
2160
2163
# print('Biglink arguments:')
2161
2164
# for arg in unique_args:
@@ -2405,10 +2408,10 @@ def __init__(self):
2405
2408
'perfectly match those requested.' ),
2406
2409
type = bool , default = False )
2407
2410
2408
-
2411
+
2409
2412
args , unknown = parser .parse_known_args (sys .argv [1 :])
2410
2413
self .dist_args = args
2411
-
2414
+
2412
2415
if args .debug :
2413
2416
logger .setLevel (logging .DEBUG )
2414
2417
self .sdk_dir = args .sdk_dir
@@ -2431,7 +2434,7 @@ def __init__(self):
2431
2434
# warning('Received --allow_build but this arg currently is not '
2432
2435
# 'handled, exiting.')
2433
2436
# exit(1)
2434
-
2437
+
2435
2438
if not hasattr (self , args .command ):
2436
2439
print ('Unrecognized command' )
2437
2440
parser .print_help ()
@@ -2517,7 +2520,7 @@ def clean_dists(self, args):
2517
2520
ctx = Context ()
2518
2521
if exists (ctx .dist_dir ):
2519
2522
shutil .rmtree (ctx .dist_dir )
2520
-
2523
+
2521
2524
def clean_builds (self , args ):
2522
2525
'''Delete all build caches for each recipe, python-install, java code
2523
2526
and compiled libs collection.
@@ -2557,7 +2560,7 @@ def clean_recipe_build(self, args):
2557
2560
recipe = Recipe .get_recipe (args .recipe , self .ctx )
2558
2561
info ('Cleaning build for {} recipe.' .format (recipe .name ))
2559
2562
recipe .clean_build ()
2560
-
2563
+
2561
2564
2562
2565
def clean_download_cache (self , args ):
2563
2566
@@ -2675,7 +2678,7 @@ def apk(self, args):
2675
2678
info ('More than one built APK found...guessing you '
2676
2679
'just built {}' .format (apks [- 1 ]))
2677
2680
shprint (sh .cp , apks [- 1 ], './' )
2678
-
2681
+
2679
2682
2680
2683
@require_prebuilt_dist
2681
2684
def create (self , args ):
0 commit comments