Beispiel #1
0
    def content(self):
        """With compiler_args you can invoke your compiler:
        $ gcc main.c @conanbuildinfo.args -o main
        $ clang main.c @conanbuildinfo.args -o main
        $ cl /EHsc main.c @conanbuildinfo.args
        """
        flags = []
        flags.extend(format_defines(self._deps_build_info.defines))
        flags.extend(format_include_paths(self._deps_build_info.include_paths,
                                          compiler=self.compiler))

        flags.extend(self._deps_build_info.cxxflags)
        flags.extend(self._deps_build_info.cflags)

        arch_flag = architecture_flag(arch=self.conanfile.settings.get_safe("arch"),
                                      os=self.conanfile.settings.get_safe("os"),
                                      compiler=self.compiler)
        if arch_flag:
            flags.append(arch_flag)

        build_type = self.conanfile.settings.get_safe("build_type")
        btfs = build_type_flags(compiler=self.compiler, build_type=build_type,
                                vs_toolset=self.conanfile.settings.get_safe("compiler.toolset"))
        if btfs:
            flags.extend(btfs)
        btd = build_type_define(build_type=build_type)
        if btd:
            flags.extend(format_defines([btd]))

        if self.compiler == "Visual Studio":
            runtime = visual_runtime(self.conanfile.settings.get_safe("compiler.runtime"))
            if runtime:
                flags.append(runtime)
            # Necessary in the "cl" invocation before specify the rest of linker flags
            flags.append(visual_linker_option_separator)

        os_build, _ = get_build_os_arch(self.conanfile)
        if not hasattr(self.conanfile, 'settings_build'):
            os_build = os_build or self.conanfile.settings.get_safe("os")

        flags.extend(rpath_flags(os_build, self.compiler, self._deps_build_info.lib_paths))
        flags.extend(format_library_paths(self._deps_build_info.lib_paths, compiler=self.compiler))
        flags.extend(format_libraries(self._deps_build_info.libs, compiler=self.compiler))
        flags.extend(format_libraries(self._deps_build_info.system_libs, compiler=self.compiler))
        flags.extend(self._deps_build_info.sharedlinkflags)
        flags.extend(self._deps_build_info.exelinkflags)
        flags.extend(self._libcxx_flags())
        flags.extend(format_frameworks(self._deps_build_info.frameworks, compiler=self.compiler))
        flags.extend(format_framework_paths(self._deps_build_info.framework_paths,
                                            compiler=self.compiler))
        flags.append(cppstd_flag(self.conanfile.settings))
        sysrf = sysroot_flag(self._deps_build_info.sysroot, compiler=self.compiler)
        if sysrf:
            flags.append(sysrf)

        return " ".join(flag for flag in flags if flag)
Beispiel #2
0
    def content(self):
        """With compiler_args you can invoke your compiler:
        $ gcc main.c @conanbuildinfo.args -o main
        $ clang main.c @conanbuildinfo.args -o main
        $ cl /EHsc main.c @conanbuildinfo.args
        """
        flags = []
        flags.extend(format_defines(self._deps_build_info.defines))
        flags.extend(format_include_paths(self._deps_build_info.include_paths, compiler=self.compiler))

        flags.extend(self._deps_build_info.cppflags)
        flags.extend(self._deps_build_info.cflags)

        arch_flag = architecture_flag(arch=self.conanfile.settings.get_safe("arch"), compiler=self.compiler)
        if arch_flag:
            flags.append(arch_flag)

        build_type = self.conanfile.settings.get_safe("build_type")
        btfs = build_type_flags(compiler=self.compiler, build_type=build_type,
                                vs_toolset=self.conanfile.settings.get_safe("compiler.toolset"))
        if btfs:
            flags.extend(btfs)
        btd = build_type_define(build_type=build_type)
        if btd:
            flags.extend(format_defines([btd]))

        if self.compiler == "Visual Studio":
            runtime = visual_runtime(self.conanfile.settings.get_safe("compiler.runtime"))
            if runtime:
                flags.append(runtime)
            # Necessary in the "cl" invocation before specify the rest of linker flags
            flags.append(visual_linker_option_separator)

        the_os = (self.conanfile.settings.get_safe("os_build") or
                  self.conanfile.settings.get_safe("os"))
        flags.extend(rpath_flags(the_os, self.compiler, self._deps_build_info.lib_paths))
        flags.extend(format_library_paths(self._deps_build_info.lib_paths, compiler=self.compiler))
        flags.extend(format_libraries(self._deps_build_info.libs, compiler=self.compiler))
        flags.extend(self._deps_build_info.sharedlinkflags)
        flags.extend(self._deps_build_info.exelinkflags)
        flags.extend(self._libcxx_flags())
        flags.append(cppstd_flag(self.conanfile.settings.get_safe("compiler"),
                                 self.conanfile.settings.get_safe("compiler.version"),
                                 self.conanfile.settings.get_safe("cppstd")))
        sysrf = sysroot_flag(self._deps_build_info.sysroot, compiler=self.compiler)
        if sysrf:
            flags.append(sysrf)

        return " ".join(flag for flag in flags if flag)
