예제 #1
0
    def test_build_type_define(self):
        define = build_type_define(build_type='Release')
        self.assertEqual(define, 'NDEBUG')

        define = build_type_define(build_type='Debug')
        self.assertEqual(define, '')

        define = build_type_define(build_type='MinSizeRel')
        self.assertEqual(define, 'NDEBUG')

        define = build_type_define(build_type='RelWithDebInfo')
        self.assertEqual(define, 'NDEBUG')
예제 #2
0
    def __init__(self, conanfile):
        self._conanfile = conanfile
        self._build_type = conanfile.settings.get_safe("build_type")
        self._compiler = conanfile.settings.get_safe("compiler")
        self._compiler_version = conanfile.settings.get_safe(
            "compiler.version")
        self._compiler_runtime = conanfile.settings.get_safe(
            "compiler.runtime")
        self._shared = self._conanfile.options.get_safe("shared")
        self._fpic = self._deduce_fpic()

        self._libcxx_flag = libcxx_flag(conanfile.settings)
        self._cppstd_flag = cppstd_flag(conanfile.settings)
        self._skip_rpath = True if self._conanfile.settings.get_safe(
            "os") == "Macos" else False
        self._arch_flag = architecture_flag(self._conanfile.settings)
        self._build_type_flags = build_type_flags(self._conanfile.settings)

        self._os_host = conanfile.settings.get_safe("os")
        self._arch_host = conanfile.settings.get_safe("arch")
        self._os_target, self._arch_target = get_target_os_arch(conanfile)
        self._arch_build, self._os_build = self._get_build_os_arch()

        self._trip_build, self._trip_host, self._trip_target = self._get_host_build_target_flags(
        )

        self._build_type_define = build_type_define(
            build_type=self._build_type)
        self._glibcxx_define = libcxx_define(self._conanfile.settings)

        self.variables = {}
        self.preprocessor_definitions = {}
예제 #3
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
예제 #4
0
파일: make.py 프로젝트: markushedvall/conan
    def __init__(self, conanfile):
        self._conanfile = conanfile
        self._build_type = conanfile.settings.get_safe("build_type")

        self._build_type_define = build_type_define(build_type=self._build_type)
        self._glibcxx_define = libcxx_define(self._conanfile.settings)

        self.variables = OrderedDict()
        self.preprocessor_definitions = OrderedDict()
예제 #5
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)
예제 #6
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
예제 #7
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
예제 #8
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
예제 #9
0
    def _configure_defines(self):
        # requires declared defines
        ret = copy.copy(self._deps_cpp_info.defines)

        # Debug definition for GCC
        btf = build_type_define(build_type=self._build_type)
        if btf:
            ret.append(btf)

        # CXX11 ABI
        abif = libcxx_define(compiler=self._compiler, libcxx=self._libcxx)
        if abif:
            ret.append(abif)
        return ret
예제 #10
0
    def _configure_defines(self):
        # requires declared defines
        ret = list(self._deps_cpp_info.defines)

        # Debug definition for GCC
        btf = build_type_define(build_type=self._build_type)
        if btf:
            ret.append(btf)

        # CXX11 ABI
        abif = libcxx_define(self._conanfile.settings)
        if abif:
            ret.append(abif)
        return ret
예제 #11
0
    def _configure_defines(self):
        # requires declared defines
        ret = copy.copy(self._deps_cpp_info.defines)

        # Debug definition for GCC
        btf = build_type_define(build_type=self._build_type)
        if btf:
            ret.append(btf)

        # CXX11 ABI
        abif = libcxx_define(compiler=self._compiler, libcxx=self._libcxx)
        if abif:
            ret.append(abif)
        return ret
예제 #12
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)
예제 #13
0
    def test_build_type_flags(self):
        flags = build_type_flag(compiler='Visual Studio', build_type='Debug')
        self.assertEquals(flags, '-Zi')

        flags = build_type_flag(compiler='Visual Studio', build_type='Release')
        self.assertEquals(flags, "")

        flags = build_type_flag(compiler='gcc', build_type='Debug')
        self.assertEquals(flags, '-g')

        flags = build_type_flag(compiler='gcc', build_type='Release')
        self.assertEquals(flags, '-s')
        define = build_type_define(build_type='Release')
        self.assertEquals(define, 'NDEBUG')

        flags = build_type_flag(compiler='clang', build_type='Debug')
        self.assertEquals(flags, '-g')

        flags = build_type_flag(compiler='clang', build_type='Release')
        self.assertEquals(flags, '')
