aboutsummaryrefslogtreecommitdiff
path: root/build/lib
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2017-11-28 22:37:29 -0800
committerDan Albert <danalbert@google.com>2017-11-28 23:04:56 -0800
commit8ae58fe7bb88d8aa1bb355d2fc8ecb4676e2e57d (patch)
treec0bec02313c5f74048e9d12daf4a8323ee1c7e6b /build/lib
parent76508a6acfa90a9520c143690dcb6699b271d5e2 (diff)
downloadndk-8ae58fe7bb88d8aa1bb355d2fc8ecb4676e2e57d.tar.gz
Move APIs from build.lib.build_support to ndk.
"build" is not a valid package name for setuptools. This package will be silently removed from the source distribution because setuptools thinks it's the build directory rather than a python package named build. Pieces of this package are being moved into the ndk package where they belong, but will continue to be exported from there until we can chase down all the other users. Test: ./checkbuild.py && ./run_tests.py Bug: None Change-Id: I6c57eefb78866a6e4f53af22791842e1afb24698
Diffstat (limited to 'build/lib')
-rw-r--r--build/lib/build_support.py179
1 files changed, 33 insertions, 146 deletions
diff --git a/build/lib/build_support.py b/build/lib/build_support.py
index 90e7cd8e1..7029f7705 100644
--- a/build/lib/build_support.py
+++ b/build/lib/build_support.py
@@ -17,111 +17,52 @@ import argparse
import multiprocessing
import os
import shutil
+import site
import subprocess
import sys
import tempfile
import zipfile
+# "build" is not a valid package name for setuptools. This package will be
+# silently removed from the source distribution because setuptools thinks it's
+# the build directory rather than a python package named build. Pieces of this
+# package are being moved into the ndk package where they belong, but will
+# continue to be exported from here until we can chase down all the other
+# users.
THIS_DIR = os.path.realpath(os.path.dirname(__file__))
-
-
-ALL_TOOLCHAINS = (
- 'arm-linux-androideabi',
- 'aarch64-linux-android',
- 'x86',
- 'x86_64',
-)
-
-
-ALL_TRIPLES = (
- 'arm-linux-androideabi',
- 'aarch64-linux-android',
- 'i686-linux-android',
- 'x86_64-linux-android',
+site.addsitedir(os.path.join(THIS_DIR, '../..'))
+
+# pylint: disable=wrong-import-position,unused-import
+from ndk.abis import (
+ ALL_ABIS,
+ ALL_ARCHITECTURES,
+ ALL_TOOLCHAINS,
+ ALL_TRIPLES,
+ LP32_ABIS,
+ LP64_ABIS,
+ arch_to_abis,
+ arch_to_toolchain,
+ arch_to_triple,
+ toolchain_to_arch,
)
-
-ALL_ARCHITECTURES = (
- 'arm',
- 'arm64',
- 'x86',
- 'x86_64',
+from ndk.builds import make_repo_prop
+from ndk.hosts import get_default_host, host_to_tag
+from ndk.paths import (
+ android_path,
+ get_dist_dir,
+ get_out_dir,
+ ndk_path,
+ sysroot_path,
+ toolchain_path,
)
-
-
-ALL_ABIS = (
- 'armeabi-v7a',
- 'arm64-v8a',
- 'x86',
- 'x86_64',
-)
-
-
-LP32_ABIS = ('armeabi-v7a', 'x86')
-LP64_ABIS = ('arm64-v8a', 'x86_64')
+# pylint: enable=wrong-import-position,unused-import
def minimum_platform_level(abi):
- if abi in LP64_ABIS:
- return 21
- else:
- return 14
-
-
-def arch_to_toolchain(arch):
- return dict(zip(ALL_ARCHITECTURES, ALL_TOOLCHAINS))[arch]
-
-
-def arch_to_triple(arch):
- return dict(zip(ALL_ARCHITECTURES, ALL_TRIPLES))[arch]
-
-
-def toolchain_to_arch(toolchain):
- return dict(zip(ALL_TOOLCHAINS, ALL_ARCHITECTURES))[toolchain]
-
-
-def arch_to_abis(arch):
- return {
- 'arm': ['armeabi-v7a'],
- 'arm64': ['arm64-v8a'],
- 'x86': ['x86'],
- 'x86_64': ['x86_64'],
- }[arch]
-
-
-def abi_to_arch(arch):
- return {
- 'armeabi-v7a': 'arm',
- 'arm64-v8a': 'arm64',
- 'x86': 'x86',
- 'x86_64': 'x86_64',
- }[arch]
-
-
-def android_path(*args):
- top = os.path.realpath(os.path.join(THIS_DIR, '../../..'))
- return os.path.normpath(os.path.join(top, *args))
-
-
-def sysroot_path(toolchain):
- arch = toolchain_to_arch(toolchain)
- # Only ARM has more than one ABI, and they both have the same minimum
- # platform level.
- abi = arch_to_abis(arch)[0]
- version = minimum_platform_level(abi)
-
- prebuilt_ndk = 'prebuilts/ndk/current'
- sysroot_subpath = 'platforms/android-{}/arch-{}'.format(version, arch)
- return android_path(prebuilt_ndk, sysroot_subpath)
-
-
-def ndk_path(*args):
- return android_path('ndk', *args)
-
-
-def toolchain_path(*args):
- return android_path('toolchain', *args)
+ import ndk.abis
+ return ndk.abis.min_api_for_abi(abi)
def jobs_arg():
@@ -141,60 +82,6 @@ def build(cmd, args, intermediate_package=False):
subprocess.check_call(cmd + common_args, env=build_env)
-def _get_dir_from_env(default, env_var):
- path = os.path.realpath(os.getenv(env_var, default))
- if not os.path.isdir(path):
- os.makedirs(path)
- return path
-
-
-def get_out_dir():
- return _get_dir_from_env(android_path('out'), 'OUT_DIR')
-
-
-def get_dist_dir(out_dir):
- return _get_dir_from_env(os.path.join(out_dir, 'dist'), 'DIST_DIR')
-
-
-def get_default_host():
- if sys.platform in ('linux', 'linux2'):
- return 'linux'
- elif sys.platform == 'darwin':
- return 'darwin'
- elif sys.platform == 'win32':
- return 'windows'
- else:
- raise RuntimeError('Unsupported host: {}'.format(sys.platform))
-
-
-def host_to_tag(host):
- if host in ['darwin', 'linux']:
- return host + '-x86_64'
- elif host == 'windows':
- return 'windows'
- elif host == 'windows64':
- return 'windows-x86_64'
- else:
- raise RuntimeError('Unsupported host: {}'.format(host))
-
-
-def make_repo_prop(out_dir):
- file_name = 'repo.prop'
-
- dist_dir = os.environ.get('DIST_DIR')
- if dist_dir is not None:
- dist_repo_prop = os.path.join(dist_dir, file_name)
- shutil.copy(dist_repo_prop, out_dir)
- else:
- out_file = os.path.join(out_dir, file_name)
- with open(out_file, 'w') as prop_file:
- cmd = [
- 'repo', 'forall', '-c',
- 'echo $REPO_PROJECT $(git rev-parse HEAD)',
- ]
- subprocess.check_call(cmd, stdout=prop_file)
-
-
def make_package(name, directory, out_dir):
"""Pacakges an NDK module for release.