diff options
author | Dan Albert <danalbert@google.com> | 2016-01-26 17:03:31 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2016-01-26 17:03:31 -0800 |
commit | cb15bb82985e825169669c8625f342dd125bac2d (patch) | |
tree | 17bc9bb75abc7d524f219a82788641ac0edc3cc3 | |
parent | 12f3d3a26023214642b18d396dbce8aa10fa7671 (diff) | |
download | ndk-cb15bb82985e825169669c8625f342dd125bac2d.tar.gz |
Unpack modules to a known location when packaging.
If we extract the modules to a known location we can reuse the
directory for testing. This cuts the final unpack out of our build ->
package -> unpack -> repack -> unpack -> test process.
Change-Id: I254c4dc4f13d70d881fe98cc418eb333ba1e6d7d
-rwxr-xr-x | build/tools/package.py | 10 | ||||
-rw-r--r-- | checkbuild.py | 64 |
2 files changed, 30 insertions, 44 deletions
diff --git a/build/tools/package.py b/build/tools/package.py index 091cd642d..76b90abbf 100755 --- a/build/tools/package.py +++ b/build/tools/package.py @@ -249,6 +249,8 @@ def copy_changelog(out_dir): def make_package(release, package_dir, packages, host, out_dir, temp_dir): release_name = 'android-ndk-{}'.format(release) extract_dir = os.path.join(temp_dir, release_name) + if os.path.exists(extract_dir): + shutil.rmtree(extract_dir) extract_all(package_dir, packages, extract_dir) make_ndk_build_shortcut(extract_dir, host) @@ -336,12 +338,8 @@ def main(): extract_all(args.dist_dir, packages, args.out_dir) make_ndk_build_shortcut(args.out_dir, args.host) else: - package_dir = tempfile.mkdtemp() - try: - make_package(args.release, args.dist_dir, packages, args.host, - args.out_dir, package_dir) - finally: - shutil.rmtree(package_dir) + make_package(args.release, args.dist_dir, packages, args.host, + args.out_dir, build_support.get_out_dir()) if __name__ == '__main__': diff --git a/checkbuild.py b/checkbuild.py index 831a0f21f..ea04c843a 100644 --- a/checkbuild.py +++ b/checkbuild.py @@ -136,48 +136,36 @@ def package_ndk(out_dir, dist_dir, args): def test_ndk(out_dir, args): - # TODO(danalbert): Remove the unpack step. - # We're building modules, unpacking them, repacking them, and then - # unpacking to test. This is dumb. Unpack to a known location to cut out - # half of these steps. - unpack_dir = tempfile.mkdtemp() - try: - host_tag = build_support.host_to_tag(args.system) - release = args.release - if args.release is None: - release = datetime.date.today().strftime('%Y%m%d') + release = args.release + if args.release is None: + release = datetime.date.today().strftime('%Y%m%d') - package_name = 'android-ndk-{}-{}.tar.bz2'.format(release, host_tag) - package_path = os.path.join(out_dir, package_name) + # The packaging step extracts all the modules to a known directory for + # packaging. This directory is not cleaned up after packaging, so we can + # reuse that for testing. + test_dir = os.path.join(out_dir, 'android-ndk-{}'.format(release)) - print('Extracting {} to {}'.format(package_path, unpack_dir)) - subprocess.check_call(['tar', 'xf', package_path, '-C', unpack_dir]) - test_dir = os.path.join( - unpack_dir, 'android-ndk-{}'.format(release)) + test_env = dict(os.environ) + test_env['NDK'] = test_dir - test_env = dict(os.environ) - test_env['NDK'] = test_dir + abis = build_support.ALL_ABIS + if args.arch is not None: + abis = build_support.arch_to_abis(args.arch) - abis = build_support.ALL_ABIS - if args.arch is not None: - abis = build_support.arch_to_abis(args.arch) + results = {} + for abi in abis: + cmd = [ + 'python', build_support.ndk_path('tests/run-all.py'), + '--abi', abi, '--suite', 'build' + ] + print('Running tests: {}'.format(' '.join(cmd))) + result = subprocess.call(cmd, env=test_env) + results[abi] = result == 0 - results = {} - for abi in abis: - cmd = [ - 'python', build_support.ndk_path('tests/run-all.py'), - '--abi', abi, '--suite', 'build' - ] - print('Running tests: {}'.format(' '.join(cmd))) - result = subprocess.call(cmd, env=test_env) - results[abi] = result == 0 - - print('Results:') - for abi, result in results.iteritems(): - print('{}: {}'.format(abi, 'PASS' if result else 'FAIL')) - return all(results.values()) - finally: - shutil.rmtree(unpack_dir) + print('Results:') + for abi, result in results.iteritems(): + print('{}: {}'.format(abi, 'PASS' if result else 'FAIL')) + return all(results.values()) def common_build_args(out_dir, dist_dir, args): @@ -640,7 +628,7 @@ def main(): package_ndk(out_dir, dist_dir, args) if args.test: - result = test_ndk(dist_dir, args) + result = test_ndk(out_dir, args) sys.exit(0 if result else 1) |