コード例 #1
0
    def modify_values_test(self):
        settings = MockSettings({
            "build_type": "Debug",
            "arch": "x86_64",
            "compiler": "gcc",
            "compiler.libcxx": "libstdc++"
        })
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        be = AutoToolsBuildEnvironment(conanfile)

        # Alter some things
        be.defines.append("OtherDefinition=23")
        be.link_flags = ["-inventedflag"]
        be.cxx_flags.append("-onlycxx")
        be.fpic = True
        be.flags.append("cucucu")

        expected = {
            'CFLAGS':
            'a_c_flag -m64 -g --sysroot=/path/to/folder cucucu -fPIC',
            'CPPFLAGS':
            '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition'
            ' -D_GLIBCXX_USE_CXX11_ABI=0 -DOtherDefinition=23',
            'CXXFLAGS':
            'a_c_flag -m64 -g --sysroot=/path/to/folder cucucu -fPIC a_cpp_flag -onlycxx',
            'LDFLAGS':
            '-inventedflag -Lone/lib/path',
            'LIBS':
            '-lonelib -ltwolib'
        }
        self.assertEquals(be.vars, expected)
コード例 #2
0
 def get_values(this_os, this_arch, setting_os, setting_arch):
     settings = MockSettings({"arch": setting_arch,
                              "os": setting_os})
     conanfile = MockConanfile(settings)
     conanfile.settings = settings
     be = AutoToolsBuildEnvironment(conanfile)
     return be._get_host_build_target_flags(this_arch, this_os)
コード例 #3
0
 def get_values(this_os, this_arch, setting_os, setting_arch):
     settings = MockSettings({"arch": setting_arch,
                              "os": setting_os})
     conanfile = MockConanfile(settings)
     conanfile.settings = settings
     be = AutoToolsBuildEnvironment(conanfile)
     return be._get_host_build_target_flags(this_arch, this_os)
コード例 #4
0
    def environment_append_test(self):
        settings = MockSettings({
            "build_type": "Debug",
            "arch": "x86_64",
            "compiler": "gcc",
            "compiler.libcxx": "libstdc++"
        })
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        env_vars = {
            "CFLAGS": "-additionalcflag",
            "CXXFLAGS": "-additionalcxxflag",
            "LDFLAGS": "-additionalldflag",
            "LIBS": "-additionallibs",
            "CPPFLAGS": "-additionalcppflag"
        }

        with (tools.environment_append(env_vars)):
            be = AutoToolsBuildEnvironment(conanfile)
            expected = {
                'CPPFLAGS':
                '-Ipath/includes -Iother/include/path -Donedefinition -'
                'Dtwodefinition -D_GLIBCXX_USE_CXX11_ABI=0 -additionalcppflag',
                'CXXFLAGS':
                'a_c_flag -m64 -g --sysroot=/path/to/folder a_cpp_flag -additionalcxxflag',
                'LIBS':
                '-lonelib -ltwolib -additionallibs',
                'LDFLAGS':
                'shared_link_flag exe_link_flag -m64 '
                '--sysroot=/path/to/folder -Lone/lib/path -additionalldflag',
                'CFLAGS':
                'a_c_flag -m64 -g --sysroot=/path/to/folder -additionalcflag'
            }
            self.assertEquals(be.vars, expected)
コード例 #5
0
    def test_previous_env(self):
        settings = MockSettings({"arch": "x86", "os": "Linux"})
        conanfile = MockConanfile(settings)

        with tools.environment_append({"CPPFLAGS": "MyCppFlag"}):
            be = AutoToolsBuildEnvironment(conanfile)
            self.assertEquals(be.vars["CPPFLAGS"], "MyCppFlag")
コード例 #6
0
ファイル: virtualbuildenv.py プロジェクト: zomeck/conan
    def __init__(self, conanfile):
        super(VirtualBuildEnvGenerator, self).__init__(conanfile)
        compiler = conanfile.settings.get_safe("compiler")
        if compiler != "Visual Studio":
            tools = AutoToolsBuildEnvironment(conanfile)
        else:
            tools = VisualStudioBuildEnvironment(conanfile)

        self.env = tools.vars_dict
