示例#1
0
def write_conanvcvars(conanfile):
    """
    write a conanvcvars.bat file with the good args from settings
    """
    os_ = conanfile.settings.get_safe("os")
    if os_ != "Windows":
        return

    compiler = conanfile.settings.get_safe("compiler")
    cvars = None
    if compiler == "intel":
        cvars = intel_compilervars_command(conanfile)
    elif compiler == "Visual Studio" or compiler == "msvc":
        vs_version = vs_ide_version(conanfile)
        vcvarsarch = vcvars_arch(conanfile)
        cvars = vcvars_command(vs_version,
                               architecture=vcvarsarch,
                               platform_type=None,
                               winsdk_version=None,
                               vcvars_ver=None)
    if cvars:
        content = textwrap.dedent("""\
            @echo off
            {}
            """.format(cvars))
        save(CONAN_VCVARS_FILE, content)
示例#2
0
    def __init__(self, conanfile):
        self._conanfile = conanfile
        self.preprocessor_definitions = {}
        self.compile_options = {}
        self.configuration = conanfile.settings.build_type
        self.runtime_library = self._runtime_library(conanfile.settings)
        self.cppstd = conanfile.settings.get_safe("compiler.cppstd")
        self.toolset = self._msvs_toolset(conanfile.settings)

        # For VCVARS stuff
        self.compiler = conanfile.settings.get_safe("compiler")
        # This is assuming this is the Visual Studio IDE version, used for the vcvars
        compiler_version = (
            conanfile.settings.get_safe("compiler.base.version")
            or conanfile.settings.get_safe("compiler.version"))
        self.vcvars_arch = vcvars_arch(conanfile)
        if self.compiler == "msvc":
            toolset_override = self._conanfile.conf[
                "tools.microsoft.msbuild"].vs_version
            if toolset_override:
                self.visual_version = toolset_override
            else:
                version = compiler_version[:
                                           4]  # Remove the latest version number 19.1X if existing
                _visuals = {
                    '19.0': '14',  # TODO: This is common to CMake, refactor
                    '19.1': '15',
                    '19.2': '16'
                }
                self.visual_version = _visuals[version]
        else:
            self.visual_version = compiler_version
示例#3
0
 def _run(self, cmd):
     if self._conanfile.settings.get_safe("compiler") == "Visual Studio":
         vcvars = vcvars_command(
             self._conanfile.settings.get_safe("compiler.version"),
             vcvars_arch(self._conanfile))
         cmd = '%s && %s' % (vcvars, cmd)
     self._conanfile.run(cmd)
示例#4
0
 def __init__(self, conanfile):
     self._conanfile = conanfile
     self.compiler = conanfile.settings.get_safe("compiler")
     # This is assuming this is the Visual Studio IDE version, used for the vcvars
     self.version = (conanfile.settings.get_safe("compiler.base.version") or
                     conanfile.settings.get_safe("compiler.version"))
     if self.compiler == "msvc":
         version = self.version[:4]  # Remove the latest version number 19.1X if existing
         _visuals = {'19.0': '14',  # TODO: This is common to CMake, refactor
                     '19.1': '15',
                     '19.2': '16'}
         self.version = _visuals[version]
     self.vcvars_arch = vcvars_arch(conanfile)
     self.build_type = conanfile.settings.get_safe("build_type")
     msvc_arch = {'x86': 'x86',
                  'x86_64': 'x64',
                  'armv7': 'ARM',
                  'armv8': 'ARM64'}
     # if platforms:
     #    msvc_arch.update(platforms)
     arch = conanfile.settings.get_safe("arch")
     msvc_arch = msvc_arch.get(str(arch))
     if conanfile.settings.get_safe("os") == "WindowsCE":
         msvc_arch = conanfile.settings.get_safe("os.platform")
     self.platform = msvc_arch
示例#5
0
 def __init__(self, conanfile):
     self._conanfile = conanfile
     self.compiler = conanfile.settings.get_safe("compiler")
     self.version = conanfile.settings.get_safe("compiler.base.version") or \
                    conanfile.settings.get_safe("compiler.version")
     self.vcvars_arch = vcvars_arch(conanfile)
     self.build_type = conanfile.settings.get_safe("build_type")
     msvc_arch = {
         'x86': 'x86',
         'x86_64': 'x64',
         'armv7': 'ARM',
         'armv8': 'ARM64'
     }
     # if platforms:
     #    msvc_arch.update(platforms)
     arch = conanfile.settings.get_safe("arch")
     msvc_arch = msvc_arch.get(str(arch))
     if conanfile.settings.get_safe("os") == "WindowsCE":
         msvc_arch = conanfile.settings.get_safe("os.platform")
     self.platform = msvc_arch