예제 #1
0
    def generate(self, scope="build"):
        """
        write a conanvcvars.bat file with the good args from settings
        """
        conanfile = self._conanfile
        os_ = conanfile.settings.get_safe("os")
        if os_ != "Windows":
            return

        compiler = conanfile.settings.get_safe("compiler")
        if compiler != "Visual Studio" and compiler != "msvc":
            return

        vs_version = vs_ide_version(conanfile)
        vcvarsarch = vcvars_arch(conanfile)
        vcvars_ver = _vcvars_vers(conanfile, compiler, vs_version)

        vs_install_path = conanfile.conf.get("tools.microsoft.msbuild:installation_path")
        # The vs_install_path is like
        # C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
        # C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
        # C:\Program Files (x86)\Microsoft Visual Studio 14.0
        vcvars = vcvars_command(vs_version, architecture=vcvarsarch, platform_type=None,
                                winsdk_version=None, vcvars_ver=vcvars_ver,
                                vs_install_path=vs_install_path)

        content = textwrap.dedent("""\
            @echo off
            {}
            """.format(vcvars))
        from conan.tools.env.environment import create_env_script
        create_env_script(conanfile, content, CONAN_VCVARS_FILE, scope)
예제 #2
0
 def generate(self, scope="build"):
     """Generate the Conan Intel file to be loaded in build environment by default"""
     if platform.system() == "Windows" and not self._conanfile.win_bash:
         content = textwrap.dedent("""\
             @echo off
             {}
             """.format(self.command))
         filename = self.filename + '.bat'
     else:
         filename = self.filename + '.sh'
         content = self.command
     from conan.tools.env.environment import create_env_script
     create_env_script(self._conanfile, content, filename, scope)