Пример #1
0
def select_llvm_c_compiler(platform, native_toolchain):
    original_llvm_c_compiler = yield Get(LLVMCCompiler, LLVM,
                                         native_toolchain._llvm)
    provided_clang = original_llvm_c_compiler.c_compiler

    if platform.normalized_os_name == 'darwin':
        xcode_clang = yield Get(CCompiler, XCodeCLITools,
                                native_toolchain._xcode_cli_tools)
        clang_with_xcode_paths = CCompiler(
            path_entries=(provided_clang.path_entries +
                          xcode_clang.path_entries),
            exe_filename=provided_clang.exe_filename,
            library_dirs=(provided_clang.library_dirs +
                          xcode_clang.library_dirs),
            include_dirs=(xcode_clang.include_dirs +
                          provided_clang.include_dirs))
        final_llvm_c_compiler = LLVMCCompiler(clang_with_xcode_paths)
    else:
        gcc_c_compiler = yield Get(GCCCCompiler, GCC, native_toolchain._gcc)
        provided_gcc = gcc_c_compiler.c_compiler
        clang_with_gcc_libs = CCompiler(
            path_entries=provided_clang.path_entries,
            exe_filename=provided_clang.exe_filename,
            # We need this version of GLIBCXX to be able to run, unfortunately.
            library_dirs=(provided_gcc.library_dirs +
                          provided_clang.library_dirs),
            include_dirs=(provided_clang.include_dirs +
                          provided_gcc.include_dirs))
        final_llvm_c_compiler = LLVMCCompiler(clang_with_gcc_libs)

    yield final_llvm_c_compiler
Пример #2
0
def select_llvm_c_toolchain(platform, native_toolchain):
    provided_clang = yield Get(CCompiler, LLVM, native_toolchain._llvm)

    # These arguments are shared across platforms.
    llvm_c_compiler_args = [
        '-x',
        'c',
        '-std=c11',
        '-nobuiltininc',
    ]

    if platform.normalized_os_name == 'darwin':
        xcode_clang = yield Get(CCompiler, XCodeCLITools,
                                native_toolchain._xcode_cli_tools)
        working_c_compiler = CCompiler(
            path_entries=(provided_clang.path_entries +
                          xcode_clang.path_entries),
            exe_filename=provided_clang.exe_filename,
            library_dirs=(provided_clang.library_dirs +
                          xcode_clang.library_dirs),
            include_dirs=(provided_clang.include_dirs +
                          xcode_clang.include_dirs),
            extra_args=(llvm_c_compiler_args + xcode_clang.extra_args))
    else:
        gcc_install = yield Get(GCCInstallLocationForLLVM, GCC,
                                native_toolchain._gcc)
        provided_gcc = yield Get(CCompiler, GCC, native_toolchain._gcc)
        working_c_compiler = CCompiler(
            path_entries=provided_clang.path_entries,
            exe_filename=provided_clang.exe_filename,
            # We need g++'s version of the GLIBCXX library to be able to run, unfortunately.
            library_dirs=(provided_gcc.library_dirs +
                          provided_clang.library_dirs),
            include_dirs=provided_gcc.include_dirs,
            extra_args=(llvm_c_compiler_args + gcc_install.as_clang_argv))

    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=(base_linker.path_entries +
                      working_c_compiler.path_entries),
        exe_filename=working_c_compiler.exe_filename,
        library_dirs=(base_linker.library_dirs +
                      working_c_compiler.library_dirs),
        linking_library_dirs=(base_linker.linking_library_dirs +
                              libc_dev.get_libc_dirs(platform)),
        extra_args=base_linker.extra_args)

    yield LLVMCToolchain(CToolchain(working_c_compiler, working_linker))
Пример #3
0
 def c_compiler(self, platform):
   return CCompiler(
     path_entries=self.path_entries,
     exe_filename='gcc',
     runtime_library_dirs=self._common_lib_dirs(platform),
     include_dirs=self._common_include_dirs,
     extra_args=[])
Пример #4
0
 def c_compiler(self) -> CCompiler:
   return CCompiler(
     path_entries=self.path_entries,
     exe_filename='clang',
     runtime_library_dirs=self._common_lib_dirs,
     include_dirs=self._common_include_dirs,
     extra_args=())
