def test_ndk(out_dir, args):
    # 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(config.release))

    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)

    use_color = sys.stdin.isatty() and os.name != 'nt'
    results = {}
    for abi in abis:
        test_out_dir = os.path.join(out_dir, 'test', abi)
        results[abi], _ = tests.runners.run_single_configuration(
            test_dir,
            test_out_dir,
            tests.printers.StdoutPrinter(use_color=use_color),
            abi,
            'clang',
            suites=['build'])

    print('Results:')
    for abi, result in results.iteritems():
        print('{}: {}'.format(abi, 'PASS' if result else 'FAIL'))
    return all(results.values())
示例#2
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    build_dir = os.path.join(args.out_dir, 'gnustl')

    print('Building libstdc++ for ABIs: {}'.format(' '.join(abis)))
    abis_arg = '--abis={}'.format(','.join(abis))
    ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path())
    build_cmd = [
        'bash',
        'build-gnu-libstdc++.sh',
        abis_arg,
        ndk_dir_arg,
        build_support.jobs_arg(),
        build_support.toolchain_path(),
        '--with-debug-info',
        '--build-dir={}'.format(build_dir),
    ]

    build_support.build(build_cmd, args)
示例#3
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    print('Building stlport for ABIs: {}'.format(' '.join(abis)))

    abis_arg = '--abis={}'.format(','.join(abis))
    ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path())
    script = build_support.ndk_path('build/tools/build-cxx-stl.sh')
    build_cmd = [
        'bash',
        script,
        '--stl=stlport',
        abis_arg,
        ndk_dir_arg,
        build_support.jobs_arg(),
        build_support.toolchain_path(),
        '--with-debug-info',
        '--llvm-version=3.6',
    ]

    build_support.build(build_cmd, args)
示例#4
0
def test_ndk(out_dir, args):
    # 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(config.release))

    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)

    use_color = sys.stdin.isatty() and os.name != 'nt'
    results = {}
    for abi in abis:
        test_out_dir = os.path.join(out_dir, 'test', abi)
        results[abi], _ = tests.runners.run_single_configuration(
            test_dir, test_out_dir,
            tests.printers.StdoutPrinter(use_color=use_color),
            abi, 'clang', suites=['build'])

    print('Results:')
    for abi, result in results.iteritems():
        print('{}: {}'.format(abi, 'PASS' if result else 'FAIL'))
    return all(results.values())
示例#5
0
def test_ndk(out_dir, args):
    release = args.release
    if args.release is None:
        release = datetime.date.today().strftime('%Y%m%d')

    # 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))

    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)

    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())
示例#6
0
文件: build.py 项目: jcai/android-ndk
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    print('Building libc++ for ABIs: {}'.format(' '.join(abis)))

    abis_arg = '--abis={}'.format(','.join(abis))
    ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path())
    script = build_support.ndk_path('build/tools/build-cxx-stl.sh')
    build_cmd = [
        'bash', script, '--stl=libc++-libc++abi', abis_arg, ndk_dir_arg,
        build_support.jobs_arg(), build_support.toolchain_path(),
        '--with-debug-info', '--llvm-version=3.6',
    ]

    build_support.build(build_cmd, args)
示例#7
0
def expand_packages(package, host, arches):
    """Expands package definition tuple into list of full package names.

    >>> expand_packages('gcc-{arch}-{host}', 'linux', ['arm64', 'x86_64'])
    ['gcc-arm64-linux-x86_64', 'gcc-x86_64-linux-x86_64']

    >>> expand_packages('gcclibs-{arch}', 'linux', ['arm64', 'x86_64'])
    ['gcclibs-arm64', 'gcclibs-x86_64']

    >>> expand_packages('llvm-{host}', 'linux', ['arm'])
    ['llvm-linux-x86_64']

    >>> expand_packages('platforms', 'linux', ['arm'])
    ['platforms']

    >>> expand_packages('libc++-{abi}', 'linux', ['arm'])
    ['libc++-armeabi', 'libc++-armeabi-v7a']

    >>> expand_packages('binutils/{triple}', 'linux', ['arm', 'x86_64'])
    ['binutils/arm-linux-androideabi', 'binutils/x86_64-linux-android']

    >> expand_packages('toolchains/{toolchain}-4.9', 'linux', ['arm', 'x86'])
    ['toolchains/arm-linux-androideabi-4.9', 'toolchains/x86-4.9']
    """
    host_tag = build_support.host_to_tag(host)
    seen_packages = set()
    packages = []
    for arch in arches:
        triple = build_support.arch_to_triple(arch)
        toolchain = build_support.arch_to_toolchain(arch)
        for abi in build_support.arch_to_abis(arch):
            expanded = package.format(abi=abi,
                                      arch=arch,
                                      host=host_tag,
                                      triple=triple,
                                      toolchain=toolchain)
            if expanded not in seen_packages:
                packages.append(expanded)
            seen_packages.add(expanded)
    return packages