Beispiel #3
0
    def _get_cl_list(self, quotes=True):
        # FIXME: It should be managed with the compiler_flags module
        # But need further investigation about the quotes and so on, so better to not break anything
        if quotes:
            ret = [
                '%s"%s"' % (include_path_option, lib)
                for lib in self.include_paths
            ]
        else:
            ret = [
                '%s%s' % (include_path_option, lib)
                for lib in self.include_paths
            ]

        runtime = visual_runtime(self._runtime)
        if runtime:
            ret.append(runtime)

        ret.extend(format_defines(self.defines))
        ret.extend(self.flags)
        ret.extend(self.cxx_flags)
        ret.extend(self.link_flags)

        if self.std:
            ret.append(self.std)

        return ret
Beispiel #4
0
    def _get_vars(self):
        def append(*args):
            ret = []
            for arg in args:
                if arg:
                    if isinstance(arg, list):
                        ret.extend(arg)
                    else:
                        ret.append(arg)
            return ret

        lib_paths = format_library_paths(self.library_paths,
                                         win_bash=self._win_bash,
                                         subsystem=self.subsystem,
                                         compiler=self._compiler)
        include_paths = format_include_paths(self.include_paths,
                                             win_bash=self._win_bash,
                                             subsystem=self.subsystem,
                                             compiler=self._compiler)

        ld_flags = append(self.link_flags, lib_paths)
        cpp_flags = append(include_paths, format_defines(self.defines))
        libs = format_libraries(self.libs, compiler=self._compiler)

        tmp_compilation_flags = copy.copy(self.flags)
        if self.fpic:
            tmp_compilation_flags.append(pic_flag(self._compiler))

        cxx_flags = append(tmp_compilation_flags, self.cxx_flags,
                           self.cppstd_flag)
        c_flags = tmp_compilation_flags

        return ld_flags, cpp_flags, libs, cxx_flags, c_flags
    def _get_vars(self):
        def append(*args):
            ret = []
            for arg in args:
                if arg:
                    if isinstance(arg, list):
                        ret.extend(arg)
                    else:
                        ret.append(arg)
            return ret

        lib_paths = format_library_paths(self.library_paths, win_bash=self._win_bash,
                                         subsystem=self.subsystem, compiler=self._compiler)
        include_paths = format_include_paths(self.include_paths, win_bash=self._win_bash,
                                             subsystem=self.subsystem, compiler=self._compiler)

        ld_flags = append(self.link_flags, lib_paths)
        cpp_flags = append(include_paths, format_defines(self.defines))
        libs = format_libraries(self.libs, compiler=self._compiler)

        tmp_compilation_flags = copy.copy(self.flags)
        if self.fpic:
            tmp_compilation_flags.append(pic_flag(self._compiler))

        cxx_flags = append(tmp_compilation_flags, self.cxx_flags, self.cppstd_flag)
        c_flags = tmp_compilation_flags

        return ld_flags, cpp_flags, libs, cxx_flags, c_flags
Beispiel #6
0
 def _configure_flags(self):
     ret = copy.copy(self._deps_cpp_info.cflags)
     btd = build_type_define(build_type=self._build_type)
     if btd:
         ret.extend(format_defines([btd], compiler="Visual Studio"))
     btf = build_type_flag("Visual Studio", build_type=self._build_type)
     if btf:
         ret.append(btf)
     return ret
Beispiel #7
0
    def _libcxx_flags(self, compiler, libcxx):
        lib_flags = []
        if libcxx:
            stdlib_define = libcxx_define(compiler=compiler, libcxx=libcxx)
            lib_flags.extend(format_defines([stdlib_define]))
            cxxf = libcxx_flag(compiler=compiler, libcxx=libcxx)
            if cxxf:
                lib_flags.append(cxxf)

        return lib_flags
