示例#1
0
def select_llvm_cpp_compiler(platform, native_toolchain):
    original_llvm_cpp_compiler = yield Get(LLVMCppCompiler, LLVM,
                                           native_toolchain._llvm)
    provided_clangpp = original_llvm_cpp_compiler.cpp_compiler

    if platform.normalized_os_name == 'darwin':
        xcode_clang = yield Get(CppCompiler, XCodeCLITools,
                                native_toolchain._xcode_cli_tools)
        clang_with_xcode_paths = CppCompiler(
            path_entries=(provided_clangpp.path_entries +
                          xcode_clang.path_entries),
            exe_filename=provided_clangpp.exe_filename,
            library_dirs=(provided_clangpp.library_dirs +
                          xcode_clang.library_dirs),
            include_dirs=(xcode_clang.include_dirs +
                          provided_clangpp.include_dirs))
        final_llvm_cpp_compiler = LLVMCppCompiler(clang_with_xcode_paths)
    else:
        gcc_cpp_compiler = yield Get(GCCCppCompiler, GCC,
                                     native_toolchain._gcc)
        provided_gpp = gcc_cpp_compiler.cpp_compiler
        clang_with_gpp_libs = CppCompiler(
            path_entries=provided_clangpp.path_entries,
            exe_filename=provided_clangpp.exe_filename,
            # We need this version of GLIBCXX to be able to run, unfortunately.
            library_dirs=(provided_gpp.library_dirs +
                          provided_clangpp.library_dirs),
            include_dirs=(provided_clangpp.include_dirs +
                          provided_gpp.include_dirs))
        final_llvm_cpp_compiler = LLVMCppCompiler(clang_with_gpp_libs)

    yield final_llvm_cpp_compiler
示例#2
0
 def cpp_compiler(self, platform):
     return CppCompiler(
         path_entries=self.path_entries,
         exe_filename='g++',
         runtime_library_dirs=self._common_lib_dirs(platform),
         include_dirs=(self._common_include_dirs + self._cpp_include_dirs),
         extra_args=[])
示例#3
0
 def cpp_compiler(self):
     return CppCompiler(path_entries=self.path_entries,
                        exe_filename='clang++',
                        library_dirs=self._common_lib_dirs,
                        include_dirs=(self._cpp_include_dirs +
                                      self._common_include_dirs),
                        extra_args=[])
示例#4
0
def select_gcc_cpp_compiler(platform, native_toolchain):
    original_gcc_cpp_compiler = yield Get(GCCCppCompiler, GCC,
                                          native_toolchain._gcc)
    provided_gpp = original_gcc_cpp_compiler.cpp_compiler

    if platform.normalized_os_name == 'darwin':
        xcode_tools_assembler = yield Get(Assembler, XCodeCLITools,
                                          native_toolchain._xcode_cli_tools)
        assembler_paths = xcode_tools_assembler.path_entries

        xcode_clangpp = yield Get(CppCompiler, XCodeCLITools,
                                  native_toolchain._xcode_cli_tools)

        new_library_dirs = provided_gpp.library_dirs + xcode_clangpp.library_dirs
        new_include_dirs = xcode_clangpp.include_dirs + provided_gpp.include_dirs
    else:
        binutils_assembler = yield Get(Assembler, Binutils,
                                       native_toolchain._binutils)
        assembler_paths = binutils_assembler.path_entries

        new_library_dirs = provided_gpp.library_dirs
        new_include_dirs = provided_gpp.include_dirs

    gcc_with_assembler = CppCompiler(path_entries=(provided_gpp.path_entries +
                                                   assembler_paths),
                                     exe_filename=provided_gpp.exe_filename,
                                     library_dirs=new_library_dirs,
                                     include_dirs=new_include_dirs)

    final_gcc_cpp_compiler = GCCCppCompiler(gcc_with_assembler)
    yield final_gcc_cpp_compiler
示例#5
0
 def cpp_compiler(self):
     return CppCompiler(
         path_entries=self.path_entries(),
         exe_filename='clang++',
         runtime_library_dirs=self.lib_dirs(),
         include_dirs=self.include_dirs(include_cpp_inc=True),
         extra_args=[MIN_OSX_VERSION_ARG])
示例#6
0
 def cpp_compiler(self):
     exe_filename = 'g++'
     path_entries = self.path_entries()
     return CppCompiler(path_entries=self.path_entries(),
                        exe_filename=exe_filename,
                        library_dirs=self._lib_search_dirs(
                            exe_filename, path_entries),
                        include_dirs=[])
