Example #1
0
def merge_default_version(env):
    version = get_default_version(env)
    arch = get_default_arch(env)

    msvs = get_vs_by_version(version)
    if msvs is None:
        return
    batfilename = msvs.get_batch_file()

    # XXX: I think this is broken. This will silently set a bogus tool instead
    # of failing, but there is no other way with the current scons tool
    # framework
    if batfilename is not None:

        vars = ('LIB', 'LIBPATH', 'PATH', 'INCLUDE')

        msvs_list = get_installed_visual_studios()
        # TODO(1.5):
        #vscommonvarnames = [ vs.common_tools_var for vs in msvs_list ]
        vscommonvarnames = map(lambda vs: vs.common_tools_var, msvs_list)
        nenv = normalize_env(env['ENV'], vscommonvarnames + ['COMSPEC'])
        output = get_output(batfilename, arch, env=nenv)
        vars = parse_output(output, vars)

        for k, v in vars.items():
            env.PrependENVPath(k, v, delete_existing=1)
Example #2
0
def merge_default_version(env):
    version = get_default_version(env)
    arch = get_default_arch(env)

    msvs = get_vs_by_version(version)
    if msvs is None:
        return
    batfilename = msvs.get_batch_file()

    # XXX: I think this is broken. This will silently set a bogus tool instead
    # of failing, but there is no other way with the current scons tool
    # framework
    if batfilename is not None:

        vars = ('LIB', 'LIBPATH', 'PATH', 'INCLUDE')

        msvs_list = get_installed_visual_studios()
        # TODO(1.5):
        #vscommonvarnames = [ vs.common_tools_var for vs in msvs_list ]
        vscommonvarnames = map(lambda vs: vs.common_tools_var, msvs_list)
        nenv = normalize_env(env['ENV'], vscommonvarnames + ['COMSPEC'])
        output = get_output(batfilename, arch, env=nenv)
        vars = parse_output(output, vars)

        for k, v in vars.items():
            env.PrependENVPath(k, v, delete_existing=1)