Beispiel #8
0
    def _get_vars(self):
        def append(*args):
            ret = []
            for arg in args:
                if arg:
                    if isinstance(arg, list):
                        ret.extend(arg)
                    else:
                        ret.append(arg)
            return ret

        lib_paths = format_library_paths(self.library_paths,
                                         self._conanfile.settings,
                                         win_bash=self._win_bash,
                                         subsystem=self.subsystem)
        include_paths = format_include_paths(self.include_paths,
                                             self._conanfile.settings,
                                             win_bash=self._win_bash,
                                             subsystem=self.subsystem)

        ld_flags = append(self.link_flags, lib_paths)
        cpp_flags = append(include_paths, format_defines(self.defines))
        libs = format_libraries(self.libs, self._conanfile.settings)

        tmp_compilation_flags = copy.copy(self.flags)
        if self.fpic:
            tmp_compilation_flags.append(pic_flag(self._conanfile.settings))
        if tools.is_apple_os(self._os):
            concat = " ".join(tmp_compilation_flags)
            if os.environ.get("CFLAGS", None):
                concat += " " + os.environ.get("CFLAGS", None)
            if os.environ.get("CXXFLAGS", None):
                concat += " " + os.environ.get("CXXFLAGS", None)
            if (self._os_version and "-version-min" not in concat and "-target" not in concat) or \
                    self._os_subsystem:
                tmp_compilation_flags.append(
                    tools.apple_deployment_target_flag(self._os,
                                                       self._os_version,
                                                       self._os_sdk,
                                                       self._os_subsystem,
                                                       self._arch))
            if "-isysroot" not in concat and platform.system() == "Darwin":
                isysroot = tools.XCRun(self._conanfile.settings).sdk_path
                if isysroot:
                    tmp_compilation_flags.extend(["-isysroot", isysroot])
            if "-arch" not in concat and self._arch:
                apple_arch = tools.to_apple_arch(self._arch)
                if apple_arch:
                    tmp_compilation_flags.extend(["-arch", apple_arch])

        cxx_flags = append(tmp_compilation_flags, self.cxx_flags,
                           self.cppstd_flag)
        c_flags = tmp_compilation_flags

        return ld_flags, cpp_flags, libs, cxx_flags, c_flags
Beispiel #9
0
def vs_build_type_flags(settings):
    build_type = settings.get_safe("build_type")
    ret = []
    btd = build_type_define(build_type=build_type)
    if btd:
        ret.extend(format_defines([btd], compiler="Visual Studio"))
    btf = build_type_flag("Visual Studio", build_type=build_type)
    if btf:
        ret.append(btf)

    return ret
Beispiel #10
0
    def _libcxx_flags(self):
        libcxx = self._settings.get_safe("compiler.libcxx")

        lib_flags = []
        if libcxx:
            stdlib_define = libcxx_define(self._settings)
            lib_flags.extend(format_defines([stdlib_define]))
            cxxf = libcxx_flag(self._settings)
            if cxxf:
                lib_flags.append(cxxf)

        return lib_flags
Beispiel #11
0
def vs_build_type_flags(settings):
    build_type = settings.get_safe("build_type")
    ret = []
    btd = build_type_define(build_type=build_type)
    if btd:
        ret.extend(format_defines([btd]))
    btfs = build_type_flags("Visual Studio",
                            build_type=build_type,
                            vs_toolset=settings.get_safe("compiler.toolset"))
    if btfs:
        ret.extend(btfs)

    return ret
Beispiel #12
0
    def _libcxx_flags(self):
        libcxx = self.conanfile.settings.get_safe("compiler.libcxx")
        compiler = self.conanfile.settings.get_safe("compiler")

        lib_flags = []
        if libcxx:
            stdlib_define = libcxx_define(compiler=compiler, libcxx=libcxx)
            lib_flags.extend(format_defines([stdlib_define]))
            cxxf = libcxx_flag(compiler=compiler, libcxx=libcxx)
            if cxxf:
                lib_flags.append(cxxf)

        return lib_flags
Beispiel #13
0
    def _libcxx_flags(self):
        libcxx = self.conanfile.settings.get_safe("compiler.libcxx")
        compiler = self.conanfile.settings.get_safe("compiler")

        lib_flags = []
        if libcxx:
            stdlib_define = libcxx_define(compiler=compiler, libcxx=libcxx)
            lib_flags.extend(format_defines([stdlib_define]))
            cxxf = libcxx_flag(compiler=compiler, libcxx=libcxx)
            if cxxf:
                lib_flags.append(cxxf)

        return lib_flags
Beispiel #14
0
def vs_build_type_flags(settings, with_flags=True):
    build_type = settings.get_safe("build_type")
    ret = []
    btd = build_type_define(build_type=build_type)
    if btd:
        ret.extend(format_defines([btd]))
    if with_flags:
        # When using to build a vs project we don't want to adjust these flags
        btfs = build_type_flags(settings)
        if btfs:
            ret.extend(btfs)

    return ret
Beispiel #15
0
    def _libcxx_flags(self, compiler, libcxx):
        lib_flags = []
        if libcxx:
            if conan_version >= Version("1.26"):
                stdlib_define = libcxx_define(self._settings)
                cxxf = libcxx_flag(self._settings)
            else:
                stdlib_define = libcxx_define(compiler=compiler, libcxx=libcxx)
                cxxf = libcxx_flag(compiler=compiler, libcxx=libcxx)

            lib_flags.extend(format_defines([stdlib_define]))
            if cxxf:
                lib_flags.append(cxxf)

        return lib_flags
