diff options
-rwxr-xr-x | ndk/checkbuild.py | 36 | ||||
-rwxr-xr-x | sources/host-tools/make-3.81/build-make.sh | 118 | ||||
-rwxr-xr-x | sources/host-tools/make-3.81/build.py | 45 |
3 files changed, 32 insertions, 167 deletions
diff --git a/ndk/checkbuild.py b/ndk/checkbuild.py index 67a86b1dc..64519cc14 100755 --- a/ndk/checkbuild.py +++ b/ndk/checkbuild.py @@ -38,6 +38,7 @@ import json import logging import multiprocessing import os +from pathlib import Path import pipes import re import shutil @@ -55,6 +56,7 @@ from typing import ( Iterable, Iterator, List, + Optional, Set, TextIO, Tuple, @@ -63,6 +65,7 @@ from typing import ( from build.lib import build_support import ndk.abis +from ndk.autoconf import AutoconfBuilder import ndk.ansi import ndk.builds import ndk.config @@ -582,22 +585,44 @@ class HostTools(ndk.builds.Module): ndk.paths.android_path('toolchain/yasm/GNU_LGPL-2.0'), ] + make_src = ndk.paths.NDK_DIR / 'sources/host-tools/make-3.81' + _make_builder: Optional[AutoconfBuilder] = None + @property def notices(self) -> List[str]: return [ ndk.paths.android_path('toolchain/gdb/gdb-7.11/COPYING'), ndk.paths.android_path('toolchain/python/Python-2.7.5/LICENSE'), - ndk.paths.ndk_path('sources/host-tools/make-3.81/COPYING'), + str(self.make_src / 'COPYING'), ndk.paths.ndk_path('sources/host-tools/toolbox/NOTICE'), ] + self.yasm_notices + @property + def intermediate_out_dir(self) -> Path: + """Path for intermediate outputs of this module.""" + return Path(self.out_dir) / self.host.value + + @property + def make_builder(self) -> AutoconfBuilder: + """Returns the lazily initialized make builder for this module.""" + if self._make_builder is None: + self._make_builder = AutoconfBuilder( + self.make_src / 'configure', + self.intermediate_out_dir / 'make', self.host) + return self._make_builder + + def build_make(self) -> None: + self.make_builder.build([ + "--disable-nls", + "--disable-rpath", + ]) + def build(self) -> None: build_args = ndk.builds.common_build_args(self.out_dir, self.dist_dir, self.host) print('Building make...') - ndk.builds.invoke_external_build( - 'ndk/sources/host-tools/make-3.81/build.py', build_args) + self.build_make() if self.host.is_windows: print('Building toolbox...') @@ -620,7 +645,6 @@ class HostTools(ndk.builds.Module): packages = [ 'gdb-multiarch-7.11', - 'ndk-make', 'ndk-python', 'ndk-yasm', ] @@ -646,6 +670,10 @@ class HostTools(ndk.builds.Module): shutil.copy2( ndk.paths.ndk_path(f), os.path.join(install_dir, 'bin')) + copy_tree( + str(self.make_builder.install_directory), + str(install_dir)) + def install_exe(out_dir: str, install_dir: str, name: str, host: ndk.hosts.Host) -> None: diff --git a/sources/host-tools/make-3.81/build-make.sh b/sources/host-tools/make-3.81/build-make.sh deleted file mode 100755 index 12c8dd415..000000000 --- a/sources/host-tools/make-3.81/build-make.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/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. -# -# Build the host version of the make executable and place it -# at the right location - -PROGDIR=$(dirname $0) -. $NDK_BUILDTOOLS_PATH/prebuilt-common.sh - -PROGRAM_PARAMETERS="" -PROGRAM_DESCRIPTION=\ -"Rebuild the host GNU Make tool used by the NDK." - -NDK_DIR=$ANDROID_NDK_ROOT -register_var_option "--ndk-dir=<path>" NDK_DIR "Install to specific NDK directory" - -register_try64_option -register_canadian_option -register_jobs_option - -OUT= -CUSTOM_OUT= -register_option "--out=<file>" do_out "Specify output executable path" "$OUT" -do_out () { CUSTOM_OUT=true; OUT=$1; } - -GNUMAKE=make -register_var_option "--make=<path>" GNUMAKE "Specify GNU Make program for the build" - -PACKAGE_DIR= -register_var_option "--package-dir=<path>" PACKAGE_DIR "Archive binaries into package directory" - -BUILD_DIR= -register_var_option "--build-dir=<path>" BUILD_DIR "Specify temporary build dir." - -extract_parameters "$@" - -if [ -z "$CUSTOM_OUT" ]; then - SUBDIR=$(get_prebuilt_host_exec make) - OUT=$NDK_DIR/$SUBDIR - log "Auto-config: --out=$OUT" -fi - -GNUMAKE_VERSION=3.81 -GNUMAKE_SRCDIR=$ANDROID_NDK_ROOT/sources/host-tools/make-$GNUMAKE_VERSION -if [ ! -d "$GNUMAKE_SRCDIR" ]; then - echo "ERROR: Can't find make-$GNUMAKE_VERSION source tree: $GNUMAKE_SRCDIR" - exit 1 -fi - -log "Using sources from: $GNUMAKE_SRCDIR" - -prepare_abi_configure_build -prepare_host_build - -TMP_SRCDIR=$BUILD_DIR/src - -# We need to copy the sources to a temporary directory because -# the build system will modify some documentation files in the -# source directory. Sigh... -log "Copying sources to temporary directory: $TMP_SRCDIR" -mkdir -p "$TMP_SRCDIR" && copy_directory "$GNUMAKE_SRCDIR" "$TMP_SRCDIR" -fail_panic "Could not copy GNU Make sources to: $TMP_SRCDIR" - -BUILD_DIR=$BUILD_DIR/build - -CONFIGURE_FLAGS="--disable-nls --disable-rpath" -if [ "$MINGW" = "yes" ]; then - # Required for a proper mingw cross compile - CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --host=i686-w64-mingw32" -fi - -if [ "$DARWIN" = "yes" ]; then - # Required for a proper darwin cross compile - CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --host=$ABI_CONFIGURE_HOST" -fi - -log "Configuring the build" -mkdir -p $BUILD_DIR && rm -rf $BUILD_DIR/* -prepare_canadian_toolchain $BUILD_DIR -cd $BUILD_DIR && -CFLAGS=$HOST_CFLAGS" -O2 -s" && -export CC CFLAGS && -run $TMP_SRCDIR/configure $CONFIGURE_FLAGS --build=$ABI_CONFIGURE_BUILD -fail_panic "Failed to configure the make-$GNUMAKE_VERSION build!" - -log "Building make" -run $GNUMAKE -j $NUM_JOBS -fail_panic "Failed to build the make-$GNUMAKE_VERSION executable!" - -log "Copying executable to prebuilt location" -run mkdir -p $(dirname "$OUT") && cp $(get_host_exec_name make) $OUT -fail_panic "Could not copy executable to: $OUT" - -if [ "$PACKAGE_DIR" ]; then - ARCHIVE=ndk-make-$HOST_TAG.tar.bz2 - dump "Packaging: $ARCHIVE" - mkdir -p "$PACKAGE_DIR" && - pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR" - fail_panic "Could not package archive: $PACKAGE_DIR/$ARCHIVE" -fi - -log "Cleaning up" -rm -rf $BUILD_DIR $TMP_SRCDIR - -log "Done." diff --git a/sources/host-tools/make-3.81/build.py b/sources/host-tools/make-3.81/build.py deleted file mode 100755 index 17178fba1..000000000 --- a/sources/host-tools/make-3.81/build.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/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 make for the NDK.""" -from __future__ import print_function - -import os -import site - -site.addsitedir(os.path.join(os.path.dirname(__file__), '../../../build/lib')) -site.addsitedir(os.path.join(os.path.dirname(__file__), '../../..')) - -# pylint: disable=import-error,wrong-import-position -import build_support -from ndk.hosts import Host -# pylint: enable=import-error,wrong-import-position - - -def main(args): - build_cmd = [ - 'bash', 'build-make.sh', '--try-64', - ] - - if args.host.is_windows: - build_cmd.append('--mingw') - - build_cmd.append('--build-dir=' + os.path.join(args.out_dir, 'make')) - - build_support.build(build_cmd, args, intermediate_package=True) - -if __name__ == '__main__': - build_support.run(main) |