Home | History | Annotate | Download | only in llvm-libc++
      1 #!/usr/bin/env python
      2 #
      3 # Copyright (C) 2015 The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #      http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 #
     17 """Builds libc++ for Android."""
     18 from __future__ import print_function
     19 
     20 import os
     21 import site
     22 
     23 site.addsitedir(os.path.join(os.path.dirname(__file__), '../../../build/lib'))
     24 
     25 import build_support
     26 
     27 
     28 class ArgParser(build_support.ArgParser):
     29     def __init__(self):
     30         super(ArgParser, self).__init__()
     31 
     32         self.add_argument(
     33             '--arch', choices=build_support.ALL_ARCHITECTURES,
     34             help='Architectures to build. Builds all if not present.')
     35 
     36 
     37 def main(args):
     38     arches = build_support.ALL_ARCHITECTURES
     39     if args.arch is not None:
     40         arches = [args.arch]
     41 
     42     abis = []
     43     for arch in arches:
     44         abis.extend(build_support.arch_to_abis(arch))
     45 
     46     print('Building libc++ for ABIs: {}'.format(' '.join(abis)))
     47 
     48     abis_arg = '--abis={}'.format(','.join(abis))
     49     ndk_dir_arg = '--ndk-dir={}'.format(build_support.ndk_path())
     50     script = build_support.ndk_path('build/tools/build-cxx-stl.sh')
     51     build_cmd = [
     52         'bash', script, '--stl=libc++-libc++abi', abis_arg, ndk_dir_arg,
     53         build_support.jobs_arg(), build_support.toolchain_path(),
     54         '--with-debug-info', '--llvm-version=3.6',
     55     ]
     56 
     57     build_support.build(build_cmd, args)
     58 
     59 if __name__ == '__main__':
     60     build_support.run(main, ArgParser)
     61