diff options
author | Dan Albert <danalbert@google.com> | 2015-08-28 13:06:43 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2015-08-28 13:06:43 -0700 |
commit | 66fe4c3e70d45cbb2b3081e7f37634ea976b2dce (patch) | |
tree | 65b97141d378b8131c12bab67d4eb73101c588b0 | |
parent | e2c6a2756cc96f570889c196b1caf413181e2fb3 (diff) | |
download | yasm-66fe4c3e70d45cbb2b3081e7f37634ea976b2dce.tar.gz |
Fix up build-yasm.sh to build standalone.
Change-Id: I1d4a38f6f387b19b4803d05d490ea62ce09465c1
-rwxr-xr-x | build-yasm.sh | 6 | ||||
-rwxr-xr-x | build.py | 90 |
2 files changed, 93 insertions, 3 deletions
diff --git a/build-yasm.sh b/build-yasm.sh index 2356f7c9..43cf9661 100755 --- a/build-yasm.sh +++ b/build-yasm.sh @@ -18,7 +18,7 @@ # at the right location PROGDIR=$(dirname $0) -. $PROGDIR/prebuilt-common.sh +. $NDK_BUILDTOOLS_PATH/prebuilt-common.sh PROGRAM_PARAMETERS="<src-dir> <ndk-dir>" PROGRAM_DESCRIPTION=\ @@ -132,7 +132,7 @@ find $BUILD_OUT/prefix/bin -maxdepth 1 -type f -exec $STRIP {} \; log "Copying yasm" #run copy_directory "$BUILD_OUT/prefix" "$(get_prebuilt_install_prefix)" SUBDIR=$(get_prebuilt_host_exec yasm) -OUT=$NDK_DIR/$SUBDIR +OUT=$TMPDIR/$SUBDIR run mkdir -p $(dirname "$OUT") && cp $BUILD_OUT/prefix/bin/$(get_host_exec_name yasm) $OUT fail_panic "Could not copy yasm" @@ -140,7 +140,7 @@ if [ "$PACKAGE_DIR" ]; then ARCHIVE=ndk-yasm-$HOST_TAG.tar.bz2 dump "Packaging: $ARCHIVE" mkdir -p "$PACKAGE_DIR" && - pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR" + pack_archive "$PACKAGE_DIR/$ARCHIVE" "$TMPDIR" "$SUBDIR" fail_panic "Could not package archive: $PACKAGE_DIR/$ARCHIVE" fi diff --git a/build.py b/build.py new file mode 100755 index 00000000..40f326c1 --- /dev/null +++ b/build.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python +# +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from __future__ import print_function + +import argparse +import os +import subprocess +import sys + + +def android_path(path=''): + top = os.getenv('ANDROID_BUILD_TOP', '') + return os.path.realpath(os.path.join(top, path)) + + +def get_default_package_dir(): + return android_path('out/ndk') + + +def get_default_host(): + if sys.platform in ('linux', 'linux2'): + return 'linux' + elif sys.platform == 'darwin': + return 'darwin' + else: + raise RuntimeError('Unsupported host: {}'.format(sys.platform)) + + +class ArgParser(argparse.ArgumentParser): + def __init__(self): + super(ArgParser, self).__init__( + description='Builds GCC for Android.') + + self.add_argument( + '--host', choices=('darwin', 'linux', 'windows', 'windows64'), + default=get_default_host(), + help='Build binaries for given OS (e.g. linux).') + self.add_argument( + '--package-dir', help='Directory to place the packaged GCC.', + default=get_default_package_dir()) + + +def main(): + args = ArgParser().parse_args() + + if 'ANDROID_BUILD_TOP' not in os.environ: + top = os.path.join(os.path.dirname(__file__), '../..') + os.environ['ANDROID_BUILD_TOP'] = os.path.realpath(top) + + os.chdir(android_path('toolchain/yasm')) + + toolchain_path = android_path('toolchain') + ndk_path = android_path('ndk') + + package_dir_arg = '--package-dir={}'.format(args.package_dir) + + ndk_build_tools_path = android_path('ndk/build/tools') + build_env = dict(os.environ) + build_env['NDK_BUILDTOOLS_PATH'] = ndk_build_tools_path + build_env['ANDROID_NDK_ROOT'] = ndk_path + + build_cmd = [ + 'bash', 'build-yasm.sh', toolchain_path, ndk_path, + package_dir_arg, '--verbose', + ] + + if args.host in ('windows', 'windows64'): + build_cmd.append('--mingw') + + if args.host != 'windows': + build_cmd.append('--try-64') + + subprocess.check_call(build_cmd, env=build_env) + +if __name__ == '__main__': + main() |