コード例 #7
0
    def __init__(self, conanfile):
        super(VirtualBuildEnvGenerator, self).__init__(conanfile)

        compiler = conanfile.settings.get_safe("compiler")
        self.env = {}
        if compiler != "Visual Studio":
            auto_tools_b = AutoToolsBuildEnvironment(conanfile)
            tmp = {var: '"%s"' % value for var, value in auto_tools_b.vars.items()}
            self.env = tmp
        else:
            visual_b = VisualStudioBuildEnvironment(conanfile, quote_paths=False)
            self.env = visual_b.vars
コード例 #8
0
    def modify_values_test(self):
        settings = MockSettings({"build_type": "Debug",
                                 "arch": "x86_64",
                                 "compiler": "gcc",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        be = AutoToolsBuildEnvironment(conanfile)

        # Alter some things
        be.defines.append("OtherDefinition=23")
        be.link_flags = ["-inventedflag"]
        be.cxx_flags.append("-onlycxx")
        be.fpic = True
        be.flags.append("cucucu")

        expected = {'CFLAGS': 'a_c_flag -m64 -g --sysroot=/path/to/folder cucucu -fPIC',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition'
                                ' -D_GLIBCXX_USE_CXX11_ABI=0 -DOtherDefinition=23',
                    'CXXFLAGS': 'a_c_flag -m64 -g --sysroot=/path/to/folder cucucu -fPIC a_cpp_flag -onlycxx',
                    'LDFLAGS': '-inventedflag -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        self.assertEquals(be.vars, expected)
コード例 #9
0
    def test_mocked_methods(self):

        runner = RunnerMock()
        conanfile = MockConanfile(MockSettings({}), runner)
        ab = AutoToolsBuildEnvironment(conanfile)
        ab.make(make_program="othermake")
        self.assertEquals(runner.command_called,
                          "othermake -j%s" % cpu_count())

        with tools.environment_append({"CONAN_MAKE_PROGRAM": "mymake"}):
            ab.make(make_program="othermake")
            self.assertEquals(runner.command_called,
                              "mymake -j%s" % cpu_count())

        ab.make(args=["things"])
        things = "'things'" if platform.system() != "Windows" else "things"
        self.assertEquals(runner.command_called,
                          "make %s -j%s" % (things, cpu_count()))
コード例 #10
0
    def test_variables(self):
        # GCC 32
        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86",
                                 "compiler": "gcc",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings)
        self._set_deps_info(conanfile)

        be = AutoToolsBuildEnvironment(conanfile)
        expected = {'CFLAGS': '-m32 -s',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG '
                                '-D_GLIBCXX_USE_CXX11_ABI=0',
                    'CXXFLAGS': '-m32 -s',
                    'LDFLAGS': '-m32 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}

        self.assertEquals(be.vars, expected)

        # GCC 64
        settings = MockSettings({"build_type": "Debug",
                                 "arch": "x86_64",
                                 "compiler": "gcc",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64 -g',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition'
                                ' -D_GLIBCXX_USE_CXX11_ABI=0',
                    'CXXFLAGS': '-m64 -g',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        # With clang, we define _GLIBCXX_USE_CXX11_ABI
        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "clang",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition'
                                ' -D_GLIBCXX_USE_CXX11_ABI=0',
                    'CXXFLAGS': '-m64 -stdlib=libstdc++',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        # Change libcxx
        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "clang",
                                 "compiler.libcxx": "libc++"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition',
                    'CXXFLAGS': '-m64 -stdlib=libc++',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        # gcc libcxx
        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "gcc",
                                 "compiler.libcxx": "libstdc++11"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64 -s',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG '
                                '-D_GLIBCXX_USE_CXX11_ABI=1',
                    'CXXFLAGS': '-m64 -s',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        # Sun CC libCstd
        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "sun-cc",
                                 "compiler.libcxx": "libCstd"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition',
                    'CXXFLAGS': '-m64 -library=Cstd',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "sun-cc",
                                 "compiler.libcxx": "libstdcxx"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition',
                    'CXXFLAGS': '-m64 -library=stdcxx4',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "sun-cc",
                                 "compiler.libcxx": "libstlport"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition',
                    'CXXFLAGS': '-m64 -library=stlport4',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)

        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86_64",
                                 "compiler": "sun-cc",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings)
        conanfile.settings = settings
        self._set_deps_info(conanfile)
        expected = {'CFLAGS': '-m64',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition',
                    'CXXFLAGS': '-m64 -library=stdcpp',
                    'LDFLAGS': '-m64 -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)