aboutsummaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-08-31 13:00:22 -0700
committerDan Albert <danalbert@google.com>2015-08-31 13:00:22 -0700
commit03a2b1ea38e98822e6b4d9e4945130dbe0a30219 (patch)
tree2eaad30879407b37de53869c0e9a64faeeb2335f /sources
parent972284ee14b5036c4856d5c46f5b5068cb906edb (diff)
downloadndk-03a2b1ea38e98822e6b4d9e4945130dbe0a30219.tar.gz
Move toolbox build script to its source directory.
Change-Id: I5d0f0c0bbfbb2c64df3f8f6dd37e31068de0c53c
Diffstat (limited to 'sources')
-rwxr-xr-xsources/host-tools/toolbox/build-toolbox.sh123
-rwxr-xr-xsources/host-tools/toolbox/build.py46
2 files changed, 169 insertions, 0 deletions
diff --git a/sources/host-tools/toolbox/build-toolbox.sh b/sources/host-tools/toolbox/build-toolbox.sh
new file mode 100755
index 000000000..2473bbf7a
--- /dev/null
+++ b/sources/host-tools/toolbox/build-toolbox.sh
@@ -0,0 +1,123 @@
+#!/bin/sh
+#
+# Copyright (C) 2011 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.
+#
+# This shell script is used to rebuild the toolbox programs which sources
+# are under $NDK/sources/host-tools/toolbox
+#
+
+# include common function and variable definitions
+. $NDK_BUILDTOOLS_PATH/prebuilt-common.sh
+. $NDK_BUILDTOOLS_PATH/builder-funcs.sh
+
+PROGRAM_PARAMETERS=""
+
+PROGRAM_DESCRIPTION=\
+"Rebuild the prebuilt host toolbox binaries for the Android NDK.
+
+These are simple command-line programs used by the NDK build script.
+
+By default, this will try to place the binaries inside the current NDK
+directory, unless you use the --ndk-dir=<path> option.
+"
+
+PACKAGE_DIR=
+register_var_option "--package-dir=<path>" PACKAGE_DIR "Put prebuilt tarballs into <path>."
+
+NDK_DIR=
+register_var_option "--ndk-dir=<path>" NDK_DIR "Specify NDK root path for the build."
+
+BUILD_DIR=
+OPTION_BUILD_DIR=
+register_var_option "--build-dir=<path>" OPTION_BUILD_DIR "Specify temporary build dir."
+
+NO_MAKEFILE=
+register_var_option "--no-makefile" NO_MAKEFILE "Do not use makefile to speed-up build"
+
+PACKAGE_DIR=
+register_var_option "--package-dir=<path>" PACKAGE_DIR "Archive binaries into package directory"
+
+register_jobs_option
+register_try64_option
+
+extract_parameters "$@"
+
+# Handle NDK_DIR
+if [ -z "$NDK_DIR" ] ; then
+ NDK_DIR=$ANDROID_NDK_ROOT
+ log "Auto-config: --ndk-dir=$NDK_DIR"
+else
+ if [ ! -d "$NDK_DIR" ] ; then
+ echo "ERROR: NDK directory does not exists: $NDK_DIR"
+ exit 1
+ fi
+fi
+
+if [ -z "$OPTION_BUILD_DIR" ]; then
+ BUILD_DIR=$NDK_TMPDIR/build-toolbox
+ log "Auto-config: --build-dir=$BUILD_DIR"
+ rm -rf $BUILD_DIR/* && mkdir -p $BUILD_DIR
+else
+ BUILD_DIR=$OPTION_BUILD_DIR
+fi
+mkdir -p "$BUILD_DIR"
+fail_panic "Could not create build directory: $BUILD_DIR"
+
+if [ -z "$NO_MAKEFILE" ]; then
+ MAKEFILE=$BUILD_DIR/Makefile
+else
+ MAKEFILE=
+fi
+
+TOOLBOX_SRCDIR=$ANDROID_NDK_ROOT/sources/host-tools/toolbox
+
+BUILD_WINDOWS_SOURCES=yes
+
+if [ "$BUILD_WINDOWS_SOURCES" ]; then
+ ORIGINAL_HOST_TAG=$HOST_TAG
+ MINGW=yes
+ handle_canadian_build
+ prepare_canadian_toolchain $BUILD_DIR
+
+ SUBDIR=$(get_prebuilt_install_prefix $HOST_TAG)/bin
+ DSTDIR=$NDK_DIR/$SUBDIR
+ mkdir -p "$DSTDIR"
+ fail_panic "Could not create destination directory: $DSTDIR"
+
+ # Build echo.exe
+ HOST_TAG=$ORIGINAL_HOST_TAG
+ builder_begin_host "$BUILD_DIR" "$MAKEFILE"
+ builder_set_srcdir "$TOOLBOX_SRCDIR"
+ builder_set_dstdir "$DSTDIR"
+ builder_sources echo_win.c
+ builder_host_executable echo
+ builder_end
+
+ # Build cmp.exe
+ HOST_TAG=$ORIGINAL_HOST_TAG
+ builder_begin_host "$BUILD_DIR" "$MAKEFILE"
+ builder_set_srcdir "$TOOLBOX_SRCDIR"
+ builder_set_dstdir "$DSTDIR"
+ builder_sources cmp_win.c
+ builder_host_executable cmp
+ builder_end
+
+ if [ "$PACKAGE_DIR" ]; then
+ ARCHIVE=toolbox-$HOST_TAG.tar.bz2
+ dump "Packaging : $ARCHIVE"
+ pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR/echo.exe" "$SUBDIR/cmp.exe"
+ fail_panic "Could not package toolbox binaires"
+ fi
+fi
diff --git a/sources/host-tools/toolbox/build.py b/sources/host-tools/toolbox/build.py
new file mode 100755
index 000000000..618281433
--- /dev/null
+++ b/sources/host-tools/toolbox/build.py
@@ -0,0 +1,46 @@
+#!/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.
+#
+"""Builds NDK toolbox.
+
+Toolbox is just a POSIX compatible cmp.exe and echo.exe for Windows.
+"""
+from __future__ import print_function
+
+import os
+import site
+import sys
+
+site.addsitedir(os.path.join(os.path.dirname(__file__), '../../../build/lib'))
+
+import build_support
+
+
+def main(args):
+ if args.host not in ('windows', 'windows64'):
+ sys.exit('Toolbox is only for Windows hosts.')
+
+ build_cmd = [
+ 'bash', 'build-toolbox.sh',
+ ]
+
+ if args.host != 'windows':
+ build_cmd.append('--try-64')
+
+ build_support.build(build_cmd, args)
+
+if __name__ == '__main__':
+ build_support.run(main)