示例#7
0
def select_gcc_cpp_toolchain(platform, native_toolchain):
    provided_gpp = yield Get(CppCompiler, GCC, native_toolchain._gcc)

    # GCC needs an assembler, so we provide that (platform-specific) tool here.
    assembler = yield Get(Assembler, NativeToolchain, native_toolchain)

    if platform.normalized_os_name == 'darwin':
        # GCC needs access to some headers that are only provided by the XCode toolchain
        # currently (e.g. "_stdio.h"). These headers are unlikely to change across versions, so this is
        # probably safe.
        # TODO: we should be providing all of these (so we can eventually phase out XCodeCLITools
        # entirely).
        xcode_clangpp = yield Get(CppCompiler, XCodeCLITools,
                                  native_toolchain._xcode_cli_tools)
        new_include_dirs = xcode_clangpp.include_dirs + provided_gpp.include_dirs
    else:
        new_include_dirs = provided_gpp.include_dirs

    working_cpp_compiler = CppCompiler(
        path_entries=(provided_gpp.path_entries + assembler.path_entries),
        exe_filename=provided_gpp.exe_filename,
        library_dirs=provided_gpp.library_dirs,
        include_dirs=new_include_dirs,
        extra_args=([
            '-x',
            'c++',
            '-std=c++11',
            '-nostdinc++',
        ]))

    base_linker_wrapper = yield Get(BaseLinker, NativeToolchain,
                                    native_toolchain)
    base_linker = base_linker_wrapper.linker
    libc_dev = yield Get(LibcDev, NativeToolchain, native_toolchain)
    working_linker = Linker(
        path_entries=(working_cpp_compiler.path_entries +
                      base_linker.path_entries),
        exe_filename=working_cpp_compiler.exe_filename,
        library_dirs=(base_linker.library_dirs +
                      working_cpp_compiler.library_dirs),
        linking_library_dirs=(base_linker.linking_library_dirs +
                              libc_dev.get_libc_dirs(platform)),
        extra_args=base_linker.extra_args)

    yield GCCCppToolchain(CppToolchain(working_cpp_compiler, working_linker))
示例#8
0
def select_llvm_cpp_toolchain(platform, native_toolchain):
    provided_clangpp = yield Get(CppCompiler, LLVM, native_toolchain._llvm)

    # These arguments are shared across platforms.
    llvm_cpp_compiler_args = [
        '-x',
        'c++',
        '-std=c++11',
        # This mean we don't use any of the headers from our LLVM distribution's C++ stdlib
        # implementation, or any from the host system. Instead, we use include dirs from the
        # XCodeCLITools or GCC.
        '-nobuiltininc',
        '-nostdinc++',
    ]

    if platform.normalized_os_name == 'darwin':
        xcode_clang = yield Get(CppCompiler, XCodeCLITools,
                                native_toolchain._xcode_cli_tools)
        working_cpp_compiler = CppCompiler(
            path_entries=(provided_clangpp.path_entries +
                          xcode_clang.path_entries),
            exe_filename=provided_clangpp.exe_filename,
            library_dirs=(provided_clangpp.library_dirs +
                          xcode_clang.library_dirs),
            include_dirs=(provided_clangpp.include_dirs +
                          xcode_clang.include_dirs),
            # On OSX, this uses the libc++ (LLVM) C++ standard library implementation. This is
            # feature-complete for OSX, but not for Linux (see https://libcxx.llvm.org/ for more info).
            extra_args=(llvm_cpp_compiler_args + xcode_clang.extra_args))
        linking_library_dirs = []
        linker_extra_args = []
    else:
        gcc_install = yield Get(GCCInstallLocationForLLVM, GCC,
                                native_toolchain._gcc)
        provided_gpp = yield Get(CppCompiler, GCC, native_toolchain._gcc)
        working_cpp_compiler = CppCompiler(
            path_entries=provided_clangpp.path_entries,
            exe_filename=provided_clangpp.exe_filename,
            # We need g++'s version of the GLIBCXX library to be able to run, unfortunately.
            library_dirs=(provided_gpp.library_dirs +
                          provided_clangpp.library_dirs),
            # NB: we use g++'s headers on Linux, and therefore their C++ standard library.
            include_dirs=provided_gpp.include_dirs,
            extra_args=(llvm_cpp_compiler_args + gcc_install.as_clang_argv))
        linking_library_dirs = provided_gpp.library_dirs + provided_clangpp.library_dirs
        # Ensure we use libstdc++, provided by g++, during the linking stage.
        linker_extra_args = ['-stdlib=libstdc++']

    libc_dev = yield Get(LibcDev, NativeToolchain, native_toolchain)
    base_linker_wrapper = yield Get(BaseLinker, NativeToolchain,
                                    native_toolchain)
    base_linker = base_linker_wrapper.linker
    working_linker = Linker(
        path_entries=(base_linker.path_entries +
                      working_cpp_compiler.path_entries),
        exe_filename=working_cpp_compiler.exe_filename,
        library_dirs=(base_linker.library_dirs +
                      working_cpp_compiler.library_dirs),
        linking_library_dirs=(base_linker.linking_library_dirs +
                              linking_library_dirs +
                              libc_dev.get_libc_dirs(platform)),
        extra_args=(base_linker.extra_args + linker_extra_args))

    yield LLVMCppToolchain(CppToolchain(working_cpp_compiler, working_linker))
示例#9
0
文件: llvm.py 项目: shuoli84/pants
 def cpp_compiler(self, platform):
     return CppCompiler(path_entries=self.path_entries(),
                        exe_filename='clang++',
                        platform=platform)
示例#10
0
文件: gcc.py 项目: shuoli84/pants
 def cpp_compiler(self, platform):
     return CppCompiler(
         path_entries=self._path_entries_for_platform(platform),
         exe_filename='g++',
         platform=platform)
示例#11
0
 def cpp_compiler(self):
     return CppCompiler(path_entries=self.path_entries(),
                        exe_filename='clang++',
                        library_dirs=self.lib_dirs(),
                        include_dirs=self.include_dirs())