2011-09-10 11:13:51 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# DC 2008
|
2017-02-11 16:13:37 +01:00
|
|
|
# Thomas Nagy 2016-2017 (ita)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 21:30:32 +02:00
|
|
|
import os, re
|
|
|
|
from waflib import Utils, Logs, Errors
|
|
|
|
from waflib.Tools import fc, fc_config, fc_scan, ar, ccroot
|
2011-09-10 11:13:51 +02:00
|
|
|
from waflib.Configure import conf
|
2016-06-25 21:30:32 +02:00
|
|
|
from waflib.TaskGen import after_method, feature
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def find_ifort(conf):
|
|
|
|
fc = conf.find_program('ifort', var='FC')
|
|
|
|
conf.get_ifort_version(fc)
|
|
|
|
conf.env.FC_NAME = 'IFORT'
|
|
|
|
|
|
|
|
@conf
|
2016-01-17 02:30:41 +01:00
|
|
|
def ifort_modifier_win32(self):
|
|
|
|
v = self.env
|
|
|
|
v.IFORT_WIN32 = True
|
2016-01-16 12:38:49 +01:00
|
|
|
v.FCSTLIB_MARKER = ''
|
|
|
|
v.FCSHLIB_MARKER = ''
|
|
|
|
|
|
|
|
v.FCLIB_ST = v.FCSTLIB_ST = '%s.lib'
|
|
|
|
v.FCLIBPATH_ST = v.STLIBPATH_ST = '/LIBPATH:%s'
|
|
|
|
v.FCINCPATH_ST = '/I%s'
|
|
|
|
v.FCDEFINES_ST = '/D%s'
|
|
|
|
|
|
|
|
v.fcprogram_PATTERN = v.fcprogram_test_PATTERN = '%s.exe'
|
|
|
|
v.fcshlib_PATTERN = '%s.dll'
|
|
|
|
v.fcstlib_PATTERN = v.implib_PATTERN = '%s.lib'
|
|
|
|
|
2016-01-17 02:30:41 +01:00
|
|
|
v.FCLNK_TGT_F = '/out:'
|
|
|
|
v.FC_TGT_F = ['/c', '/o', '']
|
2016-01-16 12:38:49 +01:00
|
|
|
v.FCFLAGS_fcshlib = ''
|
2016-01-20 00:12:42 +01:00
|
|
|
v.LINKFLAGS_fcshlib = '/DLL'
|
2016-01-16 12:38:49 +01:00
|
|
|
v.AR_TGT_F = '/out:'
|
2016-01-20 00:12:42 +01:00
|
|
|
v.IMPLIB_ST = '/IMPLIB:%s'
|
2011-10-26 22:04:34 +02:00
|
|
|
|
2016-01-17 03:27:30 +01:00
|
|
|
v.append_value('LINKFLAGS', '/subsystem:console')
|
|
|
|
if v.IFORT_MANIFEST:
|
|
|
|
v.append_value('LINKFLAGS', ['/MANIFEST'])
|
|
|
|
|
2011-10-26 22:04:34 +02:00
|
|
|
@conf
|
|
|
|
def ifort_modifier_darwin(conf):
|
|
|
|
fc_config.fortran_modifier_darwin(conf)
|
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
@conf
|
|
|
|
def ifort_modifier_platform(conf):
|
2016-01-17 02:30:41 +01:00
|
|
|
dest_os = conf.env.DEST_OS or Utils.unversioned_sys_platform()
|
2011-09-10 11:13:51 +02:00
|
|
|
ifort_modifier_func = getattr(conf, 'ifort_modifier_' + dest_os, None)
|
|
|
|
if ifort_modifier_func:
|
|
|
|
ifort_modifier_func()
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def get_ifort_version(conf, fc):
|
2016-06-26 11:59:27 +02:00
|
|
|
"""
|
|
|
|
Detects the compiler version and sets ``conf.env.FC_VERSION``
|
|
|
|
"""
|
2015-12-23 15:28:43 +01:00
|
|
|
version_re = re.compile(r"\bIntel\b.*\bVersion\s*(?P<major>\d*)\.(?P<minor>\d*)",re.I).search
|
2014-08-14 20:03:28 +02:00
|
|
|
if Utils.is_win32:
|
2014-08-28 11:27:44 +02:00
|
|
|
cmd = fc
|
2014-08-14 20:03:28 +02:00
|
|
|
else:
|
2014-08-18 19:47:11 +02:00
|
|
|
cmd = fc + ['-logo']
|
2014-08-14 20:03:28 +02:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
out, err = fc_config.getoutput(conf, cmd, stdin=False)
|
2015-03-10 16:59:53 +01:00
|
|
|
match = version_re(out) or version_re(err)
|
2011-09-10 11:13:51 +02:00
|
|
|
if not match:
|
|
|
|
conf.fatal('cannot determine ifort version.')
|
|
|
|
k = match.groupdict()
|
2016-06-25 23:54:12 +02:00
|
|
|
conf.env.FC_VERSION = (k['major'], k['minor'])
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
def configure(conf):
|
2016-06-26 11:59:27 +02:00
|
|
|
"""
|
|
|
|
Detects the Intel Fortran compilers
|
|
|
|
"""
|
2016-01-17 02:30:41 +01:00
|
|
|
if Utils.is_win32:
|
|
|
|
compiler, version, path, includes, libdirs, arch = conf.detect_ifort(True)
|
|
|
|
v = conf.env
|
|
|
|
v.DEST_CPU = arch
|
|
|
|
v.PATH = path
|
|
|
|
v.INCLUDES = includes
|
|
|
|
v.LIBPATH = libdirs
|
|
|
|
v.MSVC_COMPILER = compiler
|
|
|
|
try:
|
|
|
|
v.MSVC_VERSION = float(version)
|
|
|
|
except Exception:
|
|
|
|
raise
|
|
|
|
v.MSVC_VERSION = float(version[:-3])
|
|
|
|
|
|
|
|
conf.find_ifort_win32()
|
|
|
|
conf.ifort_modifier_win32()
|
|
|
|
else:
|
|
|
|
conf.find_ifort()
|
|
|
|
conf.find_program('xiar', var='AR')
|
|
|
|
conf.find_ar()
|
|
|
|
conf.fc_flags()
|
|
|
|
conf.fc_add_flags()
|
|
|
|
conf.ifort_modifier_platform()
|
|
|
|
|
|
|
|
|
|
|
|
all_ifort_platforms = [ ('intel64', 'amd64'), ('em64t', 'amd64'), ('ia32', 'x86'), ('Itanium', 'ia64')]
|
|
|
|
"""List of icl platforms"""
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def gather_ifort_versions(conf, versions):
|
2016-06-26 11:59:27 +02:00
|
|
|
"""
|
|
|
|
List compiler versions by looking up registry keys
|
|
|
|
"""
|
2016-01-17 02:30:41 +01:00
|
|
|
version_pattern = re.compile('^...?.?\....?.?')
|
|
|
|
try:
|
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432node\\Intel\\Compilers\\Fortran')
|
|
|
|
except WindowsError:
|
|
|
|
try:
|
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Intel\\Compilers\\Fortran')
|
|
|
|
except WindowsError:
|
|
|
|
return
|
|
|
|
index = 0
|
|
|
|
while 1:
|
|
|
|
try:
|
|
|
|
version = Utils.winreg.EnumKey(all_versions, index)
|
|
|
|
except WindowsError:
|
|
|
|
break
|
2016-05-22 00:45:47 +02:00
|
|
|
index += 1
|
2016-01-17 02:30:41 +01:00
|
|
|
if not version_pattern.match(version):
|
|
|
|
continue
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = {}
|
2016-01-17 02:30:41 +01:00
|
|
|
for target,arch in all_ifort_platforms:
|
2016-05-22 10:58:24 +02:00
|
|
|
if target=='intel64': targetDir='EM64T_NATIVE'
|
|
|
|
else: targetDir=target
|
2016-01-17 02:30:41 +01:00
|
|
|
try:
|
|
|
|
Utils.winreg.OpenKey(all_versions,version+'\\'+targetDir)
|
|
|
|
icl_version=Utils.winreg.OpenKey(all_versions,version)
|
|
|
|
path,type=Utils.winreg.QueryValueEx(icl_version,'ProductDir')
|
2016-05-22 10:58:24 +02:00
|
|
|
except WindowsError:
|
|
|
|
pass
|
|
|
|
else:
|
2016-01-17 02:30:41 +01:00
|
|
|
batch_file=os.path.join(path,'bin','iclvars.bat')
|
|
|
|
if os.path.isfile(batch_file):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'intel', arch, version, target, batch_file)
|
2016-05-22 10:58:24 +02:00
|
|
|
|
2016-01-17 02:30:41 +01:00
|
|
|
for target,arch in all_ifort_platforms:
|
|
|
|
try:
|
|
|
|
icl_version = Utils.winreg.OpenKey(all_versions, version+'\\'+target)
|
|
|
|
path,type = Utils.winreg.QueryValueEx(icl_version,'ProductDir')
|
2016-05-22 10:58:24 +02:00
|
|
|
except WindowsError:
|
|
|
|
continue
|
|
|
|
else:
|
2016-01-17 02:30:41 +01:00
|
|
|
batch_file=os.path.join(path,'bin','iclvars.bat')
|
|
|
|
if os.path.isfile(batch_file):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'intel', arch, version, target, batch_file)
|
2016-01-17 02:30:41 +01:00
|
|
|
major = version[0:2]
|
2016-05-22 18:27:57 +02:00
|
|
|
versions['intel ' + major] = targets
|
2016-01-17 02:30:41 +01:00
|
|
|
|
2016-05-22 17:11:29 +02:00
|
|
|
@conf
|
2016-05-22 18:27:57 +02:00
|
|
|
def setup_ifort(conf, versiondict):
|
2016-01-17 02:30:41 +01:00
|
|
|
"""
|
|
|
|
Checks installed compilers and targets and returns the first combination from the user's
|
|
|
|
options, env, or the global supported lists that checks.
|
|
|
|
|
2016-05-22 18:27:57 +02:00
|
|
|
:param versiondict: dict(platform -> dict(architecture -> configuration))
|
|
|
|
:type versiondict: dict(string -> dict(string -> target_compiler)
|
|
|
|
:return: the compiler, revision, path, include dirs, library paths and target architecture
|
2016-01-17 02:30:41 +01:00
|
|
|
:rtype: tuple of strings
|
|
|
|
"""
|
2016-06-25 23:54:12 +02:00
|
|
|
platforms = Utils.to_list(conf.env.MSVC_TARGETS) or [i for i,j in all_ifort_platforms]
|
|
|
|
desired_versions = conf.env.MSVC_VERSIONS or list(reversed(list(versiondict.keys())))
|
2016-01-17 02:30:41 +01:00
|
|
|
for version in desired_versions:
|
|
|
|
try:
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = versiondict[version]
|
2016-01-17 02:30:41 +01:00
|
|
|
except KeyError:
|
|
|
|
continue
|
2016-05-22 18:27:57 +02:00
|
|
|
for arch in platforms:
|
2016-05-22 03:07:44 +02:00
|
|
|
try:
|
2016-05-22 18:27:57 +02:00
|
|
|
cfg = targets[arch]
|
2016-05-22 03:07:44 +02:00
|
|
|
except KeyError:
|
|
|
|
continue
|
|
|
|
cfg.evaluate()
|
|
|
|
if cfg.is_valid:
|
|
|
|
compiler,revision = version.rsplit(' ', 1)
|
2016-05-22 12:40:51 +02:00
|
|
|
return compiler,revision,cfg.bindirs,cfg.incdirs,cfg.libdirs,cfg.cpu
|
2016-05-22 16:48:14 +02:00
|
|
|
conf.fatal('ifort: Impossible to find a valid architecture for building %r - %r' % (desired_versions, list(versiondict.keys())))
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def get_ifort_version_win32(conf, compiler, version, target, vcvars):
|
|
|
|
# FIXME hack
|
|
|
|
try:
|
|
|
|
conf.msvc_cnt += 1
|
|
|
|
except AttributeError:
|
|
|
|
conf.msvc_cnt = 1
|
|
|
|
batfile = conf.bldnode.make_node('waf-print-msvc-%d.bat' % conf.msvc_cnt)
|
|
|
|
batfile.write("""@echo off
|
|
|
|
set INCLUDE=
|
|
|
|
set LIB=
|
|
|
|
call "%s" %s
|
|
|
|
echo PATH=%%PATH%%
|
|
|
|
echo INCLUDE=%%INCLUDE%%
|
|
|
|
echo LIB=%%LIB%%;%%LIBPATH%%
|
|
|
|
""" % (vcvars,target))
|
|
|
|
sout = conf.cmd_and_log(['cmd.exe', '/E:on', '/V:on', '/C', batfile.abspath()])
|
|
|
|
batfile.delete()
|
|
|
|
lines = sout.splitlines()
|
|
|
|
|
|
|
|
if not lines[0]:
|
|
|
|
lines.pop(0)
|
|
|
|
|
|
|
|
MSVC_PATH = MSVC_INCDIR = MSVC_LIBDIR = None
|
|
|
|
for line in lines:
|
|
|
|
if line.startswith('PATH='):
|
|
|
|
path = line[5:]
|
|
|
|
MSVC_PATH = path.split(';')
|
|
|
|
elif line.startswith('INCLUDE='):
|
|
|
|
MSVC_INCDIR = [i for i in line[8:].split(';') if i]
|
|
|
|
elif line.startswith('LIB='):
|
|
|
|
MSVC_LIBDIR = [i for i in line[4:].split(';') if i]
|
|
|
|
if None in (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR):
|
2016-05-22 16:48:14 +02:00
|
|
|
conf.fatal('ifort: Could not find a valid architecture for building (get_ifort_version_win32)')
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
# Check if the compiler is usable at all.
|
|
|
|
# The detection may return 64-bit versions even on 32-bit systems, and these would fail to run.
|
|
|
|
env = dict(os.environ)
|
|
|
|
env.update(PATH = path)
|
|
|
|
compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
|
|
|
|
fc = conf.find_program(compiler_name, path_list=MSVC_PATH)
|
|
|
|
|
|
|
|
# delete CL if exists. because it could contain parameters wich can change cl's behaviour rather catastrophically.
|
|
|
|
if 'CL' in env:
|
|
|
|
del(env['CL'])
|
|
|
|
|
|
|
|
try:
|
2016-05-18 22:01:37 +02:00
|
|
|
conf.cmd_and_log(fc + ['/help'], env=env)
|
|
|
|
except UnicodeError:
|
|
|
|
st = Utils.ex_stack()
|
|
|
|
if conf.logger:
|
|
|
|
conf.logger.error(st)
|
2016-05-22 16:48:14 +02:00
|
|
|
conf.fatal('ifort: Unicode error - check the code page?')
|
2016-05-18 22:01:37 +02:00
|
|
|
except Exception as e:
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.debug('ifort: get_ifort_version: %r %r %r -> failure %s', compiler, version, target, str(e))
|
2016-05-22 16:48:14 +02:00
|
|
|
conf.fatal('ifort: cannot run the compiler in get_ifort_version (run with -v to display errors)')
|
2016-05-18 22:01:37 +02:00
|
|
|
else:
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.debug('ifort: get_ifort_version: %r %r %r -> OK', compiler, version, target)
|
2016-01-17 02:30:41 +01:00
|
|
|
finally:
|
|
|
|
conf.env[compiler_name] = ''
|
|
|
|
|
|
|
|
return (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR)
|
|
|
|
|
2016-05-22 03:07:44 +02:00
|
|
|
class target_compiler(object):
|
2016-05-22 12:12:32 +02:00
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Wraps a compiler configuration; call evaluate() to determine
|
2016-05-22 12:12:32 +02:00
|
|
|
whether the configuration is usable.
|
|
|
|
"""
|
2016-05-22 12:04:23 +02:00
|
|
|
def __init__(self, ctx, compiler, cpu, version, bat_target, bat, callback=None):
|
2016-05-22 12:12:32 +02:00
|
|
|
"""
|
|
|
|
:param ctx: configuration context to use to eventually get the version environment
|
|
|
|
:param compiler: compiler name
|
|
|
|
:param cpu: target cpu
|
|
|
|
:param version: compiler version number
|
|
|
|
:param bat_target: ?
|
|
|
|
:param bat: path to the batch file to run
|
|
|
|
:param callback: optional function to take the realized environment variables tup and map it (e.g. to combine other constant paths)
|
|
|
|
"""
|
2016-05-22 03:07:44 +02:00
|
|
|
self.conf = ctx
|
|
|
|
self.name = None
|
|
|
|
self.is_valid = False
|
|
|
|
self.is_done = False
|
|
|
|
|
|
|
|
self.compiler = compiler
|
2016-05-22 12:04:23 +02:00
|
|
|
self.cpu = cpu
|
2016-05-22 03:07:44 +02:00
|
|
|
self.version = version
|
|
|
|
self.bat_target = bat_target
|
|
|
|
self.bat = bat
|
|
|
|
self.callback = callback
|
|
|
|
|
|
|
|
def evaluate(self):
|
|
|
|
if self.is_done:
|
|
|
|
return
|
|
|
|
self.is_done = True
|
|
|
|
try:
|
|
|
|
vs = self.conf.get_msvc_version(self.compiler, self.version, self.bat_target, self.bat)
|
2016-06-05 00:23:57 +02:00
|
|
|
except Errors.ConfigurationError:
|
2016-05-22 03:07:44 +02:00
|
|
|
self.is_valid = False
|
|
|
|
return
|
|
|
|
if self.callback:
|
|
|
|
vs = self.callback(self, vs)
|
|
|
|
self.is_valid = True
|
|
|
|
(self.bindirs, self.incdirs, self.libdirs) = vs
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str((self.bindirs, self.incdirs, self.libdirs))
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return repr((self.bindirs, self.incdirs, self.libdirs))
|
|
|
|
|
2016-05-22 16:57:22 +02:00
|
|
|
@conf
|
2016-05-22 18:27:57 +02:00
|
|
|
def detect_ifort(self):
|
|
|
|
return self.setup_ifort(self.get_ifort_versions(False))
|
2016-05-22 16:57:22 +02:00
|
|
|
|
2016-01-17 02:30:41 +01:00
|
|
|
@conf
|
2016-05-22 17:06:53 +02:00
|
|
|
def get_ifort_versions(self, eval_and_save=True):
|
2016-01-17 02:30:41 +01:00
|
|
|
"""
|
2016-05-22 18:27:57 +02:00
|
|
|
:return: platforms to compiler configurations
|
|
|
|
:rtype: dict
|
2016-01-17 02:30:41 +01:00
|
|
|
"""
|
2016-05-22 18:27:57 +02:00
|
|
|
dct = {}
|
|
|
|
self.gather_ifort_versions(dct)
|
|
|
|
return dct
|
2016-01-17 02:30:41 +01:00
|
|
|
|
2016-05-22 17:06:53 +02:00
|
|
|
def _get_prog_names(self, compiler):
|
2016-01-17 02:30:41 +01:00
|
|
|
if compiler=='intel':
|
|
|
|
compiler_name = 'ifort'
|
|
|
|
linker_name = 'XILINK'
|
|
|
|
lib_name = 'XILIB'
|
|
|
|
else:
|
|
|
|
# assumes CL.exe
|
|
|
|
compiler_name = 'CL'
|
|
|
|
linker_name = 'LINK'
|
|
|
|
lib_name = 'LIB'
|
|
|
|
return compiler_name, linker_name, lib_name
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def find_ifort_win32(conf):
|
|
|
|
# the autodetection is supposed to be performed before entering in this method
|
|
|
|
v = conf.env
|
2016-06-25 23:54:12 +02:00
|
|
|
path = v.PATH
|
|
|
|
compiler = v.MSVC_COMPILER
|
|
|
|
version = v.MSVC_VERSION
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
|
2016-01-17 03:27:30 +01:00
|
|
|
v.IFORT_MANIFEST = (compiler == 'intel' and version >= 11)
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
# compiler
|
|
|
|
fc = conf.find_program(compiler_name, var='FC', path_list=path)
|
|
|
|
|
|
|
|
# before setting anything, check if the compiler is really intel fortran
|
|
|
|
env = dict(conf.environ)
|
|
|
|
if path: env.update(PATH = ';'.join(path))
|
|
|
|
if not conf.cmd_and_log(fc + ['/nologo', '/help'], env=env):
|
|
|
|
conf.fatal('not intel fortran compiler could not be identified')
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.FC_NAME = 'IFORT'
|
2016-01-18 15:54:35 +01:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
if not v.LINK_FC:
|
2016-01-17 02:30:41 +01:00
|
|
|
conf.find_program(linker_name, var='LINK_FC', path_list=path, mandatory=True)
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
if not v.AR:
|
2016-01-17 02:30:41 +01:00
|
|
|
conf.find_program(lib_name, path_list=path, var='AR', mandatory=True)
|
2016-06-25 23:54:12 +02:00
|
|
|
v.ARFLAGS = ['/nologo']
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
# manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
|
2016-01-17 03:27:30 +01:00
|
|
|
if v.IFORT_MANIFEST:
|
2016-01-17 02:30:41 +01:00
|
|
|
conf.find_program('MT', path_list=path, var='MT')
|
2016-06-25 23:54:12 +02:00
|
|
|
v.MTFLAGS = ['/nologo']
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
conf.load('winres')
|
|
|
|
except Errors.WafError:
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.warn('Resource compiler not found. Compiling resource file is disabled')
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
#######################################################################################################
|
|
|
|
##### conf above, build below
|
|
|
|
|
|
|
|
@after_method('apply_link')
|
|
|
|
@feature('fc')
|
|
|
|
def apply_flags_ifort(self):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Adds additional flags implied by msvc, such as subsystems and pdb files::
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
bld.stlib(source='main.c', target='bar', subsystem='gruik')
|
|
|
|
"""
|
|
|
|
if not self.env.IFORT_WIN32 or not getattr(self, 'link_task', None):
|
|
|
|
return
|
|
|
|
|
|
|
|
is_static = isinstance(self.link_task, ccroot.stlink_task)
|
|
|
|
|
|
|
|
subsystem = getattr(self, 'subsystem', '')
|
|
|
|
if subsystem:
|
|
|
|
subsystem = '/subsystem:%s' % subsystem
|
|
|
|
flags = is_static and 'ARFLAGS' or 'LINKFLAGS'
|
|
|
|
self.env.append_value(flags, subsystem)
|
|
|
|
|
|
|
|
if not is_static:
|
|
|
|
for f in self.env.LINKFLAGS:
|
|
|
|
d = f.lower()
|
|
|
|
if d[1:] == 'debug':
|
|
|
|
pdbnode = self.link_task.outputs[0].change_ext('.pdb')
|
|
|
|
self.link_task.outputs.append(pdbnode)
|
|
|
|
|
|
|
|
if getattr(self, 'install_task', None):
|
2016-05-17 19:49:44 +02:00
|
|
|
self.pdb_install_task = self.add_install_files(install_to=self.install_task.install_to, install_from=pdbnode)
|
2016-01-17 02:30:41 +01:00
|
|
|
|
|
|
|
break
|
|
|
|
|
2016-01-19 21:08:48 +01:00
|
|
|
@feature('fcprogram', 'fcshlib', 'fcprogram_test')
|
2016-01-17 02:30:41 +01:00
|
|
|
@after_method('apply_link')
|
|
|
|
def apply_manifest_ifort(self):
|
2016-06-25 14:49:27 +02:00
|
|
|
"""
|
|
|
|
Enables manifest embedding in Fortran DLLs when using ifort on Windows
|
|
|
|
See: http://msdn2.microsoft.com/en-us/library/ms235542(VS.80).aspx
|
|
|
|
"""
|
2016-01-17 02:30:41 +01:00
|
|
|
if self.env.IFORT_WIN32 and getattr(self, 'link_task', None):
|
2016-01-17 03:27:30 +01:00
|
|
|
# it seems ifort.exe cannot be called for linking
|
2016-01-17 02:30:41 +01:00
|
|
|
self.link_task.env.FC = self.env.LINK_FC
|
|
|
|
|
2016-01-17 03:27:30 +01:00
|
|
|
if self.env.IFORT_WIN32 and self.env.IFORT_MANIFEST and getattr(self, 'link_task', None):
|
2016-01-17 02:30:41 +01:00
|
|
|
out_node = self.link_task.outputs[0]
|
|
|
|
man_node = out_node.parent.find_or_declare(out_node.name + '.manifest')
|
|
|
|
self.link_task.outputs.append(man_node)
|
2016-06-16 21:39:50 +02:00
|
|
|
self.env.DO_MANIFEST = True
|
2011-10-26 22:04:34 +02:00
|
|
|
|