Beispiel #16
0
    def _get_vars(self):
        def append(*args):
            ret = []
            for arg in args:
                if arg:
                    if isinstance(arg, list):
                        ret.extend(arg)
                    else:
                        ret.append(arg)
            return ret

        lib_paths = format_library_paths(self.library_paths,
                                         self._conanfile.settings,
                                         win_bash=self._win_bash,
                                         subsystem=self.subsystem)
        include_paths = format_include_paths(self.include_paths,
                                             self._conanfile.settings,
                                             win_bash=self._win_bash,
                                             subsystem=self.subsystem)

        ld_flags = append(self.link_flags, lib_paths)
        cpp_flags = append(include_paths, format_defines(self.defines))
        libs = format_libraries(self.libs, self._conanfile.settings)

        tmp_compilation_flags = copy.copy(self.flags)
        if self.fpic:
            tmp_compilation_flags.append(pic_flag(self._conanfile.settings))
        if tools.is_apple_os(self._os):
            concat = " ".join(tmp_compilation_flags)
            if os.environ.get("CFLAGS", None):
                concat += " " + os.environ.get("CFLAGS", None)
            if os.environ.get("CXXFLAGS", None):
                concat += " " + os.environ.get("CXXFLAGS", None)
            if self._os_version and "-version-min" not in concat and "-target" not in concat:
                tmp_compilation_flags.append(
                    tools.apple_deployment_target_flag(self._os,
                                                       self._os_version))

        cxx_flags = append(tmp_compilation_flags, self.cxx_flags,
                           self.cppstd_flag)
        c_flags = tmp_compilation_flags

        return ld_flags, cpp_flags, libs, cxx_flags, c_flags
Beispiel #17
0
 def test_format_defines(self):
     self.assertEqual(['-DFOO', '-DBAR=1'], format_defines(['FOO', 'BAR=1']))
Beispiel #18
0
    def content(self):
        """With compiler_args you can invoke your compiler:
        $ gcc main.c @conanbuildinfo.args -o main
        $ clang main.c @conanbuildinfo.args -o main
        $ cl /EHsc main.c @conanbuildinfo.args
        """
        flags = []
        flags.extend(
            format_defines(self._deps_build_info.defines,
                           compiler=self.compiler))
        flags.extend(
            format_include_paths(self._deps_build_info.include_paths,
                                 compiler=self.compiler))

        flags.extend(self._deps_build_info.cppflags)
        flags.extend(self._deps_build_info.cflags)

        arch_flag = architecture_flag(
            arch=self.conanfile.settings.get_safe("arch"),
            compiler=self.compiler)
        if arch_flag:
            flags.append(arch_flag)

        build_type = self.conanfile.settings.get_safe("build_type")
        btf = build_type_flag(compiler=self.compiler, build_type=build_type)
        if btf:
            flags.append(btf)
        btd = build_type_define(build_type=build_type)
        if btd:
            flags.extend(format_defines([btd], self.compiler))

        if self.compiler == "Visual Studio":
            runtime = visual_runtime(
                self.conanfile.settings.get_safe("compiler.runtime"))
            if runtime:
                flags.append(runtime)
            # Necessary in the "cl" invocation before specify the rest of linker flags
            flags.append(visual_linker_option_separator)

        the_os = self.conanfile.settings.get_safe("os_build") or \
                 self.conanfile.settings.get_safe("os")
        flags.extend(
            rpath_flags(the_os, self.compiler,
                        self._deps_build_info.lib_paths))
        flags.extend(
            format_library_paths(self._deps_build_info.lib_paths,
                                 compiler=self.compiler))
        flags.extend(
            format_libraries(self._deps_build_info.libs,
                             compiler=self.compiler))
        flags.extend(self._deps_build_info.sharedlinkflags)
        flags.extend(self._deps_build_info.exelinkflags)
        flags.extend(self._libcxx_flags())
        flags.extend(
            cppstd_flag(self.conanfile.settings.get_safe("compiler"),
                        self.conanfile.settings.get_safe("compiler.version"),
                        self.conanfile.settings.get_safe("cppstd")))
        sysrf = sysroot_flag(self._deps_build_info.sysroot,
                             compiler=self.compiler)
        if sysrf:
            flags.append(sysrf)

        return " ".join(flag for flag in flags if flag)
Beispiel #19
0
 def test_format_defines(self):
     self.assertEquals(['-DFOO', '-DBAR=1'], format_defines(['FOO', 'BAR=1']))