예제 #1
0
파일: msbuild.py 프로젝트: rukgar/conan
 def __init__(self, conanfile):
     if isinstance(conanfile, ConanFile):
         self._conanfile = conanfile
         self._settings = self._conanfile.settings
         self._output = self._conanfile.output
         self.build_env = VisualStudioBuildEnvironment(self._conanfile)
     else:  # backwards compatible with build_sln_command
         self._settings = conanfile
예제 #2
0
 def __init__(self, conanfile):
     super(VirtualBuildEnvGenerator, self).__init__(conanfile)
     self.venv_name = "conanbuildenv"
     compiler = conanfile.settings.get_safe("compiler")
     if compiler == "Visual Studio":
         self.env = VisualStudioBuildEnvironment(conanfile).vars_dict
         self.env.update(vcvars_dict(conanfile.settings))
     else:
         self.env = AutoToolsBuildEnvironment(conanfile).vars_dict
예제 #3
0
    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
예제 #4
0
 def __init__(self, conanfile):
     super(VirtualBuildEnvGenerator, self).__init__(conanfile)
     self.venv_name = "conanbuildenv"
     compiler = conanfile.settings.get_safe("compiler")
     if compiler == "Visual Studio":
         self.env = VisualStudioBuildEnvironment(conanfile).vars_dict
         settings_vars = vcvars_dict(conanfile.settings,
                                     output=conanfile.output)
         for env_var in self.env:
             self.env[env_var].extend(settings_vars.pop(env_var, []))
         self.env.update(settings_vars)
     else:
         self.env = AutoToolsBuildEnvironment(conanfile).vars_dict
예제 #5
0
    def __init__(self, conanfile):
        super(VirtualBuildEnvGenerator, self).__init__(conanfile)
        compiler = conanfile.settings.get_safe("compiler")
        if compiler == "Visual Studio":
            self.env = VisualStudioBuildEnvironment(conanfile).vars_dict
            settings_vars = vcvars_dict(conanfile.settings,
                                        output=conanfile.output)
            # self.env has higher priority, so only extend (append) to it.
            for name, value in self.env.items():
                if isinstance(value, list):
                    value.extend(settings_vars.pop(name, []))

            self.env.update(settings_vars)
        else:
            self.env = AutoToolsBuildEnvironment(conanfile).vars_dict