Пример #5
0
 def c_compiler(self):
   return CCompiler(
     path_entries=self.path_entries(),
     exe_filename='clang',
     runtime_library_dirs=self.lib_dirs(),
     include_dirs=self.include_dirs(),
     extra_args=[MIN_OSX_VERSION_ARG])
Пример #6
0
 def c_compiler(self, platform: Platform) -> CCompiler:
     return CCompiler(
         path_entries=self.path_entries,
         exe_filename="gcc",
         runtime_library_dirs=self._common_lib_dirs(platform),
         include_dirs=self._common_include_dirs,
         extra_args=(),
     )
Пример #7
0
 def c_compiler(self) -> CCompiler:
     return CCompiler(
         path_entries=self.path_entries(),
         exe_filename="clang",
         runtime_library_dirs=self.lib_dirs(),
         include_dirs=self.include_dirs(),
         extra_args=(MIN_OSX_VERSION_ARG, ),
     )
Пример #8
0
 def c_compiler(self):
     exe_filename = 'gcc'
     path_entries = self.path_entries()
     return CCompiler(path_entries=path_entries,
                      exe_filename=exe_filename,
                      library_dirs=self._lib_search_dirs(
                          exe_filename, path_entries),
                      include_dirs=[])
Пример #9
0
def select_gcc_c_toolchain(platform, native_toolchain):
    provided_gcc = yield Get(CCompiler, 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_clang = yield Get(CCompiler, XCodeCLITools,
                                native_toolchain._xcode_cli_tools)
        new_include_dirs = xcode_clang.include_dirs + provided_gcc.include_dirs
    else:
        new_include_dirs = provided_gcc.include_dirs

    working_c_compiler = CCompiler(path_entries=(provided_gcc.path_entries +
                                                 assembler.path_entries),
                                   exe_filename=provided_gcc.exe_filename,
                                   library_dirs=provided_gcc.library_dirs,
                                   include_dirs=new_include_dirs,
                                   extra_args=['-x', 'c', '-std=c11'])

    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_c_compiler.path_entries +
                      base_linker.path_entries),
        exe_filename=working_c_compiler.exe_filename,
        library_dirs=(base_linker.library_dirs +
                      working_c_compiler.library_dirs),
        linking_library_dirs=(base_linker.linking_library_dirs +
                              libc_dev.get_libc_dirs(platform)),
        extra_args=base_linker.extra_args)

    yield GCCCToolchain(CToolchain(working_c_compiler, working_linker))
Пример #10
0
def select_gcc_c_compiler(platform, native_toolchain):
    original_gcc_c_compiler = yield Get(GCCCCompiler, GCC,
                                        native_toolchain._gcc)
    provided_gcc = original_gcc_c_compiler.c_compiler

    # GCC needs an assembler, so we provide that (platform-specific) tool here.
    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

        # 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).
        # This mutual recursion with select_llvm_c_compiler() works because we only pull in gcc in that
        # method if we are on Linux.
        xcode_clang = yield Get(CCompiler, XCodeCLITools,
                                native_toolchain._xcode_cli_tools)

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

        new_library_dirs = provided_gcc.library_dirs
        new_include_dirs = provided_gcc.include_dirs

    gcc_with_assembler = CCompiler(path_entries=(provided_gcc.path_entries +
                                                 assembler_paths),
                                   exe_filename=provided_gcc.exe_filename,
                                   library_dirs=new_library_dirs,
                                   include_dirs=new_include_dirs)

    final_gcc_c_compiler = GCCCCompiler(gcc_with_assembler)
    yield final_gcc_c_compiler
Пример #11
0
 def c_compiler(self, platform):
     return CCompiler(path_entries=self.path_entries(),
                      exe_filename='clang',
                      platform=platform)
Пример #12
0
 def c_compiler(self, platform):
     return CCompiler(
         path_entries=self._path_entries_for_platform(platform),
         exe_filename='gcc',
         platform=platform)
Пример #13
0
 def c_compiler(self):
     return CCompiler(path_entries=self.path_entries(),
                      exe_filename='clang',
                      library_dirs=self.lib_dirs(),
                      include_dirs=self.include_dirs())