def autotools_configure_vars_test(self):
        from mock import patch

        runner = RunnerMock()
        settings = MockSettings({"build_type": "Debug",
                                 "arch": "x86_64",
                                 "compiler": "gcc",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings, None, runner)
        conanfile.settings = settings
        self._set_deps_info(conanfile)

        def custom_configure(obj, configure_dir=None, args=None, build=None, host=None, target=None,
                             pkg_config_paths=None, vars=None):  # @UnusedVariable
            self.assertNotEqual(obj.vars, vars)
            return vars or obj.vars

        with patch.object(AutoToolsBuildEnvironment, 'configure', new=custom_configure):
            be = AutoToolsBuildEnvironment(conanfile)

            # Get vars and modify them
            my_vars = be.vars
            my_vars["fake_var"] = "fake"
            my_vars["super_fake_var"] = "fakefake"

            # TEST with default vars
            mocked_result = be.configure()
            self.assertEqual(mocked_result, be.vars)

            # TEST with custom vars
            mocked_result = be.configure(vars=my_vars)
            self.assertEqual(mocked_result, my_vars)
示例#2
0
    def skip_toolset_test(self):
        settings = MockSettings({
            "build_type": "Debug",
            "compiler": "Visual Studio",
            "compiler.version": "15",
            "arch": "x86_64"
        })

        class Runner(object):
            def __init__(self):
                self.commands = []

            def __call__(self, *args, **kwargs):
                self.commands.append(args[0])

        with chdir(tools.mkdir_tmp()):
            runner = Runner()
            conanfile = MockConanfile(settings, runner=runner)
            msbuild = MSBuild(conanfile)
            msbuild.build("myproject", toolset=False)
            self.assertEqual(len(runner.commands), 1)
            self.assertNotIn("PlatformToolset", runner.commands[0])

            runner = Runner()
            conanfile = MockConanfile(settings, runner=runner)
            msbuild = MSBuild(conanfile)
            msbuild.build("myproject", toolset="mytoolset")
            self.assertEqual(len(runner.commands), 1)
            self.assertIn('/p:PlatformToolset="mytoolset"', runner.commands[0])
    def autotools_configure_vars_test(self):
        from mock import patch

        runner = RunnerMock()
        settings = MockSettings({"build_type": "Debug",
                                 "arch": "x86_64",
                                 "compiler": "gcc",
                                 "compiler.libcxx": "libstdc++"})
        conanfile = MockConanfile(settings, None, runner)
        conanfile.settings = settings
        self._set_deps_info(conanfile)

        def custom_configure(obj, configure_dir=None, args=None, build=None, host=None, target=None,
                             pkg_config_paths=None, vars=None):  # @UnusedVariable
            self.assertNotEqual(obj.vars, vars)
            return vars or obj.vars

        with patch.object(AutoToolsBuildEnvironment, 'configure', new=custom_configure):
            be = AutoToolsBuildEnvironment(conanfile)

            # Get vars and modify them
            my_vars = be.vars
            my_vars["fake_var"] = "fake"
            my_vars["super_fake_var"] = "fakefake"

            # TEST with default vars
            mocked_result = be.configure()
            self.assertEqual(mocked_result, be.vars)

            # TEST with custom vars
            mocked_result = be.configure(vars=my_vars)
            self.assertEqual(mocked_result, my_vars)
示例#4
0
    def test_win(self):
        install_dir = "C:\\Intel"
        with mock.patch("platform.system", mock.MagicMock(return_value="Windows")),\
            mock.patch("conans.client.tools.intel.intel_installation_path",
                       mock.MagicMock(return_value=install_dir)):
            settings = Settings.loads(get_default_settings_yml())
            settings.os = "Windows"
            settings.compiler = "intel"
            settings.compiler.base = "Visual Studio"
            settings.arch = "ppc32"
            with self.assertRaises(ConanException):
                compilervars_command(MockConanfile(settings))

            path = os.path.join(install_dir, "bin", "compilervars.bat")

            settings.arch = "x86"
            cvars = compilervars_command(MockConanfile(settings))
            expected = '"%s" -arch ia32' % path
            self.assertEqual(expected, cvars)

            settings.compiler.base.version = "16"
            cvars = compilervars_command(MockConanfile(settings))
            expected = '"%s" -arch ia32 vs2019' % path
            self.assertEqual(expected, cvars)

            settings.arch = "x86_64"
            expected = '"%s" -arch intel64 vs2019' % path
            cvars = compilervars_command(MockConanfile(settings))
            self.assertEqual(expected, cvars)
 def rpath_optin_test(self):
     settings = MockSettings({
         "os_build": "Linux",
         "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':
         'a_c_flag -m64 -O3 -s --sysroot=/path/to/folder',
         'CPPFLAGS':
         '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG '
         '-D_GLIBCXX_USE_CXX11_ABI=1',
         'CXXFLAGS':
         'a_c_flag -m64 -O3 -s --sysroot=/path/to/folder a_cpp_flag',
         'LDFLAGS':
         'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder '
         '-Wl,-rpath="one/lib/path" -Lone/lib/path',
         'LIBS':
         '-lonelib -ltwolib'
     }
     be = AutoToolsBuildEnvironment(conanfile, include_rpath_flags=True)
     self.assertEquals(be.vars, expected)
    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)
示例#7
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)
    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 autotools_prefix_test(self):
     runner = RunnerMock()
     conanfile = MockConanfile(MockSettings({}), None, runner)
     # Package folder is not defined
     ab = AutoToolsBuildEnvironment(conanfile)
     ab.configure()
     self.assertNotIn("--prefix", runner.command_called)
     # package folder defined
     conanfile.package_folder = "/package_folder"
     ab.configure()
     if platform.system() == "Windows":
         self.assertIn("./configure --prefix=/package_folder",
                       runner.command_called)
     else:
         self.assertIn("./configure '--prefix=/package_folder'",
                       runner.command_called)
     # --prefix already used in args
     ab.configure(args=["--prefix=/my_package_folder"])
     if platform.system() == "Windows":
         self.assertIn("./configure --prefix=/my_package_folder",
                       runner.command_called)
         self.assertNotIn("--prefix=/package_folder", runner.command_called)
     else:
         self.assertIn("./configure '--prefix=/my_package_folder'",
                       runner.command_called)
         self.assertNotIn("'--prefix=/package_folder'",
                          runner.command_called)