예제 #14
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)
예제 #15
0
    def test_build_type_flags(self):
        flags = build_type_flags(compiler='Visual Studio', build_type='Debug')
        self.assertEquals(" ".join(flags), '-Zi -Ob0 -Od')

        flags = build_type_flags(compiler='Visual Studio', build_type='Release')
        self.assertEquals(" ".join(flags), "-O2 -Ob2")

        flags = build_type_flags(compiler='Visual Studio', build_type='RelWithDebInfo')
        self.assertEquals(" ".join(flags), '-Zi -O2 -Ob1')

        flags = build_type_flags(compiler='Visual Studio', build_type='MinSizeRel')
        self.assertEquals(" ".join(flags), '-O1 -Ob1')

        # With clang toolset
        flags = build_type_flags(compiler='Visual Studio', build_type='Debug',
                                 vs_toolset="v140_clang_c2")
        self.assertEquals(" ".join(flags), '-gline-tables-only -fno-inline -O0')

        flags = build_type_flags(compiler='Visual Studio', build_type='Release',
                                 vs_toolset="v140_clang_c2")
        self.assertEquals(" ".join(flags), "-O2")

        flags = build_type_flags(compiler='Visual Studio', build_type='RelWithDebInfo',
                                 vs_toolset="v140_clang_c2")
        self.assertEquals(" ".join(flags), '-gline-tables-only -O2 -fno-inline')

        flags = build_type_flags(compiler='Visual Studio', build_type='MinSizeRel',
                                 vs_toolset="v140_clang_c2")
        self.assertEquals(" ".join(flags), '')

        # GCC

        flags = build_type_flags(compiler='gcc', build_type='Debug')
        self.assertEquals(" ".join(flags), '-g')

        flags = build_type_flags(compiler='gcc', build_type='Release')
        self.assertEquals(" ".join(flags), '-O3 -s')

        flags = build_type_flags(compiler='gcc', build_type='RelWithDebInfo')
        self.assertEquals(" ".join(flags), '-O2 -g')

        flags = build_type_flags(compiler='gcc', build_type='MinSizeRel')
        self.assertEquals(" ".join(flags), '-Os')

        flags = build_type_flags(compiler='clang', build_type='Debug')
        self.assertEquals(" ".join(flags), '-g')

        flags = build_type_flags(compiler='clang', build_type='Release')
        self.assertEquals(" ".join(flags), '-O3')

        flags = build_type_flags(compiler='clang', build_type='RelWithDebInfo')
        self.assertEquals(" ".join(flags), '-O2 -g')

        flags = build_type_flags(compiler='clang', build_type='MinSizeRel')
        self.assertEquals(" ".join(flags), '-Os')

        # SUN CC

        flags = build_type_flags(compiler='sun-cc', build_type='Debug')
        self.assertEquals(" ".join(flags), '-g')

        flags = build_type_flags(compiler='sun-cc', build_type='Release')
        self.assertEquals(" ".join(flags), '-xO3')

        flags = build_type_flags(compiler='sun-cc', build_type='RelWithDebInfo')
        self.assertEquals(" ".join(flags), '-xO2 -g')

        flags = build_type_flags(compiler='sun-cc', build_type='MinSizeRel')
        self.assertEquals(" ".join(flags), '-xO2 -xspace')

        # Define
        define = build_type_define(build_type='Release')
        self.assertEquals(define, 'NDEBUG')
예제 #16
0
    def test_build_type_flags(self):
        flags = build_type_flags(compiler='Visual Studio', build_type='Debug')
        self.assertEqual(" ".join(flags), '-Zi -Ob0 -Od')

        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='Release')
        self.assertEqual(" ".join(flags), "-O2 -Ob2")

        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='RelWithDebInfo')
        self.assertEqual(" ".join(flags), '-Zi -O2 -Ob1')

        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='MinSizeRel')
        self.assertEqual(" ".join(flags), '-O1 -Ob1')

        # With clang toolset
        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='Debug',
                                 vs_toolset="v140_clang_c2")
        self.assertEqual(" ".join(flags), '-gline-tables-only -fno-inline -O0')

        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='Release',
                                 vs_toolset="v140_clang_c2")
        self.assertEqual(" ".join(flags), "-O2")

        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='RelWithDebInfo',
                                 vs_toolset="v140_clang_c2")
        self.assertEqual(" ".join(flags), '-gline-tables-only -O2 -fno-inline')

        flags = build_type_flags(compiler='Visual Studio',
                                 build_type='MinSizeRel',
                                 vs_toolset="v140_clang_c2")
        self.assertEqual(" ".join(flags), '')

        # GCC

        flags = build_type_flags(compiler='gcc', build_type='Debug')
        self.assertEqual(" ".join(flags), '-g')

        flags = build_type_flags(compiler='gcc', build_type='Release')
        self.assertEqual(" ".join(flags), '-O3 -s')

        flags = build_type_flags(compiler='gcc', build_type='RelWithDebInfo')
        self.assertEqual(" ".join(flags), '-O2 -g')

        flags = build_type_flags(compiler='gcc', build_type='MinSizeRel')
        self.assertEqual(" ".join(flags), '-Os')

        flags = build_type_flags(compiler='clang', build_type='Debug')
        self.assertEqual(" ".join(flags), '-g')

        flags = build_type_flags(compiler='clang', build_type='Release')
        self.assertEqual(" ".join(flags), '-O3')

        flags = build_type_flags(compiler='clang', build_type='RelWithDebInfo')
        self.assertEqual(" ".join(flags), '-O2 -g')

        flags = build_type_flags(compiler='clang', build_type='MinSizeRel')
        self.assertEqual(" ".join(flags), '-Os')

        # SUN CC

        flags = build_type_flags(compiler='sun-cc', build_type='Debug')
        self.assertEqual(" ".join(flags), '-g')

        flags = build_type_flags(compiler='sun-cc', build_type='Release')
        self.assertEqual(" ".join(flags), '-xO3')

        flags = build_type_flags(compiler='sun-cc',
                                 build_type='RelWithDebInfo')
        self.assertEqual(" ".join(flags), '-xO2 -g')

        flags = build_type_flags(compiler='sun-cc', build_type='MinSizeRel')
        self.assertEqual(" ".join(flags), '-xO2 -xspace')

        # Define
        define = build_type_define(build_type='Release')
        self.assertEqual(define, 'NDEBUG')
예제 #17
0
 def test_build_type_define(self):
     define = build_type_define(build_type='Release')
     self.assertEqual(define, 'NDEBUG')