예제 #6
0
    def test_visual(self):
        settings = MockSettings({
            "build_type": "Debug",
            "compiler": "Visual Studio",
            "compiler.runtime": "MDd"
        })
        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")
        conanfile.deps_cpp_info.cflags.append("-mycflag")
        conanfile.deps_cpp_info.cflags.append("-mycflag2")
        conanfile.deps_cpp_info.cxxflags.append("-mycxxflag")
        conanfile.deps_cpp_info.cxxflags.append("-mycxxflag2")
        conanfile.deps_cpp_info.exelinkflags.append("-myexelinkflag")
        conanfile.deps_cpp_info.sharedlinkflags.append("-mysharedlinkflag")
        conanfile.deps_cpp_info.libs.extend(['gdi32', 'user32.lib'])

        tool = VisualStudioBuildEnvironment(conanfile)
        self.assertEqual(
            tool.vars_dict, {
                "CL": [
                    "-I/one/include/path", "-I/two/include/path", '-MDd',
                    '-mycflag', '-mycflag2', '-Zi', '-Ob0', '-Od',
                    '-mycxxflag', '-mycxxflag2'
                ],
                "LIB": ["/one/lib/path", "/two/lib/path"],
                "UseEnv":
                "True",
                "_LINK_": [
                    '-myexelinkflag', '-mysharedlinkflag', 'gdi32.lib',
                    'user32.lib'
                ]
            })
        tool.parallel = True
        self.assertEqual(
            tool.vars_dict, {
                "CL": [
                    "-I/one/include/path", "-I/two/include/path", '-MDd',
                    '-mycflag', '-mycflag2', '-Zi', '-Ob0', '-Od',
                    '-mycxxflag', '-mycxxflag2',
                    '/MP%s' % tools.cpu_count(output=conanfile.output)
                ],
                "LIB": ["/one/lib/path", "/two/lib/path"],
                "UseEnv":
                "True",
                "_LINK_": [
                    '-myexelinkflag', '-mysharedlinkflag', 'gdi32.lib',
                    'user32.lib'
                ]
            })
        tool.parallel = False

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

        self.assertEqual(
            tool.vars_dict, {
                "CL": [
                    "-I/one/include/path", "-I/two/include/path",
                    "-I/three/include/path", '-MDd', '-mycflag', '-mycflag2',
                    '-Zi', '-Ob0', '-Od', '-mycxxflag', '-mycxxflag2'
                ],
                "LIB": ["/one/lib/path", "/two/lib/path", "/three/lib/path"],
                "UseEnv":
                "True",
                "_LINK_": [
                    '-myexelinkflag', '-mysharedlinkflag', 'gdi32.lib',
                    'user32.lib'
                ]
            })

        # 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.assertEqual(
                tool.vars_dict, {
                    "CL": [
                        "-I/one/include/path", "-I/two/include/path",
                        "-I/three/include/path", '-MDd', '-mycflag',
                        '-mycflag2', '-Zi', '-Ob0', '-Od', '-mycxxflag',
                        '-mycxxflag2',
                        "-I/four/include/path -I/five/include/path"
                    ],
                    "LIB": [
                        "/one/lib/path", "/two/lib/path", "/three/lib/path",
                        "/four/lib/path;/five/lib/path"
                    ],
                    "UseEnv":
                    "True",
                    "_LINK_": [
                        '-myexelinkflag', '-mysharedlinkflag', 'gdi32.lib',
                        'user32.lib'
                    ]
                })

            self.assertEqual(
                tool.vars, {
                    "CL":
                    '-I"/one/include/path" -I"/two/include/path" -I"/three/include/path" -MDd '
                    '-mycflag -mycflag2 -Zi -Ob0 -Od '
                    '-mycxxflag -mycxxflag2 '
                    '-I/four/include/path -I/five/include/path',
                    "LIB":
                    "/one/lib/path;/two/lib/path;/three/lib/path;/four/lib/path;/five/lib/path",
                    "UseEnv":
                    "True",
                    "_LINK_":
                    "-myexelinkflag -mysharedlinkflag gdi32.lib user32.lib"
                })
예제 #7
0
 def __init__(self, conanfile):
     self._conanfile = conanfile
     self.build_env = VisualStudioBuildEnvironment(self._conanfile)
예제 #8
0
    def test_visual(self):
        settings = MockSettings({
            "build_type": "Debug",
            "compiler": "Visual Studio",
            "compiler.runtime": "MDd"
        })
        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")
        conanfile.deps_cpp_info.cflags.append("-mycflag")
        conanfile.deps_cpp_info.cflags.append("-mycflag2")
        conanfile.deps_cpp_info.cppflags.append("-mycppflag")
        conanfile.deps_cpp_info.cppflags.append("-mycppflag2")
        conanfile.deps_cpp_info.exelinkflags.append("-myexelinkflag")
        conanfile.deps_cpp_info.sharedlinkflags.append("-mysharedlinkflag")

        tool = VisualStudioBuildEnvironment(conanfile)
        self.assertEquals(
            tool.vars_dict, {
                "CL": [
                    "-I/one/include/path", "-I/two/include/path", '-MDd',
                    '-mycflag', '-mycflag2', '-Zi', '-Ob0', '-Od',
                    '-mycppflag', '-mycppflag2', '-myexelinkflag',
                    '-mysharedlinkflag'
                ],
                "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", '-MDd', '-mycflag', '-mycflag2',
                    '-Zi', '-Ob0', '-Od', '-mycppflag', '-mycppflag2',
                    '-myexelinkflag', '-mysharedlinkflag'
                ],
                "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", '-MDd', '-mycflag',
                        '-mycflag2', '-Zi', '-Ob0', '-Od', '-mycppflag',
                        '-mycppflag2', '-myexelinkflag', '-mysharedlinkflag',
                        "-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" -MDd '
                    '-mycflag -mycflag2 -Zi -Ob0 -Od '
                    '-mycppflag -mycppflag2 -myexelinkflag -mysharedlinkflag '
                    '-I/four/include/path -I/five/include/path',
                    "LIB":
                    "/one/lib/path;/two/lib/path;/three/lib/path;/four/lib/path;/five/lib/path",
                })