示例#8
0
def expand_packages(package, host, arches):
    """Expands package definition tuple into list of full package names.

    >>> expand_packages('gcc-{arch}-{host}', 'linux', ['arm64', 'x86_64'])
    ['gcc-arm64-linux-x86_64', 'gcc-x86_64-linux-x86_64']

    >>> expand_packages('gcclibs-{arch}', 'linux', ['arm64', 'x86_64'])
    ['gcclibs-arm64', 'gcclibs-x86_64']

    >>> expand_packages('llvm-{host}', 'linux', ['arm'])
    ['llvm-linux-x86_64']

    >>> expand_packages('platforms', 'linux', ['arm'])
    ['platforms']

    >>> expand_packages('libc++-{abi}', 'linux', ['arm'])
    ['libc++-armeabi', 'libc++-armeabi-v7a', 'libc++-armeabi-v7a-hard']

    >>> expand_packages('binutils/{triple}', 'linux', ['arm', 'x86_64'])
    ['binutils/arm-linux-androideabi', 'binutils/x86_64-linux-android']

    >> expand_packages('toolchains/{toolchain}-4.9', 'linux', ['arm', 'x86'])
    ['toolchains/arm-linux-androideabi-4.9', 'toolchains/x86-4.9']
    """
    host_tag = build_support.host_to_tag(host)
    seen_packages = set()
    packages = []
    for arch in arches:
        triple = build_support.arch_to_triple(arch)
        toolchain = build_support.arch_to_toolchain(arch)
        for abi in build_support.arch_to_abis(arch):
            expanded = package.format(
                abi=abi, arch=arch, host=host_tag, triple=triple,
                toolchain=toolchain)
            if expanded not in seen_packages:
                packages.append(expanded)
            seen_packages.add(expanded)
    return packages
示例#9
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    print("Building libstdc++ for ABIs: {}".format(" ".join(abis)))
    abis_arg = "--abis={}".format(",".join(abis))
    ndk_dir_arg = "--ndk-dir={}".format(build_support.ndk_path())
    build_cmd = [
        "bash",
        "build-gnu-libstdc++.sh",
        abis_arg,
        ndk_dir_arg,
        build_support.jobs_arg(),
        build_support.toolchain_path(),
        "--with-debug-info",
    ]

    build_support.build(build_cmd, args)
示例#10
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    ndk_build = build_support.ndk_path('build/ndk-build')
    prebuilt_ndk = build_support.android_path('prebuilts/ndk/current')
    platforms_root = os.path.join(prebuilt_ndk, 'platforms')
    toolchains_root = os.path.join(prebuilt_ndk, 'toolchains')
    libcxx_path = build_support.android_path('external/libcxx')
    obj_out = os.path.join(args.out_dir, 'libcxx/obj')

    # TODO(danalbert): Stop building to the source directory.
    # This is historical, and simplifies packaging a bit. We need to pack up
    # all the source as well as the libraries. If build_support.make_package
    # were to change to allow a list of directories instead of one directory,
    # we could make this unnecessary.  Will be a follow up CL.
    lib_out = os.path.join(libcxx_path, 'libs')

    build_cmd = [
        'bash',
        ndk_build,
        '-C',
        THIS_DIR,
        build_support.jobs_arg(),
        'V=1',
        'APP_ABI=' + ' '.join(abis),

        # Use the prebuilt platforms and toolchains.
        'NDK_PLATFORMS_ROOT=' + platforms_root,
        'NDK_TOOLCHAINS_ROOT=' + toolchains_root,
        'NDK_NEW_TOOLCHAINS_LAYOUT=true',

        # Tell ndk-build where all of our makefiles are and where outputs
        # should go. The defaults in ndk-build are only valid if we have a
        # typical ndk-build layout with a jni/{Android,Application}.mk.
        'NDK_PROJECT_PATH=null',
        'APP_BUILD_SCRIPT=' + os.path.join(libcxx_path, 'Android.mk'),
        'NDK_APPLICATION_MK=' + os.path.join(libcxx_path, 'Application.mk'),
        'NDK_OUT=' + obj_out,
        'NDK_LIBS_OUT=' + lib_out,

        # Make sure we don't pick up a cached copy.
        'LIBCXX_FORCE_REBUILD=true',
    ]
    print('Building libc++ for ABIs: {}'.format(', '.join(abis)))
    print('Running: ' + ' '.join(build_cmd))
    subprocess.check_call(build_cmd)

    # The static libraries are installed to NDK_OUT, not NDK_LIB_OUT, so we
    # need to install them to our package directory.
    for abi in abis:
        static_lib_dir = os.path.join(obj_out, 'local', abi)
        install_dir = os.path.join(lib_out, abi)
        is_arm = abi.startswith('armeabi')

        if is_arm:
            shutil.copy2(os.path.join(static_lib_dir, 'libunwind.a'),
                         install_dir)

        shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir)
        shutil.copy2(os.path.join(static_lib_dir, 'libandroid_support.a'),
                     install_dir)
        shutil.copy2(os.path.join(static_lib_dir, 'libc++_static.a'),
                     install_dir)

        # Create linker scripts for the libraries we use so that we link things
        # properly even when we're not using ndk-build. The linker will read
        # the script in place of the library so that we link the unwinder and
        # other support libraries appropriately.
        static_libs = ['-lc++_static', '-lc++abi', '-landroid_support']
        if is_arm:
            static_libs.extend(['-lunwind', '-latomic'])
        make_linker_script(os.path.join(install_dir, 'libc++.a'), static_libs)

        shared_libs = ['-landroid_support']
        if is_arm:
            shared_libs.extend(['-lunwind', '-latomic'])
        shared_libs.append('-lc++_shared')
        make_linker_script(os.path.join(install_dir, 'libc++.so'), shared_libs)

    build_support.make_package('libc++', libcxx_path, args.dist_dir)