示例#10
0
    def test_mac(self):
        install_dir = "/opt/intel"
        with mock.patch("platform.system", mock.MagicMock(return_value="Darwin")),\
            mock.patch("conans.client.tools.intel.intel_installation_path",
                       mock.MagicMock(return_value="/opt/intel")):
            settings = Settings.loads(get_default_settings_yml())
            settings.os = "Macos"
            settings.compiler = "intel"
            settings.compiler.base = "apple-clang"
            settings.arch = "ppc32"
            with self.assertRaises(ConanException):
                compilervars_command(MockConanfile(settings))

            path = os.path.join(install_dir, "bin", "compilervars.sh")

            settings.arch = "x86"
            cvars = compilervars_command(MockConanfile(settings))
            expected = 'COMPILERVARS_PLATFORM=mac COMPILERVARS_ARCHITECTURE=ia32 . ' \
                       '"%s" -arch ia32 -platform mac' % path
            self.assertEqual(expected, cvars)

            settings.arch = "x86_64"
            expected = 'COMPILERVARS_PLATFORM=mac COMPILERVARS_ARCHITECTURE=intel64 . ' \
                       '"%s" -arch intel64 -platform mac' % path
            cvars = compilervars_command(MockConanfile(settings))
            self.assertEqual(expected, cvars)