Example #3
0
def fetchSDKVars(targetArch,versionString):
	common.debug("windowsSdk.py, fetchSDKVars: Searching for SDK %s"%versionString)
	archSwitch=scriptSwitchByTargetArch.get(targetArch)
	if not archSwitch:
		common.debug("windowsSdk.py, fetchSDKVars: Unsupported target arch: %s"%targetArch)
	try:
		versionKey=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\%s'%versionString)
	except Exception as e:
		common.debug("windowsSdk.py, fetchSDKVars: failed to open registry key for version %s: %s"%(versionString,e))
		return
	try:
		installDir=_winreg.QueryValueEx(versionKey,"InstallationFolder")[0]
	except Exception as e:
		common.debug("windowsSdk.py, fetchSDKVars: no InstallationFolder value in registry key: %s: %s"%(v,e))
		return
	if versionString=='v7.1A':
		#V7.1A (comes with vc2012) does not come with a batch file 
		d=dict(PATH=os.path.join(installDir,'bin'),INCLUDE=os.path.join(installDir,'include'),LIB=os.path.join(installDir,'lib'))
		if targetArch in ('x86_64','amd64'):
			d['PATH']=os.path.join(d['PATH'],'x64')
			d['LIB']=os.path.join(d['LIB'],'x64')
		return d
	scriptPath=os.path.join(installDir,os.path.join('bin','setenv.cmd'))
	if not os.path.isfile(scriptPath):
		common.debug("windowsSdk.py, fetchSDKVars: Script %s does not exist"%scriptPath)
		return
	p=subprocess.Popen(['cmd','/V','/c',scriptPath,archSwitch,'&&','set'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
	stdout,stderr=p.communicate()
	try:
		return common.parse_output(stdout)
	except Exception as e:
		common.debug("windowsSdk.py, fetchSDKVars: Error parsing script output: %s"%e)
		return
	common.debug("windowsSdk.py, fetchSDKVars: No suitable SDK could be used")
def fetchSDKVars(targetArch, versionString):
    common.debug("windowsSdk.py, fetchSDKVars: Searching for SDK %s" %
                 versionString)
    archSwitch = scriptSwitchByTargetArch.get(targetArch)
    if not archSwitch:
        common.debug(
            "windowsSdk.py, fetchSDKVars: Unsupported target arch: %s" %
            targetArch)
    try:
        versionKey = _winreg.OpenKey(
            _winreg.HKEY_LOCAL_MACHINE,
            r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\%s' % versionString)
    except Exception as e:
        common.debug(
            "windowsSdk.py, fetchSDKVars: failed to open registry key for version %s: %s"
            % (versionString, e))
        return
    try:
        installDir = _winreg.QueryValueEx(versionKey, "InstallationFolder")[0]
    except Exception as e:
        common.debug(
            "windowsSdk.py, fetchSDKVars: no InstallationFolder value in registry key: %s: %s"
            % (v, e))
        return
    if versionString == 'v7.1A':
        #V7.1A (comes with vc2012) does not come with a batch file
        d = dict(PATH=os.path.join(installDir, 'bin'),
                 INCLUDE=os.path.join(installDir, 'include'),
                 LIB=os.path.join(installDir, 'lib'))
        if targetArch in ('x86_64', 'amd64'):
            d['PATH'] = os.path.join(d['PATH'], 'x64')
            d['LIB'] = os.path.join(d['LIB'], 'x64')
        return d
    scriptPath = os.path.join(installDir, os.path.join('bin', 'setenv.cmd'))
    if not os.path.isfile(scriptPath):
        common.debug("windowsSdk.py, fetchSDKVars: Script %s does not exist" %
                     scriptPath)
        return
    p = subprocess.Popen(
        ['cmd', '/V', '/c', scriptPath, archSwitch, '&&', 'set'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    try:
        return common.parse_output(stdout)
    except Exception as e:
        common.debug(
            "windowsSdk.py, fetchSDKVars: Error parsing script output: %s" % e)
        return
    common.debug("windowsSdk.py, fetchSDKVars: No suitable SDK could be used")
Example #5
0
def generate_win32(env):
    # Import here to avoid importing msvc tool on every platform
    from SCons.Tool.MSCommon.common import get_output, parse_output

    abi = get_abi(env, lang='FORTRAN')

    # Get product dir
    versdict = find_fc_versions(abi)
    vers = sorted(versdict.keys())[::-1]
    pdir = product_dir_fc(versdict[vers[0]])
    batfile = os.path.join(pdir, "bin", "ifortvars.bat")

    out = get_output(batfile, args=_ABI2BATABI[abi])
    d = parse_output(out)
    for k, v in d.items():
        env.PrependENVPath(k, v, delete_existing=True)

    return old_generate(env)
Example #6
0
def generate_win32(env):
    # Import here to avoid importing msvc tool on every platform
    from SCons.Tool.MSCommon.common import get_output, parse_output

    abi = get_abi(env, lang='FORTRAN')

    # Get product dir
    versdict = find_fc_versions(abi)
    vers = sorted(versdict.keys())[::-1]
    pdir = product_dir_fc(versdict[vers[0]])
    batfile = os.path.join(pdir, "bin", "ifortvars.bat")

    out = get_output(batfile, args=_ABI2BATABI[abi])
    d = parse_output(out)
    for k, v in d.items():
        env.PrependENVPath(k, v, delete_existing=True)

    return old_generate(env)
Example #7
0
def generate(env):
    SCons.Tool.msvc.generate(env)

    # YOYOYOY
    batfile = r"C:\Program Files (x86)\Intel\Compiler\11.1\038\bin\iclvars.bat"
    out = get_output(batfile, args=_ABI2INTEL[abi])
    d = parse_output(out)
    for k, v in d.items():
	env.PrependENVPath(k, v, delete_existing=True)

    #static_obj, shared_obj = SCons.Tool.createObjBuilders(env)

    #for suffix in CSuffixes:
    #    static_obj.add_action(suffix, SCons.Defaults.CAction)
    #    shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
    #    static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
    #    shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
    env["CC"] = "icl"
    env["CFLAGS"] = SCons.Util.CLVar("/nologo")
    env["SHCC"] = "$CC"
Example #8
0
def generate(env):
    SCons.Tool.msvc.generate(env)

    # YOYOYOY
    batfile = r"C:\Program Files (x86)\Intel\Compiler\11.1\038\bin\iclvars.bat"
    out = get_output(batfile, args=_ABI2INTEL[abi])
    d = parse_output(out)
    for k, v in d.items():
        env.PrependENVPath(k, v, delete_existing=True)

        # static_obj, shared_obj = SCons.Tool.createObjBuilders(env)

        # for suffix in CSuffixes:
        #    static_obj.add_action(suffix, SCons.Defaults.CAction)
        #    shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
        #    static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
        #    shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
    env["CC"] = "icl"
    env["CFLAGS"] = SCons.Util.CLVar("/nologo")
    env["SHCC"] = "$CC"
Example #9
0
def fetchSDKVars(targetArch='x86',wantedVersion=None):
	archSwitch=scriptSwitchByTargetArch.get(targetArch)
	if not archSwitch:
		common.debug("windowsSdk.py, fetchSDKVars: Unsupported target arch: %s"%targetArch)
	try:
		versionsKey=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Microsoft SDKs\Windows')
	except Exception as e:
		common.debug("windowsSdk.py, fetchSDKVars: Windows SDK tool: no SDKs installed: root registry key not found, %s"%e)
		return None
	versionsKeyLen=_winreg.QueryInfoKey(versionsKey)[0]
	if versionsKeyLen<1:
		common.debug("windowsSdk.py, fetchSDKVars: No SDK versions found: root registry key empty")
		return None
	if wantedVersion:
		versionStrings=[wantedVersion]
	else:
		versionStrings=[x for x in (_winreg.EnumKey(versionsKey,index) for index in xrange(versionsKeyLen)) if x.startswith('v')]
	for v in reversed(versionStrings):
		try:
			versionKey=_winreg.OpenKey(versionsKey,v)
		except Exception as e:
			common.debug("windowsSdk.py, fetchSDKVars: failed to open registry key for version %s: %s"%(v,e))
			continue
		try:
			installDir=_winreg.QueryValueEx(versionKey,"InstallationFolder")[0]
		except Exception as e:
			common.debug("windowsSdk.py, fetchSDKVars: no InstallationFolder value in registry key: %s: %s"%(v,e))
			continue
		scriptPath=os.path.join(installDir,os.path.join('bin','setenv.cmd'))
		if not os.path.isfile(scriptPath):
			common.debug("windowsSdk.py, fetchSDKVars: Script %s does not exist"%scriptPath)
			continue
		p=subprocess.Popen(['cmd','/V','/c',scriptPath,archSwitch,'&&','set'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
		stdout,stderr=p.communicate()
		try:
			return common.parse_output(stdout)
		except Exception as e:
			common.debug("windowsSdk.py, fetchSDKVars: Error parsing script output: %s"%e)
			continue
	common.debug("windowsSdk.py, fetchSDKVars: No suitable SDK could be used")
	return None
Example #10
0
def generate_win32(env):
    # Import here to avoid importing msvc tool on every platform
    import SCons.Tool.msvc
    from SCons.Tool.MSCommon.common import get_output, parse_output
    SCons.Tool.msvc.generate(env)

    abi = get_abi(env)

    # Set up environment
    # XXX: detect this properly
    batfile = r"C:\Program Files (x86)\Intel\Compiler\11.1\038\bin\iclvars.bat"
    out = get_output(batfile, args=abi)
    d = parse_output(out)
    for k, v in d.items():
        env.PrependENVPath(k, v, delete_existing=True)

    env["CC"] = "icl"
    env["SHCC"] = "$CC"

    env["CXX"] = "icl"
    env["SHCXX"] = "$CXX"

    env["CCFLAGS"] = SCons.Util.CLVar("/nologo")
Example #11
0
def generate_win32(env):
    # Import here to avoid importing msvc tool on every platform
    import SCons.Tool.msvc
    from SCons.Tool.MSCommon.common import get_output, parse_output
    SCons.Tool.msvc.generate(env)

    abi = get_abi(env)

    # Set up environment
    # XXX: detect this properly
    batfile = r"C:\Program Files (x86)\Intel\Compiler\11.1\038\bin\iclvars.bat"
    out = get_output(batfile, args=abi)
    d = parse_output(out)
    for k, v in d.items():
        env.PrependENVPath(k, v, delete_existing=True)

    env["CC"] = "icl"
    env["SHCC"] = "$CC"

    env["CXX"] = "icl"
    env["SHCXX"] = "$CXX"

    env["CCFLAGS"] = SCons.Util.CLVar("/nologo")
Example #12
0
              'full':'/Debug',
              }
    args = '{build_arg} {arch_arg}'
    args = args.format(arch_arg = target_arch[get_option('ARCH')], build_arg = target_build[get_option('DEBUG')])
    import platform
    env_clone = env.Clone()
    env_clone['ENV']['PROCESSOR_ARCHITECTURE'] = platform.machine()
    for k in ['OS','windir']:
        env_clone['ENV'][k] = os.environ[k]
    stdout = get_output(sdk_dir + 'bin\\SetEnv.Cmd', args, env_clone)
    # Stupid batch files do not set return code: we take a look at the
    # beginning of the output for an error message instead
    olines = stdout.splitlines()
    if olines[0].startswith("The specified configuration type is missing"):
        raise racy.ToolError('mssdk', "\n".join(olines[:2]) )
    d = MSCommon.parse_output(stdout, ("INCLUDE", "LIB", "LIBPATH", "PATH"))
    for k, v in d.items():
        env.PrependENVPath(k, v, delete_existing=True)

#------------------------------------------------------------------------------

def get_output(vcbat, args , env ):
    """Parse the output of given bat file, with given args."""
    import subprocess
    system32_folder = os.environ['SystemRoot'] +'\System32'
    popen = SCons.Action._subproc(env,
                                  '"%s" %s & set' % (vcbat, args),
                                  stdin = 'devnull',
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE,
                                  cwd=system32_folder )#needed by bat script file (to find reg and cmd program)
Example #13
0
def fetchSDKVars(targetArch='x86', wantedVersion=None):
    archSwitch = scriptSwitchByTargetArch.get(targetArch)
    if not archSwitch:
        common.debug(
            "windowsSdk.py, fetchSDKVars: Unsupported target arch: %s" %
            targetArch)
    try:
        versionsKey = _winreg.OpenKey(
            _winreg.HKEY_LOCAL_MACHINE,
            r'SOFTWARE\Microsoft\Microsoft SDKs\Windows')
    except Exception as e:
        common.debug(
            "windowsSdk.py, fetchSDKVars: Windows SDK tool: no SDKs installed: root registry key not found, %s"
            % e)
        return None
    versionsKeyLen = _winreg.QueryInfoKey(versionsKey)[0]
    if versionsKeyLen < 1:
        common.debug(
            "windowsSdk.py, fetchSDKVars: No SDK versions found: root registry key empty"
        )
        return None
    if wantedVersion:
        versionStrings = [wantedVersion]
    else:
        versionStrings = [
            x for x in (_winreg.EnumKey(versionsKey, index)
                        for index in xrange(versionsKeyLen))
            if x.startswith('v')
        ]
    for v in reversed(versionStrings):
        try:
            versionKey = _winreg.OpenKey(versionsKey, v)
        except Exception as e:
            common.debug(
                "windowsSdk.py, fetchSDKVars: failed to open registry key for version %s: %s"
                % (v, e))
            continue
        try:
            installDir = _winreg.QueryValueEx(versionKey,
                                              "InstallationFolder")[0]
        except Exception as e:
            common.debug(
                "windowsSdk.py, fetchSDKVars: no InstallationFolder value in registry key: %s: %s"
                % (v, e))
            continue
        scriptPath = os.path.join(installDir,
                                  os.path.join('bin', 'setenv.cmd'))
        if not os.path.isfile(scriptPath):
            common.debug(
                "windowsSdk.py, fetchSDKVars: Script %s does not exist" %
                scriptPath)
            continue
        p = subprocess.Popen(
            ['cmd', '/V', '/c', scriptPath, archSwitch, '&&', 'set'],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
        try:
            return common.parse_output(stdout)
        except Exception as e:
            common.debug(
                "windowsSdk.py, fetchSDKVars: Error parsing script output: %s"
                % e)
            continue
    common.debug("windowsSdk.py, fetchSDKVars: No suitable SDK could be used")
    return None