示例#11
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    ndk_build = build_support.ndk_path('build/ndk-build')
    prebuilt_ndk = build_support.android_path('prebuilts/ndk/current')
    platforms_root = os.path.join(prebuilt_ndk, 'platforms')
    toolchains_root = os.path.join(prebuilt_ndk, 'toolchains')
    libcxx_path = build_support.ndk_path('sources/cxx-stl/llvm-libc++')
    obj_out = os.path.join(args.out_dir, 'libcxx/obj')

    # TODO(danalbert): Stop building to the source directory.
    # This is historical, and simplifies packaging a bit. We need to pack up
    # all the source as well as the libraries. If build_support.make_package
    # were to change to allow a list of directories instead of one directory,
    # we could make this unnecessary.  Will be a follow up CL.
    lib_out = os.path.join(libcxx_path, 'libs')

    build_cmd = [
        'bash', ndk_build, '-C', THIS_DIR, build_support.jobs_arg(), 'V=1',
        'APP_ABI=' + ' '.join(abis),

        # Use the prebuilt platforms and toolchains.
        'NDK_PLATFORMS_ROOT=' + platforms_root,
        'NDK_TOOLCHAINS_ROOT=' + toolchains_root,
        'NDK_NEW_TOOLCHAINS_LAYOUT=true',

        # Tell ndk-build where all of our makefiles are and where outputs
        # should go. The defaults in ndk-build are only valid if we have a
        # typical ndk-build layout with a jni/{Android,Application}.mk.
        'NDK_PROJECT_PATH=null',
        'APP_BUILD_SCRIPT=' + os.path.join(THIS_DIR, 'Android.mk'),
        'NDK_APPLICATION_MK=' + os.path.join(THIS_DIR, 'Application.mk'),
        'NDK_OUT=' + obj_out,
        'NDK_LIBS_OUT=' + lib_out,

        # Make sure we don't pick up a cached copy.
        'LIBCXX_FORCE_REBUILD=true',

        # Put armeabi-v7a-hard in its own directory.
        '_NDK_TESTING_ALL_=yes',
    ]
    print('Building libc++ for ABIs: {}'.format(', '.join(abis)))
    subprocess.check_call(build_cmd)

    # The static libraries are installed to NDK_OUT, not NDK_LIB_OUT, so we
    # need to install them to our package directory.
    for abi in abis:
        static_lib_dir = os.path.join(obj_out, 'local', abi)
        install_dir = os.path.join(lib_out, abi)
        is_arm = abi.startswith('armeabi')

        if is_arm:
            shutil.copy2(
                os.path.join(static_lib_dir, 'libunwind.a'), install_dir)

        shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir)
        shutil.copy2(
            os.path.join(static_lib_dir, 'libandroid_support.a'), install_dir)
        shutil.copy2(
            os.path.join(static_lib_dir, 'libc++_static.a'), install_dir)

    build_support.make_package('libcxx', libcxx_path, args.dist_dir)