示例#11
0
    def cross_build_command_test(self):
        runner = RunnerMock()
        conanfile = MockConanfile(MockSettings({}), None, runner)
        ab = AutoToolsBuildEnvironment(conanfile)
        self.assertFalse(ab.build)
        self.assertFalse(ab.host)
        self.assertFalse(ab.target)

        ab.configure()
        self.assertEqual(runner.command_called, "./configure  ")

        ab.configure(host="x86_64-apple-darwin")
        self.assertEqual(runner.command_called, "./configure  --host=x86_64-apple-darwin")

        ab.configure(build="arm-apple-darwin")
        self.assertEqual(runner.command_called, "./configure  --build=arm-apple-darwin")

        ab.configure(target="i686-apple-darwin")
        self.assertEqual(runner.command_called, "./configure  --target=i686-apple-darwin")

        conanfile = MockConanfile(MockSettings({"build_type": "Debug",
                                                "arch": "x86_64",
                                                "os": "Windows",
                                                "compiler": "gcc",
                                                "compiler.libcxx": "libstdc++"}),
                                  None, runner)
        ab = AutoToolsBuildEnvironment(conanfile)
        ab.configure()
        if platform.system() == "Windows":
            # Not crossbuilding
            self.assertFalse(ab.host)
            self.assertFalse(ab.build)
            self.assertIn("./configure", runner.command_called)
            self.assertNotIn("--build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32",
                             runner.command_called)
        elif platform.system() == "Linux":
            self.assertIn("x86_64-w64-mingw32", ab.host)
            self.assertIn("x86_64-linux-gnu", ab.build)
            self.assertIn("./configure  --build=x86_64-linux-gnu --host=x86_64-w64-mingw32",
                          runner.command_called)
        else:
            self.assertIn("x86_64-w64-mingw32", ab.host)
            self.assertIn("x86_64-apple-darwin", ab.build)
            self.assertIn("./configure  --build=x86_64-apple-darwin --host=x86_64-w64-mingw32",
                          runner.command_called)

        ab.configure(build="fake_build_triplet", host="fake_host_triplet")
        self.assertIn("./configure  --build=fake_build_triplet --host=fake_host_triplet",
                      runner.command_called)

        ab.build = "superfake_build_triplet"
        ab.host = "superfake_host_triplet"
        ab.configure()
        self.assertIn("./configure  --build=superfake_build_triplet --host=superfake_host_triplet",
                      runner.command_called)
示例#12
0
 def test_check_cppstd_type(self):
     """ cppstd must be a number
     """
     conanfile = MockConanfile(MockSettings({}))
     with self.assertRaises(ConanException) as raises:
         check_min_cppstd(conanfile, "gnu17", False)
     self.assertEqual("cppstd parameter must be a number", str(raises.exception))
示例#13
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")
示例#14
0
 def verbosity_explicit_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("projecshould_flags_testt_file.sln", verbosity="quiet")
     self.assertIn('/verbosity:quiet', command)
示例#15
0
 def without_runtime_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     template = msbuild._get_props_file_contents()
     self.assertNotIn("<RuntimeLibrary>", template)
示例#16
0
 def test_make_targets(self):
     runner = RunnerMock()
     conanfile = MockConanfile(MockSettings({}),None,runner)
     
     ab = AutoToolsBuildEnvironment(conanfile)
     ab.configure()
     
     ab.make(target="install")
     self.assertEquals(runner.command_called,"make install -j%s" % cpu_count())        
示例#17
0
 def verbosity_env_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     with tools.environment_append({"CONAN_MSBUILD_VERBOSITY": "detailed"}):
         conanfile = MockConanfile(settings)
         msbuild = MSBuild(conanfile)
         command = msbuild.get_command("projecshould_flags_testt_file.sln")
         self.assertIn('/verbosity:detailed', command)
示例#18
0
 def explicit_toolset_test(self, expected_toolset):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("project_should_flags_test_file.sln", toolset=expected_toolset)
     self.assertIn('/p:PlatformToolset="%s"' % expected_toolset, command)
