From 7b188e8fbb01f72f00f4526b2c72d52ba5b6aa23 Mon Sep 17 00:00:00 2001 From: VladimirTechMan Date: Tue, 14 Mar 2017 03:12:35 -0700 Subject: [PATCH] Add flag to clean up temporary results after building iOS Framework or static lib The --purify flag can now be passed to remove the temporary files and directories created while building the iOS Framework or static library. That way, only the final result(s) are taking up space in the output folder. BUG=None NOTRY=True Review-Url: https://codereview.webrtc.org/2740923003 Cr-Commit-Position: refs/heads/master@{#17224} --- tools-webrtc/ios/build_ios_libs.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools-webrtc/ios/build_ios_libs.py b/tools-webrtc/ios/build_ios_libs.py index fbc8df0415..734f3e216d 100755 --- a/tools-webrtc/ios/build_ios_libs.py +++ b/tools-webrtc/ios/build_ios_libs.py @@ -50,6 +50,9 @@ def _ParseArgs(): help='Architectures to build. Defaults to %(default)s.') parser.add_argument('-c', '--clean', action='store_true', default=False, help='Removes the previously generated build output, if any.') + parser.add_argument('-p', '--purify', action='store_true', default=False, + help='Purifies the previously generated build output by ' + 'removing the temporary results used when (re)building.') parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR, help='Specifies a directory to output the build artifacts to. ' 'If specified together with -c, deletes the dir.') @@ -78,6 +81,15 @@ def _CleanArtifacts(output_dir): shutil.rmtree(output_dir) +def _CleanTemporary(output_dir, architectures): + if os.path.isdir(output_dir): + logging.info('Removing temporary build files.') + for arch in architectures: + arch_lib_path = os.path.join(output_dir, arch + '_libs') + if os.path.isdir(arch_lib_path): + shutil.rmtree(arch_lib_path) + + def BuildWebRTC(output_dir, target_arch, flavor, build_type, ios_deployment_target, libvpx_build_vp9, use_bitcode, use_goma, extra_gn_args): @@ -146,6 +158,11 @@ def main(): return 0 architectures = list(args.arch) + + if args.purify: + _CleanTemporary(args.output_dir, architectures) + return 0 + # Ignoring x86 except for static libraries for now because of a GN build issue # where the generated dynamic framework has the wrong architectures. if 'x86' in architectures and args.build_type != 'static_only':