desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Initializes the user file.
Args:
user_file_path: Path to the user file.
version: Version info.
name: Name of the user file.'
| def __init__(self, user_file_path, version, name):
| self.user_file_path = user_file_path
self.version = version
self.name = name
self.configurations = {}
|
'Adds a configuration to the project.
Args:
name: Configuration name.'
| def AddConfig(self, name):
| self.configurations[name] = ['Configuration', {'Name': name}]
|
'Adds a DebugSettings node to the user file for a particular config.
Args:
command: command line to run. First element in the list is the
executable. All elements of the command will be quoted if
necessary.
working_directory: other files which may trigger the rule. (optional)'
| def AddDebugSettings(self, config_name, command, environment={}, working_directory=''):
| command = _QuoteWin32CommandLineArgs(command)
abs_command = _FindCommandInPath(command[0])
if (environment and isinstance(environment, dict)):
env_list = [('%s="%s"' % (key, val)) for (key, val) in environment.iteritems()]
environment = ' '.join(env_list)
else:
environment = ''
n_cmd = ['DebugSettings', {'Command': abs_command, 'WorkingDirectory': working_directory, 'CommandArguments': ' '.join(command[1:]), 'RemoteMachine': socket.gethostname(), 'Environment': environment, 'EnvironmentMerge': 'true', 'Attach': 'false', 'DebuggerType': '3', 'Remote': '1', 'RemoteCommand': '', 'HttpUrl': '', 'PDBPath': '', 'SQLDebugging': '', 'DebuggerFlavor': '0', 'MPIRunCommand': '', 'MPIRunArguments': '', 'MPIRunWorkingDirectory': '', 'ApplicationCommand': '', 'ApplicationArguments': '', 'ShimCommand': '', 'MPIAcceptMode': '', 'MPIAcceptFilter': ''}]
if (config_name not in self.configurations):
self.AddConfig(config_name)
self.configurations[config_name].append(n_cmd)
|
'Writes the user file.'
| def WriteIfChanged(self):
| configs = ['Configurations']
for (config, spec) in sorted(self.configurations.iteritems()):
configs.append(spec)
content = ['VisualStudioUserFile', {'Version': self.version.ProjectVersion(), 'Name': self.name}, configs]
easy_xml.WriteXmlIfChanged(content, self.user_file_path, encoding='Windows-1252')
|
'Allows to use a unique instance of mspdbsrv.exe per linker instead of a
shared one.'
| def _UseSeparateMspdbsrv(self, env, args):
| if (len(args) < 1):
raise Exception('Not enough arguments')
if (args[0] != 'link.exe'):
return
endpoint_name = None
for arg in args:
m = _LINK_EXE_OUT_ARG.match(arg)
if m:
endpoint_name = re.sub('\\W+', '', ('%s_%d' % (m.group('out'), os.getpid())))
break
if (endpoint_name is None):
return
env['_MSPDBSRV_ENDPOINT_'] = endpoint_name
|
'Dispatches a string command to a method.'
| def Dispatch(self, args):
| if (len(args) < 1):
raise Exception('Not enough arguments')
method = ('Exec%s' % self._CommandifyName(args[0]))
return getattr(self, method)(*args[1:])
|
'Transforms a tool name like recursive-mirror to RecursiveMirror.'
| def _CommandifyName(self, name_string):
| return name_string.title().replace('-', '')
|
'Gets the saved environment from a file for a given architecture.'
| def _GetEnv(self, arch):
| pairs = open(arch).read()[:(-2)].split('\x00')
kvs = [item.split('=', 1) for item in pairs]
return dict(kvs)
|
'Simple stamp command.'
| def ExecStamp(self, path):
| open(path, 'w').close()
|
'Emulation of rm -rf out && cp -af in out.'
| def ExecRecursiveMirror(self, source, dest):
| if os.path.exists(dest):
if os.path.isdir(dest):
def _on_error(fn, path, excinfo):
if (not os.access(path, os.W_OK)):
os.chmod(path, stat.S_IWRITE)
fn(path)
shutil.rmtree(dest, onerror=_on_error)
else:
if (not os.access(dest, os.W_OK)):
os.chmod(dest, stat.S_IWRITE)
os.unlink(dest)
if os.path.isdir(source):
shutil.copytree(source, dest)
else:
shutil.copy2(source, dest)
|
'Filter diagnostic output from link that looks like:
\' Creating library ui.dll.lib and object ui.dll.exp\'
This happens when there are exports from the dll or exe.'
| def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args):
| env = self._GetEnv(arch)
if (use_separate_mspdbsrv == 'True'):
self._UseSeparateMspdbsrv(env, args)
link = subprocess.Popen(([args[0].replace('/', '\\')] + list(args[1:])), shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = link.communicate()
for line in out.splitlines():
if ((not line.startswith(' Creating library ')) and (not line.startswith('Generating code')) and (not line.startswith('Finished generating code'))):
print line
return link.returncode
|
'A wrapper for handling creating a manifest resource and then executing
a link command.'
| def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, mt, rc, intermediate_manifest, *manifests):
| variables = {'python': sys.executable, 'arch': arch, 'out': out, 'ldcmd': ldcmd, 'resname': resname, 'mt': mt, 'rc': rc, 'intermediate_manifest': intermediate_manifest, 'manifests': ' '.join(manifests)}
add_to_ld = ''
if manifests:
subprocess.check_call(('%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo -manifest %(manifests)s -out:%(out)s.manifest' % variables))
if (embed_manifest == 'True'):
subprocess.check_call(('%(python)s gyp-win-tool manifest-to-rc %(arch)s %(out)s.manifest %(out)s.manifest.rc %(resname)s' % variables))
subprocess.check_call(('%(python)s gyp-win-tool rc-wrapper %(arch)s %(rc)s %(out)s.manifest.rc' % variables))
add_to_ld = (' %(out)s.manifest.res' % variables)
subprocess.check_call((ldcmd + add_to_ld))
if manifests:
subprocess.check_call(('%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo -manifest %(out)s.manifest %(intermediate_manifest)s -out:%(out)s.assert.manifest' % variables))
assert_manifest = ('%(out)s.assert.manifest' % variables)
our_manifest = ('%(out)s.manifest' % variables)
with open(our_manifest, 'rb') as our_f:
with open(assert_manifest, 'rb') as assert_f:
our_data = our_f.read().translate(None, string.whitespace)
assert_data = assert_f.read().translate(None, string.whitespace)
if (our_data != assert_data):
os.unlink(out)
def dump(filename):
sys.stderr.write(('%s\n-----\n' % filename))
with open(filename, 'rb') as f:
sys.stderr.write((f.read() + '\n-----\n'))
dump(intermediate_manifest)
dump(our_manifest)
dump(assert_manifest)
sys.stderr.write(('Linker generated manifest "%s" added to final manifest "%s" (result in "%s"). Were /MANIFEST switches used in #pragma statements? ' % (intermediate_manifest, our_manifest, assert_manifest)))
return 1
|
'Run manifest tool with environment set. Strip out undesirable warning
(some XML blocks are recognized by the OS loader, but not the manifest
tool).'
| def ExecManifestWrapper(self, arch, *args):
| env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = popen.communicate()
for line in out.splitlines():
if (line and ('manifest authoring warning 81010002' not in line)):
print line
return popen.returncode
|
'Creates a resource file pointing a SxS assembly manifest.
|args| is tuple containing path to resource file, path to manifest file
and resource name which can be "1" (for executables) or "2" (for DLLs).'
| def ExecManifestToRc(self, arch, *args):
| (manifest_path, resource_path, resource_name) = args
with open(resource_path, 'wb') as output:
output.write(('#include <windows.h>\n%s RT_MANIFEST "%s"' % (resource_name, os.path.abspath(manifest_path).replace('\\', '/'))))
|
'Filter noisy filenames output from MIDL compile step that isn\'t
quietable via command line flags.'
| def ExecMidlWrapper(self, arch, outdir, tlb, h, dlldata, iid, proxy, idl, *flags):
| args = ((['midl', '/nologo'] + list(flags)) + ['/out', outdir, '/tlb', tlb, '/h', h, '/dlldata', dlldata, '/iid', iid, '/proxy', proxy, idl])
env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = popen.communicate()
lines = out.splitlines()
prefixes = ('Processing ', '64 bit Processing ')
processing = set((os.path.basename(x) for x in lines if x.startswith(prefixes)))
for line in lines:
if ((not line.startswith(prefixes)) and (line not in processing)):
print line
return popen.returncode
|
'Filter logo banner from invocations of asm.exe.'
| def ExecAsmWrapper(self, arch, *args):
| env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = popen.communicate()
for line in out.splitlines():
if ((not line.startswith('Copyright (C) Microsoft Corporation')) and (not line.startswith('Microsoft (R) Macro Assembler')) and (not line.startswith(' Assembling: ')) and line):
print line
return popen.returncode
|
'Filter logo banner from invocations of rc.exe. Older versions of RC
don\'t support the /nologo flag.'
| def ExecRcWrapper(self, arch, *args):
| env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = popen.communicate()
for line in out.splitlines():
if ((not line.startswith('Microsoft (R) Windows (R) Resource Compiler')) and (not line.startswith('Copyright (C) Microsoft Corporation')) and line):
print line
return popen.returncode
|
'Runs an action command line from a response file using the environment
for |arch|. If |dir| is supplied, use that as the working directory.'
| def ExecActionWrapper(self, arch, rspfile, *dir):
| env = self._GetEnv(arch)
for (k, v) in os.environ.iteritems():
if (k not in env):
env[k] = v
args = open(rspfile).read()
dir = (dir[0] if dir else None)
return subprocess.call(args, shell=True, env=env, cwd=dir)
|
'Executed by msvs-ninja projects when the \'ClCompile\' target is used to
build selected C/C++ files.'
| def ExecClCompile(self, project_dir, selected_files):
| project_dir = os.path.relpath(project_dir, BASE_DIR)
selected_files = selected_files.split(';')
ninja_targets = [(os.path.join(project_dir, filename) + '^^') for filename in selected_files]
cmd = ['ninja.exe']
cmd.extend(ninja_targets)
return subprocess.call(cmd, shell=True, cwd=BASE_DIR)
|
'Returns the extension for the target, with no leading dot.
Uses \'product_extension\' if specified, otherwise uses MSVS defaults based on
the target type.'
| def GetExtension(self):
| ext = self.spec.get('product_extension', None)
if ext:
return ext
return gyp.MSVSUtil.TARGET_TYPE_EXT.get(self.spec['type'], '')
|
'Get a dict of variables mapping internal VS macro names to their gyp
equivalents.'
| def GetVSMacroEnv(self, base_to_build=None, config=None):
| target_platform = ('Win32' if (self.GetArch(config) == 'x86') else 'x64')
target_name = (self.spec.get('product_prefix', '') + self.spec.get('product_name', self.spec['target_name']))
target_dir = ((base_to_build + '\\') if base_to_build else '')
target_ext = ('.' + self.GetExtension())
target_file_name = (target_name + target_ext)
replacements = {'$(InputName)': '${root}', '$(InputPath)': '${source}', '$(IntDir)': '$!INTERMEDIATE_DIR', '$(OutDir)\\': target_dir, '$(PlatformName)': target_platform, '$(ProjectDir)\\': '', '$(ProjectName)': self.spec['target_name'], '$(TargetDir)\\': target_dir, '$(TargetExt)': target_ext, '$(TargetFileName)': target_file_name, '$(TargetName)': target_name, '$(TargetPath)': os.path.join(target_dir, target_file_name)}
replacements.update(GetGlobalVSMacroEnv(self.vs_version))
return replacements
|
'Convert from VS macro names to something equivalent.'
| def ConvertVSMacros(self, s, base_to_build=None, config=None):
| env = self.GetVSMacroEnv(base_to_build, config=config)
return ExpandMacros(s, env)
|
'Strip -l from library if it\'s specified with that.'
| def AdjustLibraries(self, libraries):
| libs = [(lib[2:] if lib.startswith('-l') else lib) for lib in libraries]
return [((lib + '.lib') if (not lib.endswith('.lib')) else lib) for lib in libs]
|
'Retrieve a value from |field| at |path| or return |default|. If
|append| is specified, and the item is found, it will be appended to that
object instead of returned. If |map| is specified, results will be
remapped through |map| before being returned or appended.'
| def _GetAndMunge(self, field, path, default, prefix, append, map):
| result = _GenericRetrieve(field, default, path)
result = _DoRemapping(result, map)
result = _AddPrefix(result, prefix)
return _AppendOrReturn(append, result)
|
'Get architecture based on msvs_configuration_platform and
msvs_target_platform. Returns either \'x86\' or \'x64\'.'
| def GetArch(self, config):
| configuration_platform = self.msvs_configuration_platform.get(config, '')
platform = self.msvs_target_platform.get(config, '')
if (not platform):
platform = configuration_platform
return {'Win32': 'x86', 'x64': 'x64'}.get(platform, 'x86')
|
'Returns the target-specific configuration.'
| def _TargetConfig(self, config):
| arch = self.GetArch(config)
if ((arch == 'x64') and (not config.endswith('_x64'))):
config += '_x64'
if ((arch == 'x86') and config.endswith('_x64')):
config = config.rsplit('_', 1)[0]
return config
|
'_GetAndMunge for msvs_settings.'
| def _Setting(self, path, config, default=None, prefix='', append=None, map=None):
| return self._GetAndMunge(self.msvs_settings[config], path, default, prefix, append, map)
|
'_GetAndMunge for msvs_configuration_attributes.'
| def _ConfigAttrib(self, path, config, default=None, prefix='', append=None, map=None):
| return self._GetAndMunge(self.msvs_configuration_attributes[config], path, default, prefix, append, map)
|
'Updates include_dirs to expand VS specific paths, and adds the system
include dirs used for platform SDK and similar.'
| def AdjustIncludeDirs(self, include_dirs, config):
| config = self._TargetConfig(config)
includes = (include_dirs + self.msvs_system_include_dirs[config])
includes.extend(self._Setting(('VCCLCompilerTool', 'AdditionalIncludeDirectories'), config, default=[]))
return [self.ConvertVSMacros(p, config=config) for p in includes]
|
'Updates midl_include_dirs to expand VS specific paths, and adds the
system include dirs used for platform SDK and similar.'
| def AdjustMidlIncludeDirs(self, midl_include_dirs, config):
| config = self._TargetConfig(config)
includes = (midl_include_dirs + self.msvs_system_include_dirs[config])
includes.extend(self._Setting(('VCMIDLTool', 'AdditionalIncludeDirectories'), config, default=[]))
return [self.ConvertVSMacros(p, config=config) for p in includes]
|
'Returns the set of defines that are injected to the defines list based
on other VS settings.'
| def GetComputedDefines(self, config):
| config = self._TargetConfig(config)
defines = []
if (self._ConfigAttrib(['CharacterSet'], config) == '1'):
defines.extend(('_UNICODE', 'UNICODE'))
if (self._ConfigAttrib(['CharacterSet'], config) == '2'):
defines.append('_MBCS')
defines.extend(self._Setting(('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[]))
return defines
|
'Get the pdb file name that should be used for compiler invocations, or
None if there\'s no explicit name specified.'
| def GetCompilerPdbName(self, config, expand_special):
| config = self._TargetConfig(config)
pdbname = self._Setting(('VCCLCompilerTool', 'ProgramDataBaseFileName'), config)
if pdbname:
pdbname = expand_special(self.ConvertVSMacros(pdbname))
return pdbname
|
'Gets the explicitly overriden map file name for a target or returns None
if it\'s not set.'
| def GetMapFileName(self, config, expand_special):
| config = self._TargetConfig(config)
map_file = self._Setting(('VCLinkerTool', 'MapFileName'), config)
if map_file:
map_file = expand_special(self.ConvertVSMacros(map_file, config=config))
return map_file
|
'Gets the explicitly overridden output name for a target or returns None
if it\'s not overridden.'
| def GetOutputName(self, config, expand_special):
| config = self._TargetConfig(config)
type = self.spec['type']
root = ('VCLibrarianTool' if (type == 'static_library') else 'VCLinkerTool')
output_file = self._Setting((root, 'OutputFile'), config)
if output_file:
output_file = expand_special(self.ConvertVSMacros(output_file, config=config))
return output_file
|
'Gets the explicitly overridden pdb name for a target or returns
default if it\'s not overridden, or if no pdb will be generated.'
| def GetPDBName(self, config, expand_special, default):
| config = self._TargetConfig(config)
output_file = self._Setting(('VCLinkerTool', 'ProgramDatabaseFile'), config)
generate_debug_info = self._Setting(('VCLinkerTool', 'GenerateDebugInformation'), config)
if (generate_debug_info == 'true'):
if output_file:
return expand_special(self.ConvertVSMacros(output_file, config=config))
else:
return default
else:
return None
|
'If NoImportLibrary: true, ninja will not expect the output to include
an import library.'
| def GetNoImportLibrary(self, config):
| config = self._TargetConfig(config)
noimplib = self._Setting(('NoImportLibrary',), config)
return (noimplib == 'true')
|
'Returns the flags that need to be added to ml invocations.'
| def GetAsmflags(self, config):
| config = self._TargetConfig(config)
asmflags = []
safeseh = self._Setting(('MASM', 'UseSafeExceptionHandlers'), config)
if (safeseh == 'true'):
asmflags.append('/safeseh')
return asmflags
|
'Returns the flags that need to be added to .c and .cc compilations.'
| def GetCflags(self, config):
| config = self._TargetConfig(config)
cflags = []
cflags.extend([('/wd' + w) for w in self.msvs_disabled_warnings[config]])
cl = self._GetWrapper(self, self.msvs_settings[config], 'VCCLCompilerTool', append=cflags)
cl('Optimization', map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O', default='2')
cl('InlineFunctionExpansion', prefix='/Ob')
cl('DisableSpecificWarnings', prefix='/wd')
cl('StringPooling', map={'true': '/GF'})
cl('EnableFiberSafeOptimizations', map={'true': '/GT'})
cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy')
cl('EnableIntrinsicFunctions', map={'false': '-', 'true': ''}, prefix='/Oi')
cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O')
cl('FloatingPointModel', map={'0': 'precise', '1': 'strict', '2': 'fast'}, prefix='/fp:', default='0')
cl('CompileAsManaged', map={'false': '', 'true': '/clr'})
cl('WholeProgramOptimization', map={'true': '/GL'})
cl('WarningLevel', prefix='/W')
cl('WarnAsError', map={'true': '/WX'})
cl('CallingConvention', map={'0': 'd', '1': 'r', '2': 'z', '3': 'v'}, prefix='/G')
cl('DebugInformationFormat', map={'1': '7', '3': 'i', '4': 'I'}, prefix='/Z')
cl('RuntimeTypeInfo', map={'true': '/GR', 'false': '/GR-'})
cl('EnableFunctionLevelLinking', map={'true': '/Gy', 'false': '/Gy-'})
cl('MinimalRebuild', map={'true': '/Gm'})
cl('BufferSecurityCheck', map={'true': '/GS', 'false': '/GS-'})
cl('BasicRuntimeChecks', map={'1': 's', '2': 'u', '3': '1'}, prefix='/RTC')
cl('RuntimeLibrary', map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M')
cl('ExceptionHandling', map={'1': 'sc', '2': 'a'}, prefix='/EH')
cl('DefaultCharIsUnsigned', map={'true': '/J'})
cl('TreatWChar_tAsBuiltInType', map={'false': '-', 'true': ''}, prefix='/Zc:wchar_t')
cl('EnablePREfast', map={'true': '/analyze'})
cl('AdditionalOptions', prefix='')
cl('EnableEnhancedInstructionSet', map={'1': 'SSE', '2': 'SSE2', '3': 'AVX', '4': 'IA32', '5': 'AVX2'}, prefix='/arch:')
cflags.extend([('/FI' + f) for f in self._Setting(('VCCLCompilerTool', 'ForcedIncludeFiles'), config, default=[])])
if (self.vs_version.short_name in ('2013', '2013e', '2015')):
cflags.append('/FS')
cflags = filter((lambda x: (not x.startswith('/MP'))), cflags)
return cflags
|
'Get the flags to be added to the cflags for precompiled header support.'
| def _GetPchFlags(self, config, extension):
| config = self._TargetConfig(config)
if self.msvs_precompiled_header[config]:
source_ext = os.path.splitext(self.msvs_precompiled_source[config])[1]
if _LanguageMatchesForPch(source_ext, extension):
pch = os.path.split(self.msvs_precompiled_header[config])[1]
return [('/Yu' + pch), ('/FI' + pch), (('/Fp${pchprefix}.' + pch) + '.pch')]
return []
|
'Returns the flags that need to be added to .c compilations.'
| def GetCflagsC(self, config):
| config = self._TargetConfig(config)
return self._GetPchFlags(config, '.c')
|
'Returns the flags that need to be added to .cc compilations.'
| def GetCflagsCC(self, config):
| config = self._TargetConfig(config)
return (['/TP'] + self._GetPchFlags(config, '.cc'))
|
'Get and normalize the list of paths in AdditionalLibraryDirectories
setting.'
| def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path):
| config = self._TargetConfig(config)
libpaths = self._Setting((root, 'AdditionalLibraryDirectories'), config, default=[])
libpaths = [os.path.normpath(gyp_to_build_path(self.ConvertVSMacros(p, config=config))) for p in libpaths]
return [(('/LIBPATH:"' + p) + '"') for p in libpaths]
|
'Returns the flags that need to be added to lib commands.'
| def GetLibFlags(self, config, gyp_to_build_path):
| config = self._TargetConfig(config)
libflags = []
lib = self._GetWrapper(self, self.msvs_settings[config], 'VCLibrarianTool', append=libflags)
libflags.extend(self._GetAdditionalLibraryDirectories('VCLibrarianTool', config, gyp_to_build_path))
lib('LinkTimeCodeGeneration', map={'true': '/LTCG'})
lib('TargetMachine', map={'1': 'X86', '17': 'X64', '3': 'ARM'}, prefix='/MACHINE:')
lib('AdditionalOptions')
return libflags
|
'Returns the .def file from sources, if any. Otherwise returns None.'
| def GetDefFile(self, gyp_to_build_path):
| spec = self.spec
if (spec['type'] in ('shared_library', 'loadable_module', 'executable')):
def_files = [s for s in spec.get('sources', []) if s.endswith('.def')]
if (len(def_files) == 1):
return gyp_to_build_path(def_files[0])
elif (len(def_files) > 1):
raise Exception('Multiple .def files')
return None
|
'.def files get implicitly converted to a ModuleDefinitionFile for the
linker in the VS generator. Emulate that behaviour here.'
| def _GetDefFileAsLdflags(self, ldflags, gyp_to_build_path):
| def_file = self.GetDefFile(gyp_to_build_path)
if def_file:
ldflags.append(('/DEF:"%s"' % def_file))
|
'Gets the explicitly overridden pgd name for a target or returns None
if it\'s not overridden.'
| def GetPGDName(self, config, expand_special):
| config = self._TargetConfig(config)
output_file = self._Setting(('VCLinkerTool', 'ProfileGuidedDatabase'), config)
if output_file:
output_file = expand_special(self.ConvertVSMacros(output_file, config=config))
return output_file
|
'Returns the flags that need to be added to link commands, and the
manifest files.'
| def GetLdflags(self, config, gyp_to_build_path, expand_special, manifest_base_name, output_name, is_executable, build_dir):
| config = self._TargetConfig(config)
ldflags = []
ld = self._GetWrapper(self, self.msvs_settings[config], 'VCLinkerTool', append=ldflags)
self._GetDefFileAsLdflags(ldflags, gyp_to_build_path)
ld('GenerateDebugInformation', map={'true': '/DEBUG'})
ld('TargetMachine', map={'1': 'X86', '17': 'X64', '3': 'ARM'}, prefix='/MACHINE:')
ldflags.extend(self._GetAdditionalLibraryDirectories('VCLinkerTool', config, gyp_to_build_path))
ld('DelayLoadDLLs', prefix='/DELAYLOAD:')
ld('TreatLinkerWarningAsErrors', prefix='/WX', map={'true': '', 'false': ':NO'})
out = self.GetOutputName(config, expand_special)
if out:
ldflags.append(('/OUT:' + out))
pdb = self.GetPDBName(config, expand_special, (output_name + '.pdb'))
if pdb:
ldflags.append(('/PDB:' + pdb))
pgd = self.GetPGDName(config, expand_special)
if pgd:
ldflags.append(('/PGD:' + pgd))
map_file = self.GetMapFileName(config, expand_special)
ld('GenerateMapFile', map={'true': (('/MAP:' + map_file) if map_file else '/MAP')})
ld('MapExports', map={'true': '/MAPINFO:EXPORTS'})
ld('AdditionalOptions', prefix='')
minimum_required_version = self._Setting(('VCLinkerTool', 'MinimumRequiredVersion'), config, default='')
if minimum_required_version:
minimum_required_version = (',' + minimum_required_version)
ld('SubSystem', map={'1': ('CONSOLE%s' % minimum_required_version), '2': ('WINDOWS%s' % minimum_required_version)}, prefix='/SUBSYSTEM:')
stack_reserve_size = self._Setting(('VCLinkerTool', 'StackReserveSize'), config, default='')
if stack_reserve_size:
stack_commit_size = self._Setting(('VCLinkerTool', 'StackCommitSize'), config, default='')
if stack_commit_size:
stack_commit_size = (',' + stack_commit_size)
ldflags.append(('/STACK:%s%s' % (stack_reserve_size, stack_commit_size)))
ld('TerminalServerAware', map={'1': ':NO', '2': ''}, prefix='/TSAWARE')
ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL')
ld('BaseAddress', prefix='/BASE:')
ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED')
ld('RandomizedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE')
ld('DataExecutionPrevention', map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT')
ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:')
ld('ForceSymbolReferences', prefix='/INCLUDE:')
ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:')
ld('LinkTimeCodeGeneration', map={'1': '', '2': ':PGINSTRUMENT', '3': ':PGOPTIMIZE', '4': ':PGUPDATE'}, prefix='/LTCG')
ld('IgnoreDefaultLibraryNames', prefix='/NODEFAULTLIB:')
ld('ResourceOnlyDLL', map={'true': '/NOENTRY'})
ld('EntryPointSymbol', prefix='/ENTRY:')
ld('Profile', map={'true': '/PROFILE'})
ld('LargeAddressAware', map={'1': ':NO', '2': ''}, prefix='/LARGEADDRESSAWARE')
ld('AdditionalDependencies', prefix='')
if (self.GetArch(config) == 'x86'):
safeseh_default = 'true'
else:
safeseh_default = None
ld('ImageHasSafeExceptionHandlers', map={'false': ':NO', 'true': ''}, prefix='/SAFESEH', default=safeseh_default)
base_flags = filter((lambda x: (('DYNAMICBASE' in x) or (x == '/FIXED'))), ldflags)
if (not base_flags):
ldflags.append('/DYNAMICBASE')
if (not filter((lambda x: ('NXCOMPAT' in x)), ldflags)):
ldflags.append('/NXCOMPAT')
have_def_file = filter((lambda x: x.startswith('/DEF:')), ldflags)
(manifest_flags, intermediate_manifest, manifest_files) = self._GetLdManifestFlags(config, manifest_base_name, gyp_to_build_path, (is_executable and (not have_def_file)), build_dir)
ldflags.extend(manifest_flags)
return (ldflags, intermediate_manifest, manifest_files)
|
'Returns a 3-tuple:
- the set of flags that need to be added to the link to generate
a default manifest
- the intermediate manifest that the linker will generate that should be
used to assert it doesn\'t add anything to the merged one.
- the list of all the manifest files to be merged by the manifest tool and
included into the link.'
| def _GetLdManifestFlags(self, config, name, gyp_to_build_path, allow_isolation, build_dir):
| generate_manifest = self._Setting(('VCLinkerTool', 'GenerateManifest'), config, default='true')
if (generate_manifest != 'true'):
return (['/MANIFEST:NO'], [], [])
output_name = (name + '.intermediate.manifest')
flags = ['/MANIFEST', ('/ManifestFile:' + output_name)]
flags.append('/MANIFESTUAC:NO')
config = self._TargetConfig(config)
enable_uac = self._Setting(('VCLinkerTool', 'EnableUAC'), config, default='true')
manifest_files = []
generated_manifest_outer = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>%s</assembly>"
if (enable_uac == 'true'):
execution_level = self._Setting(('VCLinkerTool', 'UACExecutionLevel'), config, default='0')
execution_level_map = {'0': 'asInvoker', '1': 'highestAvailable', '2': 'requireAdministrator'}
ui_access = self._Setting(('VCLinkerTool', 'UACUIAccess'), config, default='false')
inner = ('\n<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">\n <security>\n <requestedPrivileges>\n <requestedExecutionLevel level=\'%s\' uiAccess=\'%s\' />\n </requestedPrivileges>\n </security>\n</trustInfo>' % (execution_level_map[execution_level], ui_access))
else:
inner = ''
generated_manifest_contents = (generated_manifest_outer % inner)
generated_name = (name + '.generated.manifest')
build_dir_generated_name = os.path.join(build_dir, generated_name)
gyp.common.EnsureDirExists(build_dir_generated_name)
f = gyp.common.WriteOnDiff(build_dir_generated_name)
f.write(generated_manifest_contents)
f.close()
manifest_files = [generated_name]
if allow_isolation:
flags.append('/ALLOWISOLATION')
manifest_files += self._GetAdditionalManifestFiles(config, gyp_to_build_path)
return (flags, output_name, manifest_files)
|
'Gets additional manifest files that are added to the default one
generated by the linker.'
| def _GetAdditionalManifestFiles(self, config, gyp_to_build_path):
| files = self._Setting(('VCManifestTool', 'AdditionalManifestFiles'), config, default=[])
if isinstance(files, str):
files = files.split(';')
return [os.path.normpath(gyp_to_build_path(self.ConvertVSMacros(f, config=config))) for f in files]
|
'Returns whether the target should be linked via Use Library Dependency
Inputs (using component .objs of a given .lib).'
| def IsUseLibraryDependencyInputs(self, config):
| config = self._TargetConfig(config)
uldi = self._Setting(('VCLinkerTool', 'UseLibraryDependencyInputs'), config)
return (uldi == 'true')
|
'Returns whether manifest should be linked into binary.'
| def IsEmbedManifest(self, config):
| config = self._TargetConfig(config)
embed = self._Setting(('VCManifestTool', 'EmbedManifest'), config, default='true')
return (embed == 'true')
|
'Returns whether the target should be linked incrementally.'
| def IsLinkIncremental(self, config):
| config = self._TargetConfig(config)
link_inc = self._Setting(('VCLinkerTool', 'LinkIncremental'), config)
return (link_inc != '1')
|
'Returns the flags that need to be added to invocations of the resource
compiler.'
| def GetRcflags(self, config, gyp_to_ninja_path):
| config = self._TargetConfig(config)
rcflags = []
rc = self._GetWrapper(self, self.msvs_settings[config], 'VCResourceCompilerTool', append=rcflags)
rc('AdditionalIncludeDirectories', map=gyp_to_ninja_path, prefix='/I')
rcflags.append(('/I' + gyp_to_ninja_path('.')))
rc('PreprocessorDefinitions', prefix='/d')
rc('Culture', prefix='/l', map=(lambda x: hex(int(x))[2:]))
return rcflags
|
'Build a command line that runs args via cygwin bash. We assume that all
incoming paths are in Windows normpath\'d form, so they need to be
converted to posix style for the part of the command line that\'s passed to
bash. We also have to do some Visual Studio macro emulation here because
various rules use magic VS names for things. Also note that rules that
contain ninja variables cannot be fixed here (for example ${source}), so
the outer generator needs to make sure that the paths that are written out
are in posix style, if the command line will be used here.'
| def BuildCygwinBashCommandLine(self, args, path_to_base):
| cygwin_dir = os.path.normpath(os.path.join(path_to_base, self.msvs_cygwin_dirs[0]))
cd = ('cd %s' % path_to_base).replace('\\', '/')
args = [a.replace('\\', '/').replace('"', '\\"') for a in args]
args = [("'%s'" % a.replace("'", "'\\''")) for a in args]
bash_cmd = ' '.join(args)
cmd = (('call "%s\\setup_env.bat" && set CYGWIN=nontsec && ' % cygwin_dir) + ('bash -c "%s ; %s"' % (cd, bash_cmd)))
return cmd
|
'Determine if an action should be run under cygwin. If the variable is
unset, or set to 1 we use cygwin.'
| def IsRuleRunUnderCygwin(self, rule):
| return (int(rule.get('msvs_cygwin_shell', self.spec.get('msvs_cygwin_shell', 1))) != 0)
|
'Determine if there\'s an explicit rule for a particular extension.'
| def _HasExplicitRuleForExtension(self, spec, extension):
| for rule in spec.get('rules', []):
if (rule['extension'] == extension):
return True
return False
|
'Determine if an action should not run midl for .idl files.'
| def _HasExplicitIdlActions(self, spec):
| return any([action.get('explicit_idl_action', 0) for action in spec.get('actions', [])])
|
'Determine if there\'s an explicit rule or action for idl files. When
there isn\'t we need to generate implicit rules to build MIDL .idl files.'
| def HasExplicitIdlRulesOrActions(self, spec):
| return (self._HasExplicitRuleForExtension(spec, 'idl') or self._HasExplicitIdlActions(spec))
|
'Determine if there\'s an explicit rule for asm files. When there isn\'t we
need to generate implicit rules to assemble .asm files.'
| def HasExplicitAsmRules(self, spec):
| return self._HasExplicitRuleForExtension(spec, 'asm')
|
'Determine the implicit outputs for an idl file. Returns output
directory, outputs, and variables and flags that are required.'
| def GetIdlBuildData(self, source, config):
| config = self._TargetConfig(config)
midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool')
def midl(name, default=None):
return self.ConvertVSMacros(midl_get(name, default=default), config=config)
tlb = midl('TypeLibraryName', default='${root}.tlb')
header = midl('HeaderFileName', default='${root}.h')
dlldata = midl('DLLDataFileName', default='dlldata.c')
iid = midl('InterfaceIdentifierFileName', default='${root}_i.c')
proxy = midl('ProxyFileName', default='${root}_p.c')
outdir = midl('OutputDirectory', default='')
output = [header, dlldata, iid, proxy]
variables = [('tlb', tlb), ('h', header), ('dlldata', dlldata), ('iid', iid), ('proxy', proxy)]
target_platform = ('win32' if (self.GetArch(config) == 'x86') else 'x64')
flags = ['/char', 'signed', '/env', target_platform, '/Oicf']
return (outdir, output, variables, flags)
|
'Get the header that will appear in an #include line for all source
files.'
| def _PchHeader(self):
| return os.path.split(self.settings.msvs_precompiled_header[self.config])[1]
|
'Given a list of sources files and the corresponding object files,
returns a list of the pch files that should be depended upon. The
additional wrapping in the return value is for interface compatibility
with make.py on Mac, and xcode_emulation.py.'
| def GetObjDependencies(self, sources, objs, arch):
| assert (arch is None)
if (not self._PchHeader()):
return []
pch_ext = os.path.splitext(self.pch_source)[1]
for source in sources:
if _LanguageMatchesForPch(os.path.splitext(source)[1], pch_ext):
return [(None, None, self.output_obj)]
return []
|
'Not used on Windows as there are no additional build steps required
(instead, existing steps are modified in GetFlagsModifications below).'
| def GetPchBuildCommands(self, arch):
| return []
|
'Get the modified cflags and implicit dependencies that should be used
for the pch compilation step.'
| def GetFlagsModifications(self, input, output, implicit, command, cflags_c, cflags_cc, expand_special):
| if (input == self.pch_source):
pch_output = [('/Yc' + self._PchHeader())]
if (command == 'cxx'):
return ([('cflags_cc', map(expand_special, (cflags_cc + pch_output)))], self.output_obj, [])
elif (command == 'cc'):
return ([('cflags_c', map(expand_special, (cflags_c + pch_output)))], self.output_obj, [])
return ([], output, implicit)
|
'Compares recorded lines to expected warnings.'
| def _ExpectedWarnings(self, expected):
| self.stderr.seek(0)
actual = self.stderr.read().split('\n')
actual = [line for line in actual if line]
self.assertEqual(sorted(expected), sorted(actual))
|
'Tests that only MSVS tool names are allowed.'
| def testValidateMSVSSettings_tool_names(self):
| MSVSSettings.ValidateMSVSSettings({'VCCLCompilerTool': {}, 'VCLinkerTool': {}, 'VCMIDLTool': {}, 'foo': {}, 'VCResourceCompilerTool': {}, 'VCLibrarianTool': {}, 'VCManifestTool': {}, 'ClCompile': {}}, self.stderr)
self._ExpectedWarnings(['Warning: unrecognized tool foo', 'Warning: unrecognized tool ClCompile'])
|
'Tests that for invalid MSVS settings.'
| def testValidateMSVSSettings_settings(self):
| MSVSSettings.ValidateMSVSSettings({'VCCLCompilerTool': {'AdditionalIncludeDirectories': 'folder1;folder2', 'AdditionalOptions': ['string1', 'string2'], 'AdditionalUsingDirectories': 'folder1;folder2', 'AssemblerListingLocation': 'a_file_name', 'AssemblerOutput': '0', 'BasicRuntimeChecks': '5', 'BrowseInformation': 'fdkslj', 'BrowseInformationFile': 'a_file_name', 'BufferSecurityCheck': 'true', 'CallingConvention': '-1', 'CompileAs': '1', 'DebugInformationFormat': '2', 'DefaultCharIsUnsigned': 'true', 'Detect64BitPortabilityProblems': 'true', 'DisableLanguageExtensions': 'true', 'DisableSpecificWarnings': 'string1;string2', 'EnableEnhancedInstructionSet': '1', 'EnableFiberSafeOptimizations': 'true', 'EnableFunctionLevelLinking': 'true', 'EnableIntrinsicFunctions': 'true', 'EnablePREfast': 'true', 'Enableprefast': 'bogus', 'ErrorReporting': '1', 'ExceptionHandling': '1', 'ExpandAttributedSource': 'true', 'FavorSizeOrSpeed': '1', 'FloatingPointExceptions': 'true', 'FloatingPointModel': '1', 'ForceConformanceInForLoopScope': 'true', 'ForcedIncludeFiles': 'file1;file2', 'ForcedUsingFiles': 'file1;file2', 'GeneratePreprocessedFile': '1', 'GenerateXMLDocumentationFiles': 'true', 'IgnoreStandardIncludePath': 'true', 'InlineFunctionExpansion': '1', 'KeepComments': 'true', 'MinimalRebuild': 'true', 'ObjectFile': 'a_file_name', 'OmitDefaultLibName': 'true', 'OmitFramePointers': 'true', 'OpenMP': 'true', 'Optimization': '1', 'PrecompiledHeaderFile': 'a_file_name', 'PrecompiledHeaderThrough': 'a_file_name', 'PreprocessorDefinitions': 'string1;string2', 'ProgramDataBaseFileName': 'a_file_name', 'RuntimeLibrary': '1', 'RuntimeTypeInfo': 'true', 'ShowIncludes': 'true', 'SmallerTypeCheck': 'true', 'StringPooling': 'true', 'StructMemberAlignment': '1', 'SuppressStartupBanner': 'true', 'TreatWChar_tAsBuiltInType': 'true', 'UndefineAllPreprocessorDefinitions': 'true', 'UndefinePreprocessorDefinitions': 'string1;string2', 'UseFullPaths': 'true', 'UsePrecompiledHeader': '1', 'UseUnicodeResponseFiles': 'true', 'WarnAsError': 'true', 'WarningLevel': '1', 'WholeProgramOptimization': 'true', 'XMLDocumentationFileName': 'a_file_name', 'ZZXYZ': 'bogus'}, 'VCLinkerTool': {'AdditionalDependencies': 'file1;file2', 'AdditionalDependencies_excluded': 'file3', 'AdditionalLibraryDirectories': 'folder1;folder2', 'AdditionalManifestDependencies': 'file1;file2', 'AdditionalOptions': 'a string1', 'AddModuleNamesToAssembly': 'file1;file2', 'AllowIsolation': 'true', 'AssemblyDebug': '2', 'AssemblyLinkResource': 'file1;file2', 'BaseAddress': 'a string1', 'CLRImageType': '2', 'CLRThreadAttribute': '2', 'CLRUnmanagedCodeCheck': 'true', 'DataExecutionPrevention': '2', 'DelayLoadDLLs': 'file1;file2', 'DelaySign': 'true', 'Driver': '2', 'EmbedManagedResourceFile': 'file1;file2', 'EnableCOMDATFolding': '2', 'EnableUAC': 'true', 'EntryPointSymbol': 'a string1', 'ErrorReporting': '2', 'FixedBaseAddress': '2', 'ForceSymbolReferences': 'file1;file2', 'FunctionOrder': 'a_file_name', 'GenerateDebugInformation': 'true', 'GenerateManifest': 'true', 'GenerateMapFile': 'true', 'HeapCommitSize': 'a string1', 'HeapReserveSize': 'a string1', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreDefaultLibraryNames': 'file1;file2', 'IgnoreEmbeddedIDL': 'true', 'IgnoreImportLibrary': 'true', 'ImportLibrary': 'a_file_name', 'KeyContainer': 'a_file_name', 'KeyFile': 'a_file_name', 'LargeAddressAware': '2', 'LinkIncremental': '2', 'LinkLibraryDependencies': 'true', 'LinkTimeCodeGeneration': '2', 'ManifestFile': 'a_file_name', 'MapExports': 'true', 'MapFileName': 'a_file_name', 'MergedIDLBaseFileName': 'a_file_name', 'MergeSections': 'a string1', 'MidlCommandFile': 'a_file_name', 'ModuleDefinitionFile': 'a_file_name', 'OptimizeForWindows98': '1', 'OptimizeReferences': '2', 'OutputFile': 'a_file_name', 'PerUserRedirection': 'true', 'Profile': 'true', 'ProfileGuidedDatabase': 'a_file_name', 'ProgramDatabaseFile': 'a_file_name', 'RandomizedBaseAddress': '2', 'RegisterOutput': 'true', 'ResourceOnlyDLL': 'true', 'SetChecksum': 'true', 'ShowProgress': '2', 'StackCommitSize': 'a string1', 'StackReserveSize': 'a string1', 'StripPrivateSymbols': 'a_file_name', 'SubSystem': '2', 'SupportUnloadOfDelayLoadedDLL': 'true', 'SuppressStartupBanner': 'true', 'SwapRunFromCD': 'true', 'SwapRunFromNet': 'true', 'TargetMachine': '2', 'TerminalServerAware': '2', 'TurnOffAssemblyGeneration': 'true', 'TypeLibraryFile': 'a_file_name', 'TypeLibraryResourceID': '33', 'UACExecutionLevel': '2', 'UACUIAccess': 'true', 'UseLibraryDependencyInputs': 'true', 'UseUnicodeResponseFiles': 'true', 'Version': 'a string1'}, 'VCMIDLTool': {'AdditionalIncludeDirectories': 'folder1;folder2', 'AdditionalOptions': 'a string1', 'CPreprocessOptions': 'a string1', 'DefaultCharType': '1', 'DLLDataFileName': 'a_file_name', 'EnableErrorChecks': '1', 'ErrorCheckAllocations': 'true', 'ErrorCheckBounds': 'true', 'ErrorCheckEnumRange': 'true', 'ErrorCheckRefPointers': 'true', 'ErrorCheckStubData': 'true', 'GenerateStublessProxies': 'true', 'GenerateTypeLibrary': 'true', 'HeaderFileName': 'a_file_name', 'IgnoreStandardIncludePath': 'true', 'InterfaceIdentifierFileName': 'a_file_name', 'MkTypLibCompatible': 'true', 'notgood': 'bogus', 'OutputDirectory': 'a string1', 'PreprocessorDefinitions': 'string1;string2', 'ProxyFileName': 'a_file_name', 'RedirectOutputAndErrors': 'a_file_name', 'StructMemberAlignment': '1', 'SuppressStartupBanner': 'true', 'TargetEnvironment': '1', 'TypeLibraryName': 'a_file_name', 'UndefinePreprocessorDefinitions': 'string1;string2', 'ValidateParameters': 'true', 'WarnAsError': 'true', 'WarningLevel': '1'}, 'VCResourceCompilerTool': {'AdditionalOptions': 'a string1', 'AdditionalIncludeDirectories': 'folder1;folder2', 'Culture': '1003', 'IgnoreStandardIncludePath': 'true', 'notgood2': 'bogus', 'PreprocessorDefinitions': 'string1;string2', 'ResourceOutputFileName': 'a string1', 'ShowProgress': 'true', 'SuppressStartupBanner': 'true', 'UndefinePreprocessorDefinitions': 'string1;string2'}, 'VCLibrarianTool': {'AdditionalDependencies': 'file1;file2', 'AdditionalLibraryDirectories': 'folder1;folder2', 'AdditionalOptions': 'a string1', 'ExportNamedFunctions': 'string1;string2', 'ForceSymbolReferences': 'a string1', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreSpecificDefaultLibraries': 'file1;file2', 'LinkLibraryDependencies': 'true', 'ModuleDefinitionFile': 'a_file_name', 'OutputFile': 'a_file_name', 'SuppressStartupBanner': 'true', 'UseUnicodeResponseFiles': 'true'}, 'VCManifestTool': {'AdditionalManifestFiles': 'file1;file2', 'AdditionalOptions': 'a string1', 'AssemblyIdentity': 'a string1', 'ComponentFileName': 'a_file_name', 'DependencyInformationFile': 'a_file_name', 'GenerateCatalogFiles': 'true', 'InputResourceManifests': 'a string1', 'ManifestResourceFile': 'a_file_name', 'OutputManifestFile': 'a_file_name', 'RegistrarScriptFile': 'a_file_name', 'ReplacementsFile': 'a_file_name', 'SuppressStartupBanner': 'true', 'TypeLibraryFile': 'a_file_name', 'UpdateFileHashes': 'truel', 'UpdateFileHashesSearchPath': 'a_file_name', 'UseFAT32Workaround': 'true', 'UseUnicodeResponseFiles': 'true', 'VerboseOutput': 'true'}}, self.stderr)
self._ExpectedWarnings(['Warning: for VCCLCompilerTool/BasicRuntimeChecks, index value (5) not in expected range [0, 4)', "Warning: for VCCLCompilerTool/BrowseInformation, invalid literal for int() with base 10: 'fdkslj'", 'Warning: for VCCLCompilerTool/CallingConvention, index value (-1) not in expected range [0, 4)', 'Warning: for VCCLCompilerTool/DebugInformationFormat, converted value for 2 not specified.', 'Warning: unrecognized setting VCCLCompilerTool/Enableprefast', 'Warning: unrecognized setting VCCLCompilerTool/ZZXYZ', 'Warning: for VCLinkerTool/TargetMachine, converted value for 2 not specified.', 'Warning: unrecognized setting VCMIDLTool/notgood', 'Warning: unrecognized setting VCResourceCompilerTool/notgood2', "Warning: for VCManifestTool/UpdateFileHashes, expected bool; got 'truel'"])
|
'Tests that for invalid MSBuild settings.'
| def testValidateMSBuildSettings_settings(self):
| MSVSSettings.ValidateMSBuildSettings({'ClCompile': {'AdditionalIncludeDirectories': 'folder1;folder2', 'AdditionalOptions': ['string1', 'string2'], 'AdditionalUsingDirectories': 'folder1;folder2', 'AssemblerListingLocation': 'a_file_name', 'AssemblerOutput': 'NoListing', 'BasicRuntimeChecks': 'StackFrameRuntimeCheck', 'BrowseInformation': 'false', 'BrowseInformationFile': 'a_file_name', 'BufferSecurityCheck': 'true', 'BuildingInIDE': 'true', 'CallingConvention': 'Cdecl', 'CompileAs': 'CompileAsC', 'CompileAsManaged': 'true', 'CreateHotpatchableImage': 'true', 'DebugInformationFormat': 'ProgramDatabase', 'DisableLanguageExtensions': 'true', 'DisableSpecificWarnings': 'string1;string2', 'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions', 'EnableFiberSafeOptimizations': 'true', 'EnablePREfast': 'true', 'Enableprefast': 'bogus', 'ErrorReporting': 'Prompt', 'ExceptionHandling': 'SyncCThrow', 'ExpandAttributedSource': 'true', 'FavorSizeOrSpeed': 'Neither', 'FloatingPointExceptions': 'true', 'FloatingPointModel': 'Precise', 'ForceConformanceInForLoopScope': 'true', 'ForcedIncludeFiles': 'file1;file2', 'ForcedUsingFiles': 'file1;file2', 'FunctionLevelLinking': 'false', 'GenerateXMLDocumentationFiles': 'true', 'IgnoreStandardIncludePath': 'true', 'InlineFunctionExpansion': 'OnlyExplicitInline', 'IntrinsicFunctions': 'false', 'MinimalRebuild': 'true', 'MultiProcessorCompilation': 'true', 'ObjectFileName': 'a_file_name', 'OmitDefaultLibName': 'true', 'OmitFramePointers': 'true', 'OpenMPSupport': 'true', 'Optimization': 'Disabled', 'PrecompiledHeader': 'NotUsing', 'PrecompiledHeaderFile': 'a_file_name', 'PrecompiledHeaderOutputFile': 'a_file_name', 'PreprocessKeepComments': 'true', 'PreprocessorDefinitions': 'string1;string2', 'PreprocessOutputPath': 'a string1', 'PreprocessSuppressLineNumbers': 'false', 'PreprocessToFile': 'false', 'ProcessorNumber': '33', 'ProgramDataBaseFileName': 'a_file_name', 'RuntimeLibrary': 'MultiThreaded', 'RuntimeTypeInfo': 'true', 'ShowIncludes': 'true', 'SmallerTypeCheck': 'true', 'StringPooling': 'true', 'StructMemberAlignment': '1Byte', 'SuppressStartupBanner': 'true', 'TrackerLogDirectory': 'a_folder', 'TreatSpecificWarningsAsErrors': 'string1;string2', 'TreatWarningAsError': 'true', 'TreatWChar_tAsBuiltInType': 'true', 'UndefineAllPreprocessorDefinitions': 'true', 'UndefinePreprocessorDefinitions': 'string1;string2', 'UseFullPaths': 'true', 'UseUnicodeForAssemblerListing': 'true', 'WarningLevel': 'TurnOffAllWarnings', 'WholeProgramOptimization': 'true', 'XMLDocumentationFileName': 'a_file_name', 'ZZXYZ': 'bogus'}, 'Link': {'AdditionalDependencies': 'file1;file2', 'AdditionalLibraryDirectories': 'folder1;folder2', 'AdditionalManifestDependencies': 'file1;file2', 'AdditionalOptions': 'a string1', 'AddModuleNamesToAssembly': 'file1;file2', 'AllowIsolation': 'true', 'AssemblyDebug': '', 'AssemblyLinkResource': 'file1;file2', 'BaseAddress': 'a string1', 'BuildingInIDE': 'true', 'CLRImageType': 'ForceIJWImage', 'CLRSupportLastError': 'Enabled', 'CLRThreadAttribute': 'MTAThreadingAttribute', 'CLRUnmanagedCodeCheck': 'true', 'CreateHotPatchableImage': 'X86Image', 'DataExecutionPrevention': 'false', 'DelayLoadDLLs': 'file1;file2', 'DelaySign': 'true', 'Driver': 'NotSet', 'EmbedManagedResourceFile': 'file1;file2', 'EnableCOMDATFolding': 'false', 'EnableUAC': 'true', 'EntryPointSymbol': 'a string1', 'FixedBaseAddress': 'false', 'ForceFileOutput': 'Enabled', 'ForceSymbolReferences': 'file1;file2', 'FunctionOrder': 'a_file_name', 'GenerateDebugInformation': 'true', 'GenerateMapFile': 'true', 'HeapCommitSize': 'a string1', 'HeapReserveSize': 'a string1', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreEmbeddedIDL': 'true', 'IgnoreSpecificDefaultLibraries': 'a_file_list', 'ImageHasSafeExceptionHandlers': 'true', 'ImportLibrary': 'a_file_name', 'KeyContainer': 'a_file_name', 'KeyFile': 'a_file_name', 'LargeAddressAware': 'false', 'LinkDLL': 'true', 'LinkErrorReporting': 'SendErrorReport', 'LinkStatus': 'true', 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration', 'ManifestFile': 'a_file_name', 'MapExports': 'true', 'MapFileName': 'a_file_name', 'MergedIDLBaseFileName': 'a_file_name', 'MergeSections': 'a string1', 'MidlCommandFile': 'a_file_name', 'MinimumRequiredVersion': 'a string1', 'ModuleDefinitionFile': 'a_file_name', 'MSDOSStubFileName': 'a_file_name', 'NoEntryPoint': 'true', 'OptimizeReferences': 'false', 'OutputFile': 'a_file_name', 'PerUserRedirection': 'true', 'PreventDllBinding': 'true', 'Profile': 'true', 'ProfileGuidedDatabase': 'a_file_name', 'ProgramDatabaseFile': 'a_file_name', 'RandomizedBaseAddress': 'false', 'RegisterOutput': 'true', 'SectionAlignment': '33', 'SetChecksum': 'true', 'ShowProgress': 'LinkVerboseREF', 'SpecifySectionAttributes': 'a string1', 'StackCommitSize': 'a string1', 'StackReserveSize': 'a string1', 'StripPrivateSymbols': 'a_file_name', 'SubSystem': 'Console', 'SupportNobindOfDelayLoadedDLL': 'true', 'SupportUnloadOfDelayLoadedDLL': 'true', 'SuppressStartupBanner': 'true', 'SwapRunFromCD': 'true', 'SwapRunFromNET': 'true', 'TargetMachine': 'MachineX86', 'TerminalServerAware': 'false', 'TrackerLogDirectory': 'a_folder', 'TreatLinkerWarningAsErrors': 'true', 'TurnOffAssemblyGeneration': 'true', 'TypeLibraryFile': 'a_file_name', 'TypeLibraryResourceID': '33', 'UACExecutionLevel': 'AsInvoker', 'UACUIAccess': 'true', 'Version': 'a string1'}, 'ResourceCompile': {'AdditionalIncludeDirectories': 'folder1;folder2', 'AdditionalOptions': 'a string1', 'Culture': '0x236', 'IgnoreStandardIncludePath': 'true', 'NullTerminateStrings': 'true', 'PreprocessorDefinitions': 'string1;string2', 'ResourceOutputFileName': 'a string1', 'ShowProgress': 'true', 'SuppressStartupBanner': 'true', 'TrackerLogDirectory': 'a_folder', 'UndefinePreprocessorDefinitions': 'string1;string2'}, 'Midl': {'AdditionalIncludeDirectories': 'folder1;folder2', 'AdditionalOptions': 'a string1', 'ApplicationConfigurationMode': 'true', 'ClientStubFile': 'a_file_name', 'CPreprocessOptions': 'a string1', 'DefaultCharType': 'Signed', 'DllDataFileName': 'a_file_name', 'EnableErrorChecks': 'EnableCustom', 'ErrorCheckAllocations': 'true', 'ErrorCheckBounds': 'true', 'ErrorCheckEnumRange': 'true', 'ErrorCheckRefPointers': 'true', 'ErrorCheckStubData': 'true', 'GenerateClientFiles': 'Stub', 'GenerateServerFiles': 'None', 'GenerateStublessProxies': 'true', 'GenerateTypeLibrary': 'true', 'HeaderFileName': 'a_file_name', 'IgnoreStandardIncludePath': 'true', 'InterfaceIdentifierFileName': 'a_file_name', 'LocaleID': '33', 'MkTypLibCompatible': 'true', 'OutputDirectory': 'a string1', 'PreprocessorDefinitions': 'string1;string2', 'ProxyFileName': 'a_file_name', 'RedirectOutputAndErrors': 'a_file_name', 'ServerStubFile': 'a_file_name', 'StructMemberAlignment': 'NotSet', 'SuppressCompilerWarnings': 'true', 'SuppressStartupBanner': 'true', 'TargetEnvironment': 'Itanium', 'TrackerLogDirectory': 'a_folder', 'TypeLibFormat': 'NewFormat', 'TypeLibraryName': 'a_file_name', 'UndefinePreprocessorDefinitions': 'string1;string2', 'ValidateAllParameters': 'true', 'WarnAsError': 'true', 'WarningLevel': '1'}, 'Lib': {'AdditionalDependencies': 'file1;file2', 'AdditionalLibraryDirectories': 'folder1;folder2', 'AdditionalOptions': 'a string1', 'DisplayLibrary': 'a string1', 'ErrorReporting': 'PromptImmediately', 'ExportNamedFunctions': 'string1;string2', 'ForceSymbolReferences': 'a string1', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreSpecificDefaultLibraries': 'file1;file2', 'LinkTimeCodeGeneration': 'true', 'MinimumRequiredVersion': 'a string1', 'ModuleDefinitionFile': 'a_file_name', 'Name': 'a_file_name', 'OutputFile': 'a_file_name', 'RemoveObjects': 'file1;file2', 'SubSystem': 'Console', 'SuppressStartupBanner': 'true', 'TargetMachine': 'MachineX86i', 'TrackerLogDirectory': 'a_folder', 'TreatLibWarningAsErrors': 'true', 'UseUnicodeResponseFiles': 'true', 'Verbose': 'true'}, 'Manifest': {'AdditionalManifestFiles': 'file1;file2', 'AdditionalOptions': 'a string1', 'AssemblyIdentity': 'a string1', 'ComponentFileName': 'a_file_name', 'EnableDPIAwareness': 'fal', 'GenerateCatalogFiles': 'truel', 'GenerateCategoryTags': 'true', 'InputResourceManifests': 'a string1', 'ManifestFromManagedAssembly': 'a_file_name', 'notgood3': 'bogus', 'OutputManifestFile': 'a_file_name', 'OutputResourceManifests': 'a string1', 'RegistrarScriptFile': 'a_file_name', 'ReplacementsFile': 'a_file_name', 'SuppressDependencyElement': 'true', 'SuppressStartupBanner': 'true', 'TrackerLogDirectory': 'a_folder', 'TypeLibraryFile': 'a_file_name', 'UpdateFileHashes': 'true', 'UpdateFileHashesSearchPath': 'a_file_name', 'VerboseOutput': 'true'}, 'ProjectReference': {'LinkLibraryDependencies': 'true', 'UseLibraryDependencyInputs': 'true'}, 'ManifestResourceCompile': {'ResourceOutputFileName': 'a_file_name'}, '': {'EmbedManifest': 'true', 'GenerateManifest': 'true', 'IgnoreImportLibrary': 'true', 'LinkIncremental': 'false'}}, self.stderr)
self._ExpectedWarnings(['Warning: unrecognized setting ClCompile/Enableprefast', 'Warning: unrecognized setting ClCompile/ZZXYZ', 'Warning: unrecognized setting Manifest/notgood3', "Warning: for Manifest/GenerateCatalogFiles, expected bool; got 'truel'", 'Warning: for Lib/TargetMachine, unrecognized enumerated value MachineX86i', "Warning: for Manifest/EnableDPIAwareness, expected bool; got 'fal'"])
|
'Tests an empty conversion.'
| def testConvertToMSBuildSettings_empty(self):
| msvs_settings = {}
expected_msbuild_settings = {}
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings, self.stderr)
self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
self._ExpectedWarnings([])
|
'Tests a minimal conversion.'
| def testConvertToMSBuildSettings_minimal(self):
| msvs_settings = {'VCCLCompilerTool': {'AdditionalIncludeDirectories': 'dir1', 'AdditionalOptions': '/foo', 'BasicRuntimeChecks': '0'}, 'VCLinkerTool': {'LinkTimeCodeGeneration': '1', 'ErrorReporting': '1', 'DataExecutionPrevention': '2'}}
expected_msbuild_settings = {'ClCompile': {'AdditionalIncludeDirectories': 'dir1', 'AdditionalOptions': '/foo', 'BasicRuntimeChecks': 'Default'}, 'Link': {'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration', 'LinkErrorReporting': 'PromptImmediately', 'DataExecutionPrevention': 'true'}}
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings, self.stderr)
self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
self._ExpectedWarnings([])
|
'Tests conversion that generates warnings.'
| def testConvertToMSBuildSettings_warnings(self):
| msvs_settings = {'VCCLCompilerTool': {'AdditionalIncludeDirectories': '1', 'AdditionalOptions': '2', 'BasicRuntimeChecks': '12', 'BrowseInformation': '21', 'UsePrecompiledHeader': '13', 'GeneratePreprocessedFile': '14'}, 'VCLinkerTool': {'Driver': '10', 'LinkTimeCodeGeneration': '31', 'ErrorReporting': '21', 'FixedBaseAddress': '6'}, 'VCResourceCompilerTool': {'Culture': '1003'}}
expected_msbuild_settings = {'ClCompile': {'AdditionalIncludeDirectories': '1', 'AdditionalOptions': '2'}, 'Link': {}, 'ResourceCompile': {'Culture': '0x03eb'}}
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings, self.stderr)
self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
self._ExpectedWarnings(['Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index value (12) not in expected range [0, 4)', 'Warning: while converting VCCLCompilerTool/BrowseInformation to MSBuild, index value (21) not in expected range [0, 3)', 'Warning: while converting VCCLCompilerTool/UsePrecompiledHeader to MSBuild, index value (13) not in expected range [0, 3)', 'Warning: while converting VCCLCompilerTool/GeneratePreprocessedFile to MSBuild, value must be one of [0, 1, 2]; got 14', 'Warning: while converting VCLinkerTool/Driver to MSBuild, index value (10) not in expected range [0, 4)', 'Warning: while converting VCLinkerTool/LinkTimeCodeGeneration to MSBuild, index value (31) not in expected range [0, 5)', 'Warning: while converting VCLinkerTool/ErrorReporting to MSBuild, index value (21) not in expected range [0, 3)', 'Warning: while converting VCLinkerTool/FixedBaseAddress to MSBuild, index value (6) not in expected range [0, 3)'])
|
'Tests conversion of all the MSBuild settings.'
| def testConvertToMSBuildSettings_full_synthetic(self):
| msvs_settings = {'VCCLCompilerTool': {'AdditionalIncludeDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'AdditionalUsingDirectories': 'folder1;folder2;folder3', 'AssemblerListingLocation': 'a_file_name', 'AssemblerOutput': '0', 'BasicRuntimeChecks': '1', 'BrowseInformation': '2', 'BrowseInformationFile': 'a_file_name', 'BufferSecurityCheck': 'true', 'CallingConvention': '0', 'CompileAs': '1', 'DebugInformationFormat': '4', 'DefaultCharIsUnsigned': 'true', 'Detect64BitPortabilityProblems': 'true', 'DisableLanguageExtensions': 'true', 'DisableSpecificWarnings': 'd1;d2;d3', 'EnableEnhancedInstructionSet': '0', 'EnableFiberSafeOptimizations': 'true', 'EnableFunctionLevelLinking': 'true', 'EnableIntrinsicFunctions': 'true', 'EnablePREfast': 'true', 'ErrorReporting': '1', 'ExceptionHandling': '2', 'ExpandAttributedSource': 'true', 'FavorSizeOrSpeed': '0', 'FloatingPointExceptions': 'true', 'FloatingPointModel': '1', 'ForceConformanceInForLoopScope': 'true', 'ForcedIncludeFiles': 'file1;file2;file3', 'ForcedUsingFiles': 'file1;file2;file3', 'GeneratePreprocessedFile': '1', 'GenerateXMLDocumentationFiles': 'true', 'IgnoreStandardIncludePath': 'true', 'InlineFunctionExpansion': '2', 'KeepComments': 'true', 'MinimalRebuild': 'true', 'ObjectFile': 'a_file_name', 'OmitDefaultLibName': 'true', 'OmitFramePointers': 'true', 'OpenMP': 'true', 'Optimization': '3', 'PrecompiledHeaderFile': 'a_file_name', 'PrecompiledHeaderThrough': 'a_file_name', 'PreprocessorDefinitions': 'd1;d2;d3', 'ProgramDataBaseFileName': 'a_file_name', 'RuntimeLibrary': '0', 'RuntimeTypeInfo': 'true', 'ShowIncludes': 'true', 'SmallerTypeCheck': 'true', 'StringPooling': 'true', 'StructMemberAlignment': '1', 'SuppressStartupBanner': 'true', 'TreatWChar_tAsBuiltInType': 'true', 'UndefineAllPreprocessorDefinitions': 'true', 'UndefinePreprocessorDefinitions': 'd1;d2;d3', 'UseFullPaths': 'true', 'UsePrecompiledHeader': '1', 'UseUnicodeResponseFiles': 'true', 'WarnAsError': 'true', 'WarningLevel': '2', 'WholeProgramOptimization': 'true', 'XMLDocumentationFileName': 'a_file_name'}, 'VCLinkerTool': {'AdditionalDependencies': 'file1;file2;file3', 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', 'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3', 'AdditionalManifestDependencies': 'file1;file2;file3', 'AdditionalOptions': 'a_string', 'AddModuleNamesToAssembly': 'file1;file2;file3', 'AllowIsolation': 'true', 'AssemblyDebug': '0', 'AssemblyLinkResource': 'file1;file2;file3', 'BaseAddress': 'a_string', 'CLRImageType': '1', 'CLRThreadAttribute': '2', 'CLRUnmanagedCodeCheck': 'true', 'DataExecutionPrevention': '0', 'DelayLoadDLLs': 'file1;file2;file3', 'DelaySign': 'true', 'Driver': '1', 'EmbedManagedResourceFile': 'file1;file2;file3', 'EnableCOMDATFolding': '0', 'EnableUAC': 'true', 'EntryPointSymbol': 'a_string', 'ErrorReporting': '0', 'FixedBaseAddress': '1', 'ForceSymbolReferences': 'file1;file2;file3', 'FunctionOrder': 'a_file_name', 'GenerateDebugInformation': 'true', 'GenerateManifest': 'true', 'GenerateMapFile': 'true', 'HeapCommitSize': 'a_string', 'HeapReserveSize': 'a_string', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreDefaultLibraryNames': 'file1;file2;file3', 'IgnoreEmbeddedIDL': 'true', 'IgnoreImportLibrary': 'true', 'ImportLibrary': 'a_file_name', 'KeyContainer': 'a_file_name', 'KeyFile': 'a_file_name', 'LargeAddressAware': '2', 'LinkIncremental': '1', 'LinkLibraryDependencies': 'true', 'LinkTimeCodeGeneration': '2', 'ManifestFile': 'a_file_name', 'MapExports': 'true', 'MapFileName': 'a_file_name', 'MergedIDLBaseFileName': 'a_file_name', 'MergeSections': 'a_string', 'MidlCommandFile': 'a_file_name', 'ModuleDefinitionFile': 'a_file_name', 'OptimizeForWindows98': '1', 'OptimizeReferences': '0', 'OutputFile': 'a_file_name', 'PerUserRedirection': 'true', 'Profile': 'true', 'ProfileGuidedDatabase': 'a_file_name', 'ProgramDatabaseFile': 'a_file_name', 'RandomizedBaseAddress': '1', 'RegisterOutput': 'true', 'ResourceOnlyDLL': 'true', 'SetChecksum': 'true', 'ShowProgress': '0', 'StackCommitSize': 'a_string', 'StackReserveSize': 'a_string', 'StripPrivateSymbols': 'a_file_name', 'SubSystem': '2', 'SupportUnloadOfDelayLoadedDLL': 'true', 'SuppressStartupBanner': 'true', 'SwapRunFromCD': 'true', 'SwapRunFromNet': 'true', 'TargetMachine': '3', 'TerminalServerAware': '2', 'TurnOffAssemblyGeneration': 'true', 'TypeLibraryFile': 'a_file_name', 'TypeLibraryResourceID': '33', 'UACExecutionLevel': '1', 'UACUIAccess': 'true', 'UseLibraryDependencyInputs': 'false', 'UseUnicodeResponseFiles': 'true', 'Version': 'a_string'}, 'VCResourceCompilerTool': {'AdditionalIncludeDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'Culture': '1003', 'IgnoreStandardIncludePath': 'true', 'PreprocessorDefinitions': 'd1;d2;d3', 'ResourceOutputFileName': 'a_string', 'ShowProgress': 'true', 'SuppressStartupBanner': 'true', 'UndefinePreprocessorDefinitions': 'd1;d2;d3'}, 'VCMIDLTool': {'AdditionalIncludeDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'CPreprocessOptions': 'a_string', 'DefaultCharType': '0', 'DLLDataFileName': 'a_file_name', 'EnableErrorChecks': '2', 'ErrorCheckAllocations': 'true', 'ErrorCheckBounds': 'true', 'ErrorCheckEnumRange': 'true', 'ErrorCheckRefPointers': 'true', 'ErrorCheckStubData': 'true', 'GenerateStublessProxies': 'true', 'GenerateTypeLibrary': 'true', 'HeaderFileName': 'a_file_name', 'IgnoreStandardIncludePath': 'true', 'InterfaceIdentifierFileName': 'a_file_name', 'MkTypLibCompatible': 'true', 'OutputDirectory': 'a_string', 'PreprocessorDefinitions': 'd1;d2;d3', 'ProxyFileName': 'a_file_name', 'RedirectOutputAndErrors': 'a_file_name', 'StructMemberAlignment': '3', 'SuppressStartupBanner': 'true', 'TargetEnvironment': '1', 'TypeLibraryName': 'a_file_name', 'UndefinePreprocessorDefinitions': 'd1;d2;d3', 'ValidateParameters': 'true', 'WarnAsError': 'true', 'WarningLevel': '4'}, 'VCLibrarianTool': {'AdditionalDependencies': 'file1;file2;file3', 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', 'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'ExportNamedFunctions': 'd1;d2;d3', 'ForceSymbolReferences': 'a_string', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3', 'LinkLibraryDependencies': 'true', 'ModuleDefinitionFile': 'a_file_name', 'OutputFile': 'a_file_name', 'SuppressStartupBanner': 'true', 'UseUnicodeResponseFiles': 'true'}, 'VCManifestTool': {'AdditionalManifestFiles': 'file1;file2;file3', 'AdditionalOptions': 'a_string', 'AssemblyIdentity': 'a_string', 'ComponentFileName': 'a_file_name', 'DependencyInformationFile': 'a_file_name', 'EmbedManifest': 'true', 'GenerateCatalogFiles': 'true', 'InputResourceManifests': 'a_string', 'ManifestResourceFile': 'my_name', 'OutputManifestFile': 'a_file_name', 'RegistrarScriptFile': 'a_file_name', 'ReplacementsFile': 'a_file_name', 'SuppressStartupBanner': 'true', 'TypeLibraryFile': 'a_file_name', 'UpdateFileHashes': 'true', 'UpdateFileHashesSearchPath': 'a_file_name', 'UseFAT32Workaround': 'true', 'UseUnicodeResponseFiles': 'true', 'VerboseOutput': 'true'}}
expected_msbuild_settings = {'ClCompile': {'AdditionalIncludeDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string /J', 'AdditionalUsingDirectories': 'folder1;folder2;folder3', 'AssemblerListingLocation': 'a_file_name', 'AssemblerOutput': 'NoListing', 'BasicRuntimeChecks': 'StackFrameRuntimeCheck', 'BrowseInformation': 'true', 'BrowseInformationFile': 'a_file_name', 'BufferSecurityCheck': 'true', 'CallingConvention': 'Cdecl', 'CompileAs': 'CompileAsC', 'DebugInformationFormat': 'EditAndContinue', 'DisableLanguageExtensions': 'true', 'DisableSpecificWarnings': 'd1;d2;d3', 'EnableEnhancedInstructionSet': 'NotSet', 'EnableFiberSafeOptimizations': 'true', 'EnablePREfast': 'true', 'ErrorReporting': 'Prompt', 'ExceptionHandling': 'Async', 'ExpandAttributedSource': 'true', 'FavorSizeOrSpeed': 'Neither', 'FloatingPointExceptions': 'true', 'FloatingPointModel': 'Strict', 'ForceConformanceInForLoopScope': 'true', 'ForcedIncludeFiles': 'file1;file2;file3', 'ForcedUsingFiles': 'file1;file2;file3', 'FunctionLevelLinking': 'true', 'GenerateXMLDocumentationFiles': 'true', 'IgnoreStandardIncludePath': 'true', 'InlineFunctionExpansion': 'AnySuitable', 'IntrinsicFunctions': 'true', 'MinimalRebuild': 'true', 'ObjectFileName': 'a_file_name', 'OmitDefaultLibName': 'true', 'OmitFramePointers': 'true', 'OpenMPSupport': 'true', 'Optimization': 'Full', 'PrecompiledHeader': 'Create', 'PrecompiledHeaderFile': 'a_file_name', 'PrecompiledHeaderOutputFile': 'a_file_name', 'PreprocessKeepComments': 'true', 'PreprocessorDefinitions': 'd1;d2;d3', 'PreprocessSuppressLineNumbers': 'false', 'PreprocessToFile': 'true', 'ProgramDataBaseFileName': 'a_file_name', 'RuntimeLibrary': 'MultiThreaded', 'RuntimeTypeInfo': 'true', 'ShowIncludes': 'true', 'SmallerTypeCheck': 'true', 'StringPooling': 'true', 'StructMemberAlignment': '1Byte', 'SuppressStartupBanner': 'true', 'TreatWarningAsError': 'true', 'TreatWChar_tAsBuiltInType': 'true', 'UndefineAllPreprocessorDefinitions': 'true', 'UndefinePreprocessorDefinitions': 'd1;d2;d3', 'UseFullPaths': 'true', 'WarningLevel': 'Level2', 'WholeProgramOptimization': 'true', 'XMLDocumentationFileName': 'a_file_name'}, 'Link': {'AdditionalDependencies': 'file1;file2;file3', 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', 'AdditionalManifestDependencies': 'file1;file2;file3', 'AdditionalOptions': 'a_string', 'AddModuleNamesToAssembly': 'file1;file2;file3', 'AllowIsolation': 'true', 'AssemblyDebug': '', 'AssemblyLinkResource': 'file1;file2;file3', 'BaseAddress': 'a_string', 'CLRImageType': 'ForceIJWImage', 'CLRThreadAttribute': 'STAThreadingAttribute', 'CLRUnmanagedCodeCheck': 'true', 'DataExecutionPrevention': '', 'DelayLoadDLLs': 'file1;file2;file3', 'DelaySign': 'true', 'Driver': 'Driver', 'EmbedManagedResourceFile': 'file1;file2;file3', 'EnableCOMDATFolding': '', 'EnableUAC': 'true', 'EntryPointSymbol': 'a_string', 'FixedBaseAddress': 'false', 'ForceSymbolReferences': 'file1;file2;file3', 'FunctionOrder': 'a_file_name', 'GenerateDebugInformation': 'true', 'GenerateMapFile': 'true', 'HeapCommitSize': 'a_string', 'HeapReserveSize': 'a_string', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreEmbeddedIDL': 'true', 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3', 'ImportLibrary': 'a_file_name', 'KeyContainer': 'a_file_name', 'KeyFile': 'a_file_name', 'LargeAddressAware': 'true', 'LinkErrorReporting': 'NoErrorReport', 'LinkTimeCodeGeneration': 'PGInstrument', 'ManifestFile': 'a_file_name', 'MapExports': 'true', 'MapFileName': 'a_file_name', 'MergedIDLBaseFileName': 'a_file_name', 'MergeSections': 'a_string', 'MidlCommandFile': 'a_file_name', 'ModuleDefinitionFile': 'a_file_name', 'NoEntryPoint': 'true', 'OptimizeReferences': '', 'OutputFile': 'a_file_name', 'PerUserRedirection': 'true', 'Profile': 'true', 'ProfileGuidedDatabase': 'a_file_name', 'ProgramDatabaseFile': 'a_file_name', 'RandomizedBaseAddress': 'false', 'RegisterOutput': 'true', 'SetChecksum': 'true', 'ShowProgress': 'NotSet', 'StackCommitSize': 'a_string', 'StackReserveSize': 'a_string', 'StripPrivateSymbols': 'a_file_name', 'SubSystem': 'Windows', 'SupportUnloadOfDelayLoadedDLL': 'true', 'SuppressStartupBanner': 'true', 'SwapRunFromCD': 'true', 'SwapRunFromNET': 'true', 'TargetMachine': 'MachineARM', 'TerminalServerAware': 'true', 'TurnOffAssemblyGeneration': 'true', 'TypeLibraryFile': 'a_file_name', 'TypeLibraryResourceID': '33', 'UACExecutionLevel': 'HighestAvailable', 'UACUIAccess': 'true', 'Version': 'a_string'}, 'ResourceCompile': {'AdditionalIncludeDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'Culture': '0x03eb', 'IgnoreStandardIncludePath': 'true', 'PreprocessorDefinitions': 'd1;d2;d3', 'ResourceOutputFileName': 'a_string', 'ShowProgress': 'true', 'SuppressStartupBanner': 'true', 'UndefinePreprocessorDefinitions': 'd1;d2;d3'}, 'Midl': {'AdditionalIncludeDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'CPreprocessOptions': 'a_string', 'DefaultCharType': 'Unsigned', 'DllDataFileName': 'a_file_name', 'EnableErrorChecks': 'All', 'ErrorCheckAllocations': 'true', 'ErrorCheckBounds': 'true', 'ErrorCheckEnumRange': 'true', 'ErrorCheckRefPointers': 'true', 'ErrorCheckStubData': 'true', 'GenerateStublessProxies': 'true', 'GenerateTypeLibrary': 'true', 'HeaderFileName': 'a_file_name', 'IgnoreStandardIncludePath': 'true', 'InterfaceIdentifierFileName': 'a_file_name', 'MkTypLibCompatible': 'true', 'OutputDirectory': 'a_string', 'PreprocessorDefinitions': 'd1;d2;d3', 'ProxyFileName': 'a_file_name', 'RedirectOutputAndErrors': 'a_file_name', 'StructMemberAlignment': '4', 'SuppressStartupBanner': 'true', 'TargetEnvironment': 'Win32', 'TypeLibraryName': 'a_file_name', 'UndefinePreprocessorDefinitions': 'd1;d2;d3', 'ValidateAllParameters': 'true', 'WarnAsError': 'true', 'WarningLevel': '4'}, 'Lib': {'AdditionalDependencies': 'file1;file2;file3', 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', 'AdditionalOptions': 'a_string', 'ExportNamedFunctions': 'd1;d2;d3', 'ForceSymbolReferences': 'a_string', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3', 'ModuleDefinitionFile': 'a_file_name', 'OutputFile': 'a_file_name', 'SuppressStartupBanner': 'true', 'UseUnicodeResponseFiles': 'true'}, 'Manifest': {'AdditionalManifestFiles': 'file1;file2;file3', 'AdditionalOptions': 'a_string', 'AssemblyIdentity': 'a_string', 'ComponentFileName': 'a_file_name', 'GenerateCatalogFiles': 'true', 'InputResourceManifests': 'a_string', 'OutputManifestFile': 'a_file_name', 'RegistrarScriptFile': 'a_file_name', 'ReplacementsFile': 'a_file_name', 'SuppressStartupBanner': 'true', 'TypeLibraryFile': 'a_file_name', 'UpdateFileHashes': 'true', 'UpdateFileHashesSearchPath': 'a_file_name', 'VerboseOutput': 'true'}, 'ManifestResourceCompile': {'ResourceOutputFileName': 'my_name'}, 'ProjectReference': {'LinkLibraryDependencies': 'true', 'UseLibraryDependencyInputs': 'false'}, '': {'EmbedManifest': 'true', 'GenerateManifest': 'true', 'IgnoreImportLibrary': 'true', 'LinkIncremental': 'false'}}
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings, self.stderr)
self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
self._ExpectedWarnings([])
|
'Tests the conversion of an actual project.
A VS2008 project with most of the options defined was created through the
VS2008 IDE. It was then converted to VS2010. The tool settings found in
the .vcproj and .vcxproj files were converted to the two dictionaries
msvs_settings and expected_msbuild_settings.
Note that for many settings, the VS2010 converter adds macros like
%(AdditionalIncludeDirectories) to make sure than inherited values are
included. Since the Gyp projects we generate do not use inheritance,
we removed these macros. They were:
ClCompile:
AdditionalIncludeDirectories: \';%(AdditionalIncludeDirectories)\'
AdditionalOptions: \' %(AdditionalOptions)\'
AdditionalUsingDirectories: \';%(AdditionalUsingDirectories)\'
DisableSpecificWarnings: \';%(DisableSpecificWarnings)\',
ForcedIncludeFiles: \';%(ForcedIncludeFiles)\',
ForcedUsingFiles: \';%(ForcedUsingFiles)\',
PreprocessorDefinitions: \';%(PreprocessorDefinitions)\',
UndefinePreprocessorDefinitions:
\';%(UndefinePreprocessorDefinitions)\',
Link:
AdditionalDependencies: \';%(AdditionalDependencies)\',
AdditionalLibraryDirectories: \';%(AdditionalLibraryDirectories)\',
AdditionalManifestDependencies:
\';%(AdditionalManifestDependencies)\',
AdditionalOptions: \' %(AdditionalOptions)\',
AddModuleNamesToAssembly: \';%(AddModuleNamesToAssembly)\',
AssemblyLinkResource: \';%(AssemblyLinkResource)\',
DelayLoadDLLs: \';%(DelayLoadDLLs)\',
EmbedManagedResourceFile: \';%(EmbedManagedResourceFile)\',
ForceSymbolReferences: \';%(ForceSymbolReferences)\',
IgnoreSpecificDefaultLibraries:
\';%(IgnoreSpecificDefaultLibraries)\',
ResourceCompile:
AdditionalIncludeDirectories: \';%(AdditionalIncludeDirectories)\',
AdditionalOptions: \' %(AdditionalOptions)\',
PreprocessorDefinitions: \';%(PreprocessorDefinitions)\',
Manifest:
AdditionalManifestFiles: \';%(AdditionalManifestFiles)\',
AdditionalOptions: \' %(AdditionalOptions)\',
InputResourceManifests: \';%(InputResourceManifests)\','
| def testConvertToMSBuildSettings_actual(self):
| msvs_settings = {'VCCLCompilerTool': {'AdditionalIncludeDirectories': 'dir1', 'AdditionalOptions': '/more', 'AdditionalUsingDirectories': 'test', 'AssemblerListingLocation': '$(IntDir)\\a', 'AssemblerOutput': '1', 'BasicRuntimeChecks': '3', 'BrowseInformation': '1', 'BrowseInformationFile': '$(IntDir)\\e', 'BufferSecurityCheck': 'false', 'CallingConvention': '1', 'CompileAs': '1', 'DebugInformationFormat': '4', 'DefaultCharIsUnsigned': 'true', 'Detect64BitPortabilityProblems': 'true', 'DisableLanguageExtensions': 'true', 'DisableSpecificWarnings': 'abc', 'EnableEnhancedInstructionSet': '1', 'EnableFiberSafeOptimizations': 'true', 'EnableFunctionLevelLinking': 'true', 'EnableIntrinsicFunctions': 'true', 'EnablePREfast': 'true', 'ErrorReporting': '2', 'ExceptionHandling': '2', 'ExpandAttributedSource': 'true', 'FavorSizeOrSpeed': '2', 'FloatingPointExceptions': 'true', 'FloatingPointModel': '1', 'ForceConformanceInForLoopScope': 'false', 'ForcedIncludeFiles': 'def', 'ForcedUsingFiles': 'ge', 'GeneratePreprocessedFile': '2', 'GenerateXMLDocumentationFiles': 'true', 'IgnoreStandardIncludePath': 'true', 'InlineFunctionExpansion': '1', 'KeepComments': 'true', 'MinimalRebuild': 'true', 'ObjectFile': '$(IntDir)\\b', 'OmitDefaultLibName': 'true', 'OmitFramePointers': 'true', 'OpenMP': 'true', 'Optimization': '3', 'PrecompiledHeaderFile': '$(IntDir)\\$(TargetName).pche', 'PrecompiledHeaderThrough': 'StdAfx.hd', 'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE', 'ProgramDataBaseFileName': '$(IntDir)\\vc90b.pdb', 'RuntimeLibrary': '3', 'RuntimeTypeInfo': 'false', 'ShowIncludes': 'true', 'SmallerTypeCheck': 'true', 'StringPooling': 'true', 'StructMemberAlignment': '3', 'SuppressStartupBanner': 'false', 'TreatWChar_tAsBuiltInType': 'false', 'UndefineAllPreprocessorDefinitions': 'true', 'UndefinePreprocessorDefinitions': 'wer', 'UseFullPaths': 'true', 'UsePrecompiledHeader': '0', 'UseUnicodeResponseFiles': 'false', 'WarnAsError': 'true', 'WarningLevel': '3', 'WholeProgramOptimization': 'true', 'XMLDocumentationFileName': '$(IntDir)\\c'}, 'VCLinkerTool': {'AdditionalDependencies': 'zx', 'AdditionalLibraryDirectories': 'asd', 'AdditionalManifestDependencies': 's2', 'AdditionalOptions': '/mor2', 'AddModuleNamesToAssembly': 'd1', 'AllowIsolation': 'false', 'AssemblyDebug': '1', 'AssemblyLinkResource': 'd5', 'BaseAddress': '23423', 'CLRImageType': '3', 'CLRThreadAttribute': '1', 'CLRUnmanagedCodeCheck': 'true', 'DataExecutionPrevention': '0', 'DelayLoadDLLs': 'd4', 'DelaySign': 'true', 'Driver': '2', 'EmbedManagedResourceFile': 'd2', 'EnableCOMDATFolding': '1', 'EnableUAC': 'false', 'EntryPointSymbol': 'f5', 'ErrorReporting': '2', 'FixedBaseAddress': '1', 'ForceSymbolReferences': 'd3', 'FunctionOrder': 'fssdfsd', 'GenerateDebugInformation': 'true', 'GenerateManifest': 'false', 'GenerateMapFile': 'true', 'HeapCommitSize': '13', 'HeapReserveSize': '12', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreDefaultLibraryNames': 'flob;flok', 'IgnoreEmbeddedIDL': 'true', 'IgnoreImportLibrary': 'true', 'ImportLibrary': 'f4', 'KeyContainer': 'f7', 'KeyFile': 'f6', 'LargeAddressAware': '2', 'LinkIncremental': '0', 'LinkLibraryDependencies': 'false', 'LinkTimeCodeGeneration': '1', 'ManifestFile': '$(IntDir)\\$(TargetFileName).2intermediate.manifest', 'MapExports': 'true', 'MapFileName': 'd5', 'MergedIDLBaseFileName': 'f2', 'MergeSections': 'f5', 'MidlCommandFile': 'f1', 'ModuleDefinitionFile': 'sdsd', 'OptimizeForWindows98': '2', 'OptimizeReferences': '2', 'OutputFile': '$(OutDir)\\$(ProjectName)2.exe', 'PerUserRedirection': 'true', 'Profile': 'true', 'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd', 'ProgramDatabaseFile': 'Flob.pdb', 'RandomizedBaseAddress': '1', 'RegisterOutput': 'true', 'ResourceOnlyDLL': 'true', 'SetChecksum': 'false', 'ShowProgress': '1', 'StackCommitSize': '15', 'StackReserveSize': '14', 'StripPrivateSymbols': 'd3', 'SubSystem': '1', 'SupportUnloadOfDelayLoadedDLL': 'true', 'SuppressStartupBanner': 'false', 'SwapRunFromCD': 'true', 'SwapRunFromNet': 'true', 'TargetMachine': '1', 'TerminalServerAware': '1', 'TurnOffAssemblyGeneration': 'true', 'TypeLibraryFile': 'f3', 'TypeLibraryResourceID': '12', 'UACExecutionLevel': '2', 'UACUIAccess': 'true', 'UseLibraryDependencyInputs': 'true', 'UseUnicodeResponseFiles': 'false', 'Version': '333'}, 'VCResourceCompilerTool': {'AdditionalIncludeDirectories': 'f3', 'AdditionalOptions': '/more3', 'Culture': '3084', 'IgnoreStandardIncludePath': 'true', 'PreprocessorDefinitions': '_UNICODE;UNICODE2', 'ResourceOutputFileName': '$(IntDir)/$(InputName)3.res', 'ShowProgress': 'true'}, 'VCManifestTool': {'AdditionalManifestFiles': 'sfsdfsd', 'AdditionalOptions': 'afdsdafsd', 'AssemblyIdentity': 'sddfdsadfsa', 'ComponentFileName': 'fsdfds', 'DependencyInformationFile': '$(IntDir)\\mt.depdfd', 'EmbedManifest': 'false', 'GenerateCatalogFiles': 'true', 'InputResourceManifests': 'asfsfdafs', 'ManifestResourceFile': '$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf', 'OutputManifestFile': '$(TargetPath).manifestdfs', 'RegistrarScriptFile': 'sdfsfd', 'ReplacementsFile': 'sdffsd', 'SuppressStartupBanner': 'false', 'TypeLibraryFile': 'sfsd', 'UpdateFileHashes': 'true', 'UpdateFileHashesSearchPath': 'sfsd', 'UseFAT32Workaround': 'true', 'UseUnicodeResponseFiles': 'false', 'VerboseOutput': 'true'}}
expected_msbuild_settings = {'ClCompile': {'AdditionalIncludeDirectories': 'dir1', 'AdditionalOptions': '/more /J', 'AdditionalUsingDirectories': 'test', 'AssemblerListingLocation': '$(IntDir)a', 'AssemblerOutput': 'AssemblyCode', 'BasicRuntimeChecks': 'EnableFastChecks', 'BrowseInformation': 'true', 'BrowseInformationFile': '$(IntDir)e', 'BufferSecurityCheck': 'false', 'CallingConvention': 'FastCall', 'CompileAs': 'CompileAsC', 'DebugInformationFormat': 'EditAndContinue', 'DisableLanguageExtensions': 'true', 'DisableSpecificWarnings': 'abc', 'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions', 'EnableFiberSafeOptimizations': 'true', 'EnablePREfast': 'true', 'ErrorReporting': 'Queue', 'ExceptionHandling': 'Async', 'ExpandAttributedSource': 'true', 'FavorSizeOrSpeed': 'Size', 'FloatingPointExceptions': 'true', 'FloatingPointModel': 'Strict', 'ForceConformanceInForLoopScope': 'false', 'ForcedIncludeFiles': 'def', 'ForcedUsingFiles': 'ge', 'FunctionLevelLinking': 'true', 'GenerateXMLDocumentationFiles': 'true', 'IgnoreStandardIncludePath': 'true', 'InlineFunctionExpansion': 'OnlyExplicitInline', 'IntrinsicFunctions': 'true', 'MinimalRebuild': 'true', 'ObjectFileName': '$(IntDir)b', 'OmitDefaultLibName': 'true', 'OmitFramePointers': 'true', 'OpenMPSupport': 'true', 'Optimization': 'Full', 'PrecompiledHeader': 'NotUsing', 'PrecompiledHeaderFile': 'StdAfx.hd', 'PrecompiledHeaderOutputFile': '$(IntDir)$(TargetName).pche', 'PreprocessKeepComments': 'true', 'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE', 'PreprocessSuppressLineNumbers': 'true', 'PreprocessToFile': 'true', 'ProgramDataBaseFileName': '$(IntDir)vc90b.pdb', 'RuntimeLibrary': 'MultiThreadedDebugDLL', 'RuntimeTypeInfo': 'false', 'ShowIncludes': 'true', 'SmallerTypeCheck': 'true', 'StringPooling': 'true', 'StructMemberAlignment': '4Bytes', 'SuppressStartupBanner': 'false', 'TreatWarningAsError': 'true', 'TreatWChar_tAsBuiltInType': 'false', 'UndefineAllPreprocessorDefinitions': 'true', 'UndefinePreprocessorDefinitions': 'wer', 'UseFullPaths': 'true', 'WarningLevel': 'Level3', 'WholeProgramOptimization': 'true', 'XMLDocumentationFileName': '$(IntDir)c'}, 'Link': {'AdditionalDependencies': 'zx', 'AdditionalLibraryDirectories': 'asd', 'AdditionalManifestDependencies': 's2', 'AdditionalOptions': '/mor2', 'AddModuleNamesToAssembly': 'd1', 'AllowIsolation': 'false', 'AssemblyDebug': 'true', 'AssemblyLinkResource': 'd5', 'BaseAddress': '23423', 'CLRImageType': 'ForceSafeILImage', 'CLRThreadAttribute': 'MTAThreadingAttribute', 'CLRUnmanagedCodeCheck': 'true', 'DataExecutionPrevention': '', 'DelayLoadDLLs': 'd4', 'DelaySign': 'true', 'Driver': 'UpOnly', 'EmbedManagedResourceFile': 'd2', 'EnableCOMDATFolding': 'false', 'EnableUAC': 'false', 'EntryPointSymbol': 'f5', 'FixedBaseAddress': 'false', 'ForceSymbolReferences': 'd3', 'FunctionOrder': 'fssdfsd', 'GenerateDebugInformation': 'true', 'GenerateMapFile': 'true', 'HeapCommitSize': '13', 'HeapReserveSize': '12', 'IgnoreAllDefaultLibraries': 'true', 'IgnoreEmbeddedIDL': 'true', 'IgnoreSpecificDefaultLibraries': 'flob;flok', 'ImportLibrary': 'f4', 'KeyContainer': 'f7', 'KeyFile': 'f6', 'LargeAddressAware': 'true', 'LinkErrorReporting': 'QueueForNextLogin', 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration', 'ManifestFile': '$(IntDir)$(TargetFileName).2intermediate.manifest', 'MapExports': 'true', 'MapFileName': 'd5', 'MergedIDLBaseFileName': 'f2', 'MergeSections': 'f5', 'MidlCommandFile': 'f1', 'ModuleDefinitionFile': 'sdsd', 'NoEntryPoint': 'true', 'OptimizeReferences': 'true', 'OutputFile': '$(OutDir)$(ProjectName)2.exe', 'PerUserRedirection': 'true', 'Profile': 'true', 'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd', 'ProgramDatabaseFile': 'Flob.pdb', 'RandomizedBaseAddress': 'false', 'RegisterOutput': 'true', 'SetChecksum': 'false', 'ShowProgress': 'LinkVerbose', 'StackCommitSize': '15', 'StackReserveSize': '14', 'StripPrivateSymbols': 'd3', 'SubSystem': 'Console', 'SupportUnloadOfDelayLoadedDLL': 'true', 'SuppressStartupBanner': 'false', 'SwapRunFromCD': 'true', 'SwapRunFromNET': 'true', 'TargetMachine': 'MachineX86', 'TerminalServerAware': 'false', 'TurnOffAssemblyGeneration': 'true', 'TypeLibraryFile': 'f3', 'TypeLibraryResourceID': '12', 'UACExecutionLevel': 'RequireAdministrator', 'UACUIAccess': 'true', 'Version': '333'}, 'ResourceCompile': {'AdditionalIncludeDirectories': 'f3', 'AdditionalOptions': '/more3', 'Culture': '0x0c0c', 'IgnoreStandardIncludePath': 'true', 'PreprocessorDefinitions': '_UNICODE;UNICODE2', 'ResourceOutputFileName': '$(IntDir)%(Filename)3.res', 'ShowProgress': 'true'}, 'Manifest': {'AdditionalManifestFiles': 'sfsdfsd', 'AdditionalOptions': 'afdsdafsd', 'AssemblyIdentity': 'sddfdsadfsa', 'ComponentFileName': 'fsdfds', 'GenerateCatalogFiles': 'true', 'InputResourceManifests': 'asfsfdafs', 'OutputManifestFile': '$(TargetPath).manifestdfs', 'RegistrarScriptFile': 'sdfsfd', 'ReplacementsFile': 'sdffsd', 'SuppressStartupBanner': 'false', 'TypeLibraryFile': 'sfsd', 'UpdateFileHashes': 'true', 'UpdateFileHashesSearchPath': 'sfsd', 'VerboseOutput': 'true'}, 'ProjectReference': {'LinkLibraryDependencies': 'false', 'UseLibraryDependencyInputs': 'true'}, '': {'EmbedManifest': 'false', 'GenerateManifest': 'false', 'IgnoreImportLibrary': 'true', 'LinkIncremental': ''}, 'ManifestResourceCompile': {'ResourceOutputFileName': '$(IntDir)$(TargetFileName).embed.manifest.resfdsf'}}
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings, self.stderr)
self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
self._ExpectedWarnings([])
|
'Test that sorting works on a valid graph with one possible order.'
| def test_Valid(self):
| graph = {'a': ['b', 'c'], 'b': [], 'c': ['d'], 'd': ['b']}
def GetEdge(node):
return tuple(graph[node])
self.assertEqual(gyp.common.TopologicallySorted(graph.keys(), GetEdge), ['a', 'c', 'd', 'b'])
|
'Test that an exception is thrown on a cyclic graph.'
| def test_Cycle(self):
| graph = {'a': ['b'], 'b': ['c'], 'c': ['d'], 'd': ['a']}
def GetEdge(node):
return tuple(graph[node])
self.assertRaises(gyp.common.CycleError, gyp.common.TopologicallySorted, graph.keys(), GetEdge)
|
'Initializes the tool file.
Args:
tool_file_path: Path to the tool file.
name: Name of the tool file.'
| def __init__(self, tool_file_path, name):
| self.tool_file_path = tool_file_path
self.name = name
self.rules_section = ['Rules']
|
'Adds a rule to the tool file.
Args:
name: Name of the rule.
description: Description of the rule.
cmd: Command line of the rule.
additional_dependencies: other files which may trigger the rule.
outputs: outputs of the rule.
extensions: extensions handled by the rule.'
| def AddCustomBuildRule(self, name, cmd, description, additional_dependencies, outputs, extensions):
| rule = ['CustomBuildRule', {'Name': name, 'ExecutionDescription': description, 'CommandLine': cmd, 'Outputs': ';'.join(outputs), 'FileExtensions': ';'.join(extensions), 'AdditionalDependencies': ';'.join(additional_dependencies)}]
self.rules_section.append(rule)
|
'Writes the tool file.'
| def WriteIfChanged(self):
| content = ['VisualStudioToolFile', {'Version': '8.00', 'Name': self.name}, self.rules_section]
easy_xml.WriteXmlIfChanged(content, self.tool_file_path, encoding='Windows-1252')
|
'Get the full description of the version.'
| def Description(self):
| return self.description
|
'Get the version number of the sln files.'
| def SolutionVersion(self):
| return self.solution_version
|
'Get the version number of the vcproj or vcxproj files.'
| def ProjectVersion(self):
| return self.project_version
|
'Returns true if this version uses a vcxproj file.'
| def UsesVcxproj(self):
| return self.uses_vcxproj
|
'Returns the file extension for the project.'
| def ProjectExtension(self):
| return ((self.uses_vcxproj and '.vcxproj') or '.vcproj')
|
'Returns the path to Visual Studio installation.'
| def Path(self):
| return self.path
|
'Returns the path to a given compiler tool.'
| def ToolPath(self, tool):
| return os.path.normpath(os.path.join(self.path, 'VC/bin', tool))
|
'Returns the msbuild toolset version that will be used in the absence
of a user override.'
| def DefaultToolset(self):
| return self.default_toolset
|
'Returns a command (with arguments) to be used to set up the
environment.'
| def SetupScript(self, target_arch):
| assert (target_arch in ('x86', 'x64'))
sdk_dir = os.environ.get('WindowsSDKDir')
if (self.sdk_based and sdk_dir):
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')), ('/' + target_arch)]
elif (target_arch == 'x86'):
if ((self.short_name >= '2013') and (self.short_name[(-1)] != 'e') and ((os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64') or (os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'))):
return [os.path.normpath(os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
return [os.path.normpath(os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
else:
assert (target_arch == 'x64')
arg = 'x86_amd64'
if ((self.short_name[(-1)] != 'e') and ((os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64') or (os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'))):
arg = 'amd64'
return [os.path.normpath(os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
|
'Dispatches a string command to a method.'
| def Dispatch(self, args):
| if (len(args) < 1):
raise Exception('Not enough arguments')
method = ('Exec%s' % self._CommandifyName(args[0]))
return getattr(self, method)(*args[1:])
|
'Transforms a tool name like copy-info-plist to CopyInfoPlist'
| def _CommandifyName(self, name_string):
| return name_string.title().replace('-', '')
|
'Copies a resource file to the bundle/Resources directory, performing any
necessary compilation on each resource.'
| def ExecCopyBundleResource(self, source, dest, convert_to_binary):
| extension = os.path.splitext(source)[1].lower()
if os.path.isdir(source):
if os.path.exists(dest):
shutil.rmtree(dest)
shutil.copytree(source, dest)
elif (extension == '.xib'):
return self._CopyXIBFile(source, dest)
elif (extension == '.storyboard'):
return self._CopyXIBFile(source, dest)
elif (extension == '.strings'):
self._CopyStringsFile(source, dest, convert_to_binary)
else:
shutil.copy(source, dest)
|
'Compiles a XIB file with ibtool into a binary plist in the bundle.'
| def _CopyXIBFile(self, source, dest):
| base = os.path.dirname(os.path.realpath(__file__))
if os.path.relpath(source):
source = os.path.join(base, source)
if os.path.relpath(dest):
dest = os.path.join(base, dest)
args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices', '--output-format', 'human-readable-text', '--compile', dest, source]
ibtool_section_re = re.compile('/\\*.*\\*/')
ibtool_re = re.compile('.*note:.*is clipping its content')
ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE)
current_section_header = None
for line in ibtoolout.stdout:
if ibtool_section_re.match(line):
current_section_header = line
elif (not ibtool_re.match(line)):
if current_section_header:
sys.stdout.write(current_section_header)
current_section_header = None
sys.stdout.write(line)
return ibtoolout.returncode
|
'Copies a .strings file using iconv to reconvert the input into UTF-16.'
| def _CopyStringsFile(self, source, dest, convert_to_binary):
| input_code = (self._DetectInputEncoding(source) or 'UTF-8')
import CoreFoundation
s = open(source, 'rb').read()
d = CoreFoundation.CFDataCreate(None, s, len(s))
(_, error) = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
if error:
return
fp = open(dest, 'wb')
fp.write(s.decode(input_code).encode('UTF-16'))
fp.close()
if (convert_to_binary == 'True'):
self._ConvertToBinary(dest)
|
'Reads the first few bytes from file_name and tries to guess the text
encoding. Returns None as a guess if it can\'t detect it.'
| def _DetectInputEncoding(self, file_name):
| fp = open(file_name, 'rb')
try:
header = fp.read(3)
except e:
fp.close()
return None
fp.close()
if header.startswith('\xfe\xff'):
return 'UTF-16'
elif header.startswith('\xff\xfe'):
return 'UTF-16'
elif header.startswith('\xef\xbb\xbf'):
return 'UTF-8'
else:
return None
|
'Copies the |source| Info.plist to the destination directory |dest|.'
| def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
| fd = open(source, 'r')
lines = fd.read()
fd.close()
plist = plistlib.readPlistFromString(lines)
if keys:
plist = dict((plist.items() + json.loads(keys[0]).items()))
lines = plistlib.writePlistToString(plist)
IDENT_RE = re.compile('[/\\s]')
for key in os.environ:
if key.startswith('_'):
continue
evar = ('${%s}' % key)
evalue = os.environ[key]
lines = string.replace(lines, evar, evalue)
evar = ('${%s:identifier}' % key)
evalue = IDENT_RE.sub('_', os.environ[key])
lines = string.replace(lines, evar, evalue)
evar = ('${%s:rfc1034identifier}' % key)
evalue = IDENT_RE.sub('-', os.environ[key])
lines = string.replace(lines, evar, evalue)
lines = lines.split('\n')
for i in range(len(lines)):
if lines[i].strip().startswith('<string>${'):
lines[i] = None
lines[(i - 1)] = None
lines = '\n'.join(filter((lambda x: (x is not None)), lines))
fd = open(dest, 'w')
fd.write(lines)
fd.close()
self._WritePkgInfo(dest)
if (convert_to_binary == 'True'):
self._ConvertToBinary(dest)
|
'This writes the PkgInfo file from the data stored in Info.plist.'
| def _WritePkgInfo(self, info_plist):
| plist = plistlib.readPlist(info_plist)
if (not plist):
return
package_type = plist['CFBundlePackageType']
if (package_type != 'APPL'):
return
signature_code = plist.get('CFBundleSignature', '????')
if (len(signature_code) != 4):
signature_code = ('?' * 4)
dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo')
fp = open(dest, 'w')
fp.write(('%s%s' % (package_type, signature_code)))
fp.close()
|
'Emulates the most basic behavior of Linux\'s flock(1).'
| def ExecFlock(self, lockfile, *cmd_list):
| fd = os.open(lockfile, ((os.O_RDONLY | os.O_NOCTTY) | os.O_CREAT), 438)
fcntl.flock(fd, fcntl.LOCK_EX)
return subprocess.call(cmd_list)
|
'Calls libtool and filters out \'/path/to/libtool: file: foo.o has no
symbols\'.'
| def ExecFilterLibtool(self, *cmd_list):
| libtool_re = re.compile('^.*libtool: file: .* has no symbols$')
libtool_re5 = re.compile((('^.*libtool: warning for library: ' + '.* the table of contents is empty ') + '\\(no object file members in the library define global symbols\\)$'))
env = os.environ.copy()
env['ZERO_AR_DATE'] = '1'
libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env)
(_, err) = libtoolout.communicate()
for line in err.splitlines():
if ((not libtool_re.match(line)) and (not libtool_re5.match(line))):
print >>sys.stderr, line
if (not libtoolout.returncode):
for i in range((len(cmd_list) - 1)):
if ((cmd_list[i] == '-o') and cmd_list[(i + 1)].endswith('.a')):
os.utime(cmd_list[(i + 1)], None)
break
return libtoolout.returncode
|
'Takes a path to Something.framework and the Current version of that and
sets up all the symlinks.'
| def ExecPackageFramework(self, framework, version):
| binary = os.path.basename(framework).split('.')[0]
CURRENT = 'Current'
RESOURCES = 'Resources'
VERSIONS = 'Versions'
if (not os.path.exists(os.path.join(framework, VERSIONS, version, binary))):
return
pwd = os.getcwd()
os.chdir(framework)
self._Relink(version, os.path.join(VERSIONS, CURRENT))
self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary)
self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES)
os.chdir(pwd)
|
'Creates a symlink to |dest| named |link|. If |link| already exists,
it is overwritten.'
| def _Relink(self, dest, link):
| if os.path.lexists(link):
os.remove(link)
os.symlink(dest, link)
|
'Compiles multiple .xcassets files into a single .car file.
This invokes \'actool\' to compile all the inputs .xcassets files. The
|keys| arguments is a json-encoded dictionary of extra arguments to
pass to \'actool\' when the asset catalogs contains an application icon
or a launch image.
Note that \'actool\' does not create the Assets.car file if the asset
catalogs does not contains imageset.'
| def ExecCompileXcassets(self, keys, *inputs):
| command_line = ['xcrun', 'actool', '--output-format', 'human-readable-text', '--compress-pngs', '--notices', '--warnings', '--errors']
is_iphone_target = ('IPHONEOS_DEPLOYMENT_TARGET' in os.environ)
if is_iphone_target:
platform = os.environ['CONFIGURATION'].split('-')[(-1)]
if (platform not in ('iphoneos', 'iphonesimulator')):
platform = 'iphonesimulator'
command_line.extend(['--platform', platform, '--target-device', 'iphone', '--target-device', 'ipad', '--minimum-deployment-target', os.environ['IPHONEOS_DEPLOYMENT_TARGET'], '--compile', os.path.abspath(os.environ['CONTENTS_FOLDER_PATH'])])
else:
command_line.extend(['--platform', 'macosx', '--target-device', 'mac', '--minimum-deployment-target', os.environ['MACOSX_DEPLOYMENT_TARGET'], '--compile', os.path.abspath(os.environ['UNLOCALIZED_RESOURCES_FOLDER_PATH'])])
if keys:
keys = json.loads(keys)
for (key, value) in keys.iteritems():
arg_name = ('--' + key)
if isinstance(value, bool):
if value:
command_line.append(arg_name)
elif isinstance(value, list):
for v in value:
command_line.append(arg_name)
command_line.append(str(v))
else:
command_line.append(arg_name)
command_line.append(str(value))
command_line.extend(map(os.path.abspath, inputs))
subprocess.check_call(command_line)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.