示例#19
0
 def rpath_optin_test(self):
     settings = MockSettings({"os_build": "Linux",
                              "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': 'a_c_flag -m64 -O3 -s --sysroot=/path/to/folder',
                 'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG '
                             '-D_GLIBCXX_USE_CXX11_ABI=1',
                 'CXXFLAGS': 'a_c_flag -m64 -O3 -s --sysroot=/path/to/folder a_cpp_flag',
                 'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder '
                            '-Wl,-rpath="one/lib/path" -Lone/lib/path',
                 'LIBS': '-lonelib -ltwolib'}
     be = AutoToolsBuildEnvironment(conanfile, include_rpath_flags=True)
     self.assertEquals(be.vars, expected)
示例#20
0
 def custom_properties_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("project_file.sln", properties={"MyProp1": "MyValue1",
                                                                   "MyProp2": "MyValue2"})
     self.assertIn('/p:MyProp1="MyValue1"', command)
     self.assertIn('/p:MyProp2="MyValue2"', command)
示例#21
0
 def binary_logging_off_implicit_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64",
                              "compiler.runtime": "MDd"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("dummy.sln")
     self.assertNotIn("/bl", command)
示例#22
0
 def _create_conanfile(self, compiler, version, os, cppstd, libcxx=None):
     settings = MockSettings({"arch": "x86_64",
                              "build_type": "Debug",
                              "os": os,
                              "compiler": compiler,
                              "compiler.version": version,
                              "compiler.cppstd": cppstd})
     if libcxx:
         settings.values["compiler.libcxx"] = libcxx
     conanfile = MockConanfile(settings)
     return conanfile
示例#23
0
    def definitions_no_value_test(self):
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64",
                                 "compiler.runtime": "MDd"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        template = msbuild._get_props_file_contents(definitions={'_DEBUG': None})

        self.assertIn("<PreprocessorDefinitions>"
                      "_DEBUG;"
                      "%(PreprocessorDefinitions)</PreprocessorDefinitions>", template)
示例#24
0
 def binary_logging_on_with_filename_test(self):
     bl_filename = "a_special_log.log"
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64",
                              "compiler.runtime": "MDd"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("dummy.sln", output_binary_log=bl_filename)
     expected_command = '/bl:"%s"' % bl_filename
     self.assertIn(expected_command, command)
    def test_visual(self):
        settings = MockSettings({})
        conanfile = MockConanfile(settings)
        conanfile.deps_cpp_info.include_paths.append("/one/include/path")
        conanfile.deps_cpp_info.include_paths.append("/two/include/path")
        conanfile.deps_cpp_info.lib_paths.append("/one/lib/path")
        conanfile.deps_cpp_info.lib_paths.append("/two/lib/path")
        tool = VisualStudioBuildEnvironment(conanfile)
        self.assertEquals(
            tool.vars_dict, {
                "CL": ["/I/one/include/path", "/I/two/include/path"],
                "LIB": ["/one/lib/path", "/two/lib/path"],
            })

        # Now alter the paths before the vars_dict call
        tool.include_paths.append("/three/include/path")
        tool.lib_paths.append("/three/lib/path")

        self.assertEquals(
            tool.vars_dict, {
                "CL": [
                    "/I/one/include/path", "/I/two/include/path",
                    "/I/three/include/path"
                ],
                "LIB": ["/one/lib/path", "/two/lib/path", "/three/lib/path"],
            })

        # Now try appending to environment
        with tools.environment_append({
                "CL": "/I/four/include/path /I/five/include/path",
                "LIB": "/four/lib/path;/five/lib/path"
        }):
            self.assertEquals(
                tool.vars_dict, {
                    "CL": [
                        "/I/one/include/path", "/I/two/include/path",
                        "/I/three/include/path",
                        "/I/four/include/path /I/five/include/path"
                    ],
                    "LIB": [
                        "/one/lib/path", "/two/lib/path", "/three/lib/path",
                        "/four/lib/path;/five/lib/path"
                    ],
                })

            self.assertEquals(
                tool.vars, {
                    "CL":
                    '/I"/one/include/path" /I"/two/include/path" '
                    '/I"/three/include/path" /I/four/include/path /I/five/include/path',
                    "LIB":
                    "/one/lib/path;/two/lib/path;/three/lib/path;/four/lib/path;/five/lib/path",
                })
示例#26
0
 def autotools_prefix_test(self):
     runner = RunnerMock()
     conanfile = MockConanfile(MockSettings({}), None, runner)
     # Package folder is not defined
     ab = AutoToolsBuildEnvironment(conanfile)
     ab.configure()
     self.assertNotIn("--prefix", runner.command_called)
     # package folder defined
     conanfile.package_folder = "/package_folder"
     ab.configure()
     if platform.system() == "Windows":
         self.assertIn("./configure --prefix=/package_folder", runner.command_called)
     else:
         self.assertIn("./configure '--prefix=/package_folder'", runner.command_called)
     # --prefix already used in args
     ab.configure(args=["--prefix=/my_package_folder"])
     if platform.system() == "Windows":
         self.assertIn("./configure --prefix=/my_package_folder", runner.command_called)
         self.assertNotIn("--prefix=/package_folder", runner.command_called)
     else:
         self.assertIn("./configure '--prefix=/my_package_folder'", runner.command_called)
         self.assertNotIn("'--prefix=/package_folder'", runner.command_called)
示例#27
0
 def windows_ce_test(self):
     settings = MockSettings({
         "build_type": "Debug",
         "compiler": "Visual Studio",
         "compiler.version": "9",
         "os": "WindowsCE",
         "os.platform": "YOUR PLATFORM SDK (ARMV4)",
         "arch": "armv4"
     })
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("test.sln")
     self.assertIn('/p:Platform="YOUR PLATFORM SDK (ARMV4)"', command)
示例#28
0
 def test_intel(self):
     settings = MockSettings({
         "build_type": "Debug",
         "compiler": "intel",
         "compiler.version": "19.1",
         "compiler.base": "Visual Studio",
         "compiler.base.version": "15",
         "arch": "x86_64"
     })
     expected_toolset = "Intel C++ Compiler 19.1"
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("project_should_flags_test_file.sln")
     self.assertIn('/p:PlatformToolset="%s"' % expected_toolset, command)
示例#29
0
    def test_mocked_methods(self):

        runner = RunnerMock()
        conanfile = MockConanfile(MockSettings({}), None, 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()))
示例#30
0
    def cross_build_command_test(self):
        runner = RunnerMock()
        conanfile = MockConanfile(MockSettings({}), None, runner)
        ab = AutoToolsBuildEnvironment(conanfile)
        ab.configure()
        self.assertEquals(runner.command_called, "./configure  ")

        ab.configure(host="x86_64-apple-darwin")
        self.assertEquals(runner.command_called, "./configure  --host=x86_64-apple-darwin")

        ab.configure(build="arm-apple-darwin")
        self.assertEquals(runner.command_called, "./configure  --build=arm-apple-darwin")

        ab.configure(target="i686-apple-darwin")
        self.assertEquals(runner.command_called, "./configure  --target=i686-apple-darwin")
示例#31
0
    def binary_logging_not_supported_test(self, mock_get_version):
        mock_get_version.return_value = Version("14")

        mocked_settings = MockSettings({"build_type": "Debug",
                                        "compiler": "Visual Studio",
                                        "compiler.version": "15",
                                        "arch": "x86_64",
                                        "compiler.runtime": "MDd"})
        conanfile = MockConanfile(mocked_settings)
        except_text = "MSBuild version detected (14) does not support 'output_binary_log' ('/bl')"
        msbuild = MSBuild(conanfile)

        with self.assertRaises(ConanException) as exc:
            msbuild.get_command("dummy.sln", output_binary_log=True)
        self.assertIn(except_text, str(exc.exception))
示例#32
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)
示例#33
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)
示例#34
0
    def build_vs_project_test(self, generator, props):
        client = TestClient()
        files = {}
        files["conanfile.py"] = hello_conanfile_py
        files["hello.h"] = hello_h
        client.save(files)
        client.run("create . lasote/testing")

        files = get_vs_project_files()
        files["MyProject/main.cpp"] = main_cpp
        files["conanfile.txt"] = conanfile_txt.format(generator=generator)
        props = os.path.join(client.current_folder, props)
        old = '<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />'
        new = old + '<Import Project="{props}" />'.format(props=props)
        files["MyProject/MyProject.vcxproj"] = files[
            "MyProject/MyProject.vcxproj"].replace(old, new)
        client.save(files, clean_first=True)

        for build_type in ["Debug", "Release"]:
            arch = "x86"
            runner = ConanRunner(print_commands_to_output=True,
                                 generate_run_log_file=False,
                                 log_run_to_output=True,
                                 output=TestBufferConanOutput())
            settings = MockSettings({
                "os": "Windows",
                "build_type": build_type,
                "arch": arch,
                "compiler": "Visual Studio",
                "compiler.version": "15",
                "compiler.toolset": "v141"
            })
            conanfile = MockConanfile(settings, runner=runner)
            settings = " -s os=Windows " \
                       " -s build_type={build_type} " \
                       " -s arch={arch}" \
                       " -s compiler=\"Visual Studio\"" \
                       " -s compiler.toolset=v141" \
                       " -s compiler.version=15".format(build_type=build_type, arch=arch)
            client.run("install . %s" % settings)
            with tools.chdir(client.current_folder):
                msbuild = MSBuild(conanfile)
                msbuild.build(project_file="MyProject.sln",
                              build_type=build_type,
                              arch=arch)
                output = TestBufferConanOutput()
                runner("%s\MyProject.exe" % build_type, output)
                self.assertIn("Hello %s!!!" % build_type, output)
示例#35
0
    def properties_injection_test(self):
        # https://github.com/conan-io/conan/issues/4471
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        command = msbuild.get_command("dummy.sln", props_file_path="conan_build.props")

        match = re.search('/p:ForceImportBeforeCppTargets="(.+?)"', command)
        self.assertTrue(
            match, "Haven't been able to find the ForceImportBeforeCppTargets")

        props_file_path = match.group(1)
        self.assertTrue(os.path.isabs(props_file_path))
        self.assertEquals(os.path.basename(props_file_path), "conan_build.props")
示例#36
0
    def test_variables(self):
        # Visual Studio
        settings = MockSettings({"build_type": "Release",
                                 "arch": "x86",
                                 "compiler": "Visual Studio",
                                 "compiler.version": "14",
                                 "compiler.runtime": "MD"})
        conanfile = MockConanfile(settings)
        self._set_deps_info(conanfile)

        be = AutoToolsBuildEnvironment(conanfile)
        expected = {'CFLAGS': 'a_c_flag -O2 -Ob2',
                    'CPPFLAGS': '-Ipath\\includes -Iother\\include\\path -Donedefinition -Dtwodefinition -DNDEBUG',
                    'CXXFLAGS': 'a_c_flag -O2 -Ob2 a_cpp_flag',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -LIBPATH:one\\lib\\path',
                    'LIBS': 'onelib.lib twolib.lib'}

        self.assertEquals(be.vars, expected)
        # 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': 'a_c_flag -m32 -O3 -s --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG '
                                '-D_GLIBCXX_USE_CXX11_ABI=0',
                    'CXXFLAGS': 'a_c_flag -m32 -O3 -s --sysroot=/path/to/folder a_cpp_flag',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m32 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -g --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition'
                                ' -D_GLIBCXX_USE_CXX11_ABI=0',
                    'CXXFLAGS': 'a_c_flag -m64 -g --sysroot=/path/to/folder a_cpp_flag',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -O3 --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition'
                                ' -DNDEBUG -D_GLIBCXX_USE_CXX11_ABI=0',
                    'CXXFLAGS': 'a_c_flag -m64 -O3 --sysroot=/path/to/folder a_cpp_flag -stdlib=libstdc++',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -O3 --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG',
                    'CXXFLAGS': 'a_c_flag -m64 -O3 --sysroot=/path/to/folder a_cpp_flag -stdlib=libc++',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -O3 -s --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG '
                                '-D_GLIBCXX_USE_CXX11_ABI=1',
                    'CXXFLAGS': 'a_c_flag -m64 -O3 -s --sysroot=/path/to/folder a_cpp_flag',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG',
                    'CXXFLAGS': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder a_cpp_flag -library=Cstd',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG',
                    'CXXFLAGS': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder a_cpp_flag -library=stdcxx4',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG',
                    'CXXFLAGS': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder a_cpp_flag -library=stlport4',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -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': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder',
                    'CPPFLAGS': '-Ipath/includes -Iother/include/path -Donedefinition -Dtwodefinition -DNDEBUG',
                    'CXXFLAGS': 'a_c_flag -m64 -xO3 --sysroot=/path/to/folder a_cpp_flag -library=stdcpp',
                    'LDFLAGS': 'shared_link_flag exe_link_flag -m64 --sysroot=/path/to/folder -Lone/lib/path',
                    'LIBS': '-lonelib -ltwolib'}
        be = AutoToolsBuildEnvironment(conanfile)
        self.assertEquals(be.vars, expected)