Esempio n. 1
0
 def test_format_library_paths(self):
     self.assertEqual(['-Lpath1', '-L"with spaces"'],
                      format_library_paths(['path1', 'with spaces'],
                                           MockSettings({})))
     self.assertEqual(['-LIBPATH:path1', '-LIBPATH:"with spaces"'],
                      format_library_paths(
                          ['path1', 'with spaces'],
                          MockSettings({"compiler": "Visual Studio"})))
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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)
Esempio n. 5
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
Esempio n. 6
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)
Esempio n. 7
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
Esempio n. 8
0
 def test_format_library_paths(self):
     self.assertEquals(['-Lpath1', '-L"with spaces"'],
                       format_library_paths(['path1', 'with spaces']))
     self.assertEquals(['-LIBPATH:path1', '-LIBPATH:"with spaces"'],
                       format_library_paths(['path1', 'with spaces'],
                                            compiler='Visual Studio'))
Esempio n. 9
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)
Esempio n. 10
0
 def test_format_library_paths(self):
     self.assertEquals(['-Lpath1', '-L"with spaces"'], format_library_paths(['path1', 'with spaces']))
     self.assertEquals(['-LIBPATH:path1', '-LIBPATH:"with spaces"'],
                       format_library_paths(['path1', 'with spaces'], compiler='Visual Studio'))