@@ -1575,6 +1575,32 @@ def prepare_build_dir(self, arch):
1575
1575
'''
1576
1576
self .unpack (arch )
1577
1577
1578
+ def clean_build (self , arch = None ):
1579
+ '''Deletes all the build information of the recipe.
1580
+
1581
+ If arch is not None, only this arch dir is deleted. Otherwise
1582
+ (the default) all builds for all archs are deleted.
1583
+
1584
+ By default, this just deletes the main build dir. If the
1585
+ recipe has e.g. object files biglinked, or .so files stored
1586
+ elsewhere, you should override this method.
1587
+
1588
+ This method is intended for testing purposes, it may have
1589
+ strange results. Rebuild everything if this seems to happen.
1590
+
1591
+ '''
1592
+ if arch is None :
1593
+ dir = join (self .ctx .build_dir , 'other_builds' , self .name )
1594
+ else :
1595
+ dir = self .get_build_container_dir (arch )
1596
+ if exists (dir ):
1597
+ shutil .rmtree (dir )
1598
+ else :
1599
+ warning (('Attempted to clean build for {} but build'
1600
+ 'did not exist' ).format (self .name ))
1601
+
1602
+
1603
+
1578
1604
@classmethod
1579
1605
def list_recipes (cls ):
1580
1606
forbidden_dirs = ('__pycache__' , )
@@ -1913,7 +1939,11 @@ def run_pymodules_install(ctx, modules):
1913
1939
'probably means the package cannot be installed with '
1914
1940
'pip as it needs a compilation recipe.' )
1915
1941
1916
- shprint (sh .bash , '-c' , '''source venv/bin/activate && env CC=/bin/false CXX=/bin/false PYTHONPATH= pip install --target '{}' -r requirements.txt''' .format (ctx .get_site_packages_dir ()))
1942
+ # This bash method is what old-p4a used
1943
+ # It works but should be replaced with something better
1944
+ shprint (sh .bash , '-c' , (
1945
+ "source venv/bin/activate && env CC=/bin/false CXX=/bin/false"
1946
+ "PYTHONPATH= pip install --target '{}' -r requirements.txt" ).format (ctx .get_site_packages_dir ()))
1917
1947
1918
1948
def biglink (ctx , arch ):
1919
1949
# First, collate object files from each recipe
@@ -2245,9 +2275,12 @@ def clean_dists(self, args):
2245
2275
shutil .rmtree (ctx .dist_dir )
2246
2276
2247
2277
def clean_builds (self , args ):
2248
- '''Delete all build caches for each recipe.
2278
+ '''Delete all build caches for each recipe, python-install, java code
2279
+ and compiled libs collection.
2249
2280
2250
2281
This does *not* delete the package download cache or the final distributions.
2282
+
2283
+ You can also use clean_recipe_build to delete the build of a specific recipe.
2251
2284
'''
2252
2285
parser = argparse .ArgumentParser (
2253
2286
description = "Delete all build files (but not download caches)" )
@@ -2263,7 +2296,27 @@ def clean_builds(self, args):
2263
2296
if exists (libs_dir ):
2264
2297
shutil .rmtree (libs_dir )
2265
2298
2299
+ def clean_recipe_build (self , args ):
2300
+ '''Deletes the build files of the given recipe.
2301
+
2302
+ This is intended for debug purposes, you may experience
2303
+ strange behaviour or problems with some recipes (if their
2304
+ build has done unexpected state changes). If this happens, run
2305
+ clean_builds, or attempt to clean other recipes until things
2306
+ work again.
2307
+ '''
2308
+ parser = argparse .ArgumentParser (
2309
+ description = "Delete all build files for the given recipe name." )
2310
+ parser .add_argument ('recipe' , help = 'The recipe name' )
2311
+ args = parser .parse_args (args )
2312
+
2313
+ recipe = Recipe .get_recipe (args .recipe , self .ctx )
2314
+ info ('Cleaning build for {} recipe.' .format (recipe .name ))
2315
+ recipe .clean_build ()
2316
+
2317
+
2266
2318
def clean_download_cache (self , args ):
2319
+
2267
2320
'''
2268
2321
Deletes any downloaded recipe packages.
2269
2322
0 commit comments