diff options
author | Russel Winder <russel@winder.org.uk> | 2016-01-01 13:52:31 (GMT) |
---|---|---|
committer | Russel Winder <russel@winder.org.uk> | 2016-01-01 13:52:31 (GMT) |
commit | 34cf3bdb1743de9a5534bfd25998d0a01297f004 (patch) | |
tree | 95b6de82092af962dd5136c4017e7388bbb72aa2 /src/engine/SCons/Tool | |
parent | 2a270c8f314e959c78e9deda29c8f250bb934dd6 (diff) | |
download | SCons-34cf3bdb1743de9a5534bfd25998d0a01297f004.zip SCons-34cf3bdb1743de9a5534bfd25998d0a01297f004.tar.gz SCons-34cf3bdb1743de9a5534bfd25998d0a01297f004.tar.bz2 |
Run futurize --stage1.
Diffstat (limited to 'src/engine/SCons/Tool')
-rw-r--r-- | src/engine/SCons/Tool/cyglink.py | 37 | ||||
-rw-r--r-- | src/engine/SCons/Tool/f08.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Tool/msvs.py | 136 | ||||
-rw-r--r-- | src/engine/SCons/Tool/swig.py | 5 |
4 files changed, 94 insertions, 88 deletions
diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index 2f54a17..f69b886 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -7,6 +7,9 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ + +from __future__ import absolute_import, print_function + import re import os @@ -15,8 +18,8 @@ import SCons.Util import SCons.Tool #MAYBE: from . import gnulink -import gnulink -import link +from . import gnulink +from . import link def _lib_generator(target, source, env, for_signature, **kw): try: cmd = kw['cmd'] @@ -59,7 +62,7 @@ def _lib_emitter(target, source, env, **kw): Verbose = False if Verbose: - print "_lib_emitter: target[0]=%r" % target[0].get_path() + print("_lib_emitter: target[0]=%r" % target[0].get_path()) try: vp = kw['varprefix'] except KeyError: vp = 'SHLIB' @@ -71,7 +74,7 @@ def _lib_emitter(target, source, env, **kw): no_import_lib = env.get('no_import_lib', 0) if Verbose: - print "_lib_emitter: dll=%r" % dll.get_path() + print("_lib_emitter: dll=%r" % dll.get_path()) if not dll or len(target) > 1: raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$%sSUFFIX" % vp)) @@ -82,14 +85,14 @@ def _lib_emitter(target, source, env, **kw): dll.name = pre + dll.name[len(pre)+3:] if Verbose: - print "_lib_emitter: dll.name=%r" % dll.name + print("_lib_emitter: dll.name=%r" % dll.name) orig_target = target target = [env.fs.File(dll)] target[0].attributes.shared = 1 if Verbose: - print "_lib_emitter: after target=[env.fs.File(dll)]: target[0]=%r" % target[0].get_path() + print("_lib_emitter: after target=[env.fs.File(dll)]: target[0]=%r" % target[0].get_path()) # Append an import lib target if not no_import_lib: @@ -98,11 +101,11 @@ def _lib_emitter(target, source, env, **kw): '%sPREFIX' % vp, '%sSUFFIX' % vp, 'IMPLIBPREFIX', 'IMPLIBSUFFIX') if Verbose: - print "_lib_emitter: target_strings=%r" % target_strings + print("_lib_emitter: target_strings=%r" % target_strings) implib_target = env.fs.File(target_strings) if Verbose: - print "_lib_emitter: implib_target=%r" % implib_target.get_path() + print("_lib_emitter: implib_target=%r" % implib_target.get_path()) implib_target.attributes.shared = 1 target.append(implib_target) @@ -110,7 +113,7 @@ def _lib_emitter(target, source, env, **kw): implib_libtype=libtype, generator_libtype=libtype+'ImpLib') if Verbose: - print "_lib_emitter: implib symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) + print("_lib_emitter: implib symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks)) if symlinks: SCons.Tool.EmitLibSymlinks(env, symlinks, implib_target, clean_targets = target[0]) implib_target.attributes.shliblinks = symlinks @@ -128,13 +131,13 @@ def _versioned_lib_suffix(env, suffix, version): If suffix='.dll', and version='0.1.2', then it returns '-0-1-2.dll'""" Verbose = False if Verbose: - print "_versioned_lib_suffix: suffix= ", suffix - print "_versioned_lib_suffix: version= ", version + print("_versioned_lib_suffix: suffix= ", suffix) + print("_versioned_lib_suffix: version= ", version) cygversion = re.sub('\.', '-', version) if not suffix.startswith('-' + cygversion): suffix = '-' + cygversion + suffix if Verbose: - print "_versioned_lib_suffix: return suffix= ", suffix + print("_versioned_lib_suffix: return suffix= ", suffix) return suffix def _versioned_implib_name(env, libnode, version, prefix, suffix, **kw): @@ -150,8 +153,8 @@ def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): Verbose = False if Verbose: - print "_versioned_implib_symlinks: libnode=%r" % libnode.get_path() - print "_versioned_implib_symlinks: version=%r" % version + print("_versioned_implib_symlinks: libnode=%r" % libnode.get_path()) + print("_versioned_implib_symlinks: version=%r" % version) try: libtype = kw['libtype'] except KeyError: libtype = 'ShLib' @@ -159,13 +162,13 @@ def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): linkdir = os.path.dirname(libnode.get_path()) if Verbose: - print "_versioned_implib_symlinks: linkdir=%r" % linkdir + print("_versioned_implib_symlinks: linkdir=%r" % linkdir) name = SCons.Tool.ImpLibNameGenerator(env, libnode, implib_libtype=libtype, generator_libtype=libtype+'ImpLib') if Verbose: - print "_versioned_implib_symlinks: name=%r" % name + print("_versioned_implib_symlinks: name=%r" % name) major = version.split('.')[0] @@ -173,7 +176,7 @@ def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): symlinks = [(link0, libnode)] if Verbose: - print "_versioned_implib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks) + print("_versioned_implib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks)) return symlinks diff --git a/src/engine/SCons/Tool/f08.py b/src/engine/SCons/Tool/f08.py index a45a61d..7fa5872 100644 --- a/src/engine/SCons/Tool/f08.py +++ b/src/engine/SCons/Tool/f08.py @@ -8,6 +8,8 @@ selection method. """ +from __future__ import absolute_import + # # __COPYRIGHT__ # @@ -36,7 +38,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Defaults import SCons.Tool import SCons.Util -import fortran +from . import fortran from SCons.Tool.FortranCommon import add_all_to_env, add_f08_to_env compilers = ['f08'] diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index efdc8a1..c3c8164 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,6 +29,7 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -39,7 +40,6 @@ import base64 import hashlib import ntpath import os -# compat layer imports "cPickle" for us if it's available. import pickle import re import sys @@ -71,7 +71,7 @@ def xmlify(s): # Returns a tuple of nodes. def processIncludes(includes, env, target, source): return SCons.PathList.PathList(includes).subst_path(env, target, source) - + external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}' @@ -169,15 +169,15 @@ class _UserGenerator(object): Base class for .dsp.user file generator ''' # Default instance values. - # Ok ... a bit defensive, but it does not seem reasonable to crash the + # Ok ... a bit defensive, but it does not seem reasonable to crash the # build for a workspace user file. :-) usrhead = None - usrdebg = None + usrdebg = None usrconf = None - createfile = False + createfile = False def __init__(self, dspfile, source, env): # DebugSettings should be a list of debug dictionary sorted in the same order - # as the target list and variants + # as the target list and variants if 'variant' not in env: raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\ "'Release') to create an MSVSProject.") @@ -185,7 +185,7 @@ class _UserGenerator(object): variants = [env['variant']] elif SCons.Util.is_List(env['variant']): variants = env['variant'] - + if 'DebugSettings' not in env or env['DebugSettings'] == None: dbg_settings = [] elif SCons.Util.is_Dict(env['DebugSettings']): @@ -201,12 +201,12 @@ class _UserGenerator(object): dbg_settings.append({}) else: dbg_settings = [] - + if len(dbg_settings) == 1: dbg_settings = dbg_settings * len(variants) - + self.createfile = self.usrhead and self.usrdebg and self.usrconf and \ - dbg_settings and bool([ds for ds in dbg_settings if ds]) + dbg_settings and bool([ds for ds in dbg_settings if ds]) if self.createfile: dbg_settings = dict(zip(variants, dbg_settings)) @@ -216,22 +216,22 @@ class _UserGenerator(object): for key in [k for k in self.usrdebg.keys() if k in src]: trg[key] = str(src[key]) self.configs[var].debug = trg - + def UserHeader(self): encoding = self.env.subst('$MSVSENCODING') versionstr = self.versionstr self.usrfile.write(self.usrhead % locals()) - + def UserProject(self): pass - + def Build(self): if not self.createfile: return try: filename = self.dspabs +'.user' self.usrfile = open(filename, 'w') - except IOError, detail: + except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + filename + '" for writing:' + str(detail)) else: self.UserHeader() @@ -291,7 +291,7 @@ class _GenerateV7User(_UserGenerator): self.usrconf = V9UserConfiguration self.usrdebg = V9DebugSettings _UserGenerator.__init__(self, dspfile, source, env) - + def UserProject(self): confkeys = sorted(self.configs.keys()) for kind in confkeys: @@ -299,8 +299,8 @@ class _GenerateV7User(_UserGenerator): platform = self.configs[kind].platform debug = self.configs[kind].debug if debug: - debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value)) - for key, value in debug.items() + debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value)) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('\t</Configurations>\n</VisualStudioUserFile>') @@ -346,7 +346,7 @@ V10DebugSettings = { class _GenerateV10User(_UserGenerator): """Generates a Project'user file for MSVS 2010""" - + def __init__(self, dspfile, source, env): self.versionstr = '4.0' self.usrhead = V10UserHeader @@ -361,8 +361,8 @@ class _GenerateV10User(_UserGenerator): platform = self.configs[kind].platform debug = self.configs[kind].debug if debug: - debug_settings = '\n'.join(['\t\t<%s>%s</%s>' % (key, xmlify(value), key) - for key, value in debug.items() + debug_settings = '\n'.join(['\t\t<%s>%s</%s>' % (key, xmlify(value), key) + for key, value in debug.items() if value is not None]) self.usrfile.write(self.usrconf % locals()) self.usrfile.write('</Project>') @@ -458,7 +458,7 @@ class _DSPGenerator(object): runfile.append(s) self.sconscript = env['MSVSSCONSCRIPT'] - + if 'cmdargs' not in env or env['cmdargs'] == None: cmdargs = [''] * len(variants) elif SCons.Util.is_String(env['cmdargs']): @@ -468,7 +468,7 @@ class _DSPGenerator(object): raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.") else: cmdargs = env['cmdargs'] - + self.env = env if 'name' in self.env: @@ -550,16 +550,16 @@ V6DSPHeader = """\ CFG=%(name)s - Win32 %(confkey)s !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "%(name)s.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "%(name)s.mak" CFG="%(name)s - Win32 %(confkey)s" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE """ class _GenerateV6DSP(_DSPGenerator): @@ -818,7 +818,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.dspheader = V7DSPHeader self.dspconfiguration = V7DSPConfiguration self.file = None - + _GenerateV7User.__init__(self, dspfile, source, env) def PrintHeader(self): @@ -895,7 +895,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', [])))) includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None) includepath = xmlify(';'.join([str(x) for x in includepath_Dirs])) - + if not env_has_buildtarget: del self.env['MSVSBUILDTARGET'] @@ -1044,7 +1044,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): self.PrintHeader() self.PrintProject() self.file.close() - + _GenerateV7User.Build(self) V10DSPHeader = """\ @@ -1101,7 +1101,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.dspheader = V10DSPHeader self.dspconfiguration = V10DSPProjectConfiguration self.dspglobals = V10DSPGlobals - + _GenerateV10User.__init__(self, dspfile, source, env) def PrintHeader(self): @@ -1132,27 +1132,27 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): '\t\t<SccLocalPath>%s</SccLocalPath>\n' % (scc_project_name, scc_local_path_legacy)) else: self.dspglobals = self.dspglobals.replace('%(scc_attrs)s', '') - + self.file.write(self.dspheader % locals()) - + self.file.write('\t<ItemGroup Label="ProjectConfigurations">\n') - + confkeys = sorted(self.configs.keys()) for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform self.file.write(self.dspconfiguration % locals()) - + self.file.write('\t</ItemGroup>\n') - + self.file.write(self.dspglobals % locals()) - + def PrintProject(self): name = self.name confkeys = sorted(self.configs.keys()) - + self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n') - + toolset = '' if 'MSVC_VERSION' in self.env: version_num, suite = msvs_parse_version(self.env['MSVC_VERSION']) @@ -1165,16 +1165,16 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\n') self.file.write('\t<ImportGroup Label="ExtensionSettings">\n') self.file.write('\t</ImportGroup>\n') - + for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform self.file.write(V10DSPImportGroupCondition % locals()) - + self.file.write('\t<PropertyGroup Label="UserMacros" />\n') self.file.write('\t<PropertyGroup>\n') self.file.write('\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\n') - + for kind in confkeys: variant = self.configs[kind].variant platform = self.configs[kind].platform @@ -1182,7 +1182,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): buildtarget = self.configs[kind].buildtarget runfile = self.configs[kind].runfile cmdargs = self.configs[kind].cmdargs - + env_has_buildtarget = 'MSVSBUILDTARGET' in self.env if not env_has_buildtarget: self.env['MSVSBUILDTARGET'] = buildtarget @@ -1207,29 +1207,29 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): del self.env['MSVSBUILDTARGET'] self.file.write(V10DSPCommandLine % locals()) - + self.file.write('\t</PropertyGroup>\n') - + #filter settings in MSVS 2010 are stored in separate file self.filtersabs = self.dspabs + '.filters' try: self.filters_file = open(self.filtersabs, 'w') except IOError as detail: raise SCons.Errors.InternalError('Unable to open "' + self.filtersabs + '" for writing:' + str(detail)) - + self.filters_file.write('<?xml version="1.0" encoding="utf-8"?>\n' '<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n') - + self.PrintSourceFiles() - + self.filters_file.write('</Project>') self.filters_file.close() - + self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n' '\t<ImportGroup Label="ExtensionTargets">\n' '\t</ImportGroup>\n' '</Project>\n') - + if self.nokeep == 0: # now we pickle some data and add it to the file -- MSDEV will ignore it. pdata = pickle.dumps(self.configs,1) @@ -1241,7 +1241,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): def printFilters(self, hierarchy, name): sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) - + for key, value in sorteditems: if SCons.Util.is_Dict(value): filter_name = name + '\\' + key @@ -1249,14 +1249,14 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): '\t\t\t<UniqueIdentifier>%s</UniqueIdentifier>\n' '\t\t</Filter>\n' % (filter_name, _generateGUID(self.dspabs, filter_name))) self.printFilters(value, filter_name) - + def printSources(self, hierarchy, kind, commonprefix, filter_name): keywords = {'Source Files': 'ClCompile', 'Header Files': 'ClInclude', 'Local Headers': 'ClInclude', 'Resource Files': 'None', 'Other Files': 'None'} - + sorteditems = sorted(hierarchy.items(), key = lambda a: a[0].lower()) # First folders, then files @@ -1270,7 +1270,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): if commonprefix: file = os.path.join(commonprefix, value) file = os.path.normpath(file) - + self.file.write('\t\t<%s Include="%s" />\n' % (keywords[kind], file)) self.filters_file.write('\t\t<%s Include="%s">\n' '\t\t\t<Filter>%s</Filter>\n' @@ -1282,10 +1282,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): 'Local Headers': 'h;hpp;hxx;hm;inl', 'Resource Files': 'r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe', 'Other Files': ''} - + cats = sorted([k for k in categories.keys() if self.sources[k]], key = lambda a: a.lower()) - + # print vcxproj.filters file first self.filters_file.write('\t<ItemGroup>\n') for kind in cats: @@ -1293,7 +1293,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): '\t\t\t<UniqueIdentifier>{7b42d31d-d53c-4868-8b92-ca2bc9fc052f}</UniqueIdentifier>\n' '\t\t\t<Extensions>%s</Extensions>\n' '\t\t</Filter>\n' % (kind, categories[kind])) - + # First remove any common prefix sources = self.sources[kind] commonprefix = None @@ -1306,17 +1306,17 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): # +1 because the filename starts after the separator sources = [s[len(cp)+1:] for s in sources] commonprefix = cp - + hierarchy = makeHierarchy(sources) self.printFilters(hierarchy, kind) - + self.filters_file.write('\t</ItemGroup>\n') - + # then print files and filters for kind in cats: self.file.write('\t<ItemGroup>\n') self.filters_file.write('\t<ItemGroup>\n') - + # First remove any common prefix sources = self.sources[kind] commonprefix = None @@ -1329,13 +1329,13 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): # +1 because the filename starts after the separator sources = [s[len(cp)+1:] for s in sources] commonprefix = cp - + hierarchy = makeHierarchy(sources) self.printSources(hierarchy, kind, commonprefix, kind) - + self.file.write('\t</ItemGroup>\n') self.filters_file.write('\t</ItemGroup>\n') - + # add the SConscript file outside of the groups self.file.write('\t<ItemGroup>\n' '\t\t<None Include="%s" />\n' @@ -1354,7 +1354,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): self.PrintHeader() self.PrintProject() self.file.close() - + _GenerateV10User.Build(self) class _DSWGenerator(object): @@ -1462,7 +1462,7 @@ class _GenerateV7DSW(_DSWGenerator): 'SLN_RELATIVE_FOLDER_PATH': dsp_relative_folder_path, 'SLN_RELATIVE_FILE_PATH': dsp_relative_file_path} self.dspfiles_info.append(dspfile_info) - + self.dspfiles_info = [] GenerateProjectFilesInfo(self) @@ -1508,7 +1508,7 @@ class _GenerateV7DSW(_DSWGenerator): self.file.write('# Visual Studio 2008\n') elif self.version_num >= 8.0: self.file.write('# Visual Studio 2005\n') - + for dspinfo in self.dspfiles_info: name = dspinfo['NAME'] base, suffix = SCons.Util.splitext(name) @@ -1970,7 +1970,7 @@ def generate(env): else: env['MSVS']['PROJECTSUFFIX'] = '.vcxproj' env['MSVS']['SOLUTIONSUFFIX'] = '.sln' - + if (version_num >= 10.0): env['MSVSENCODING'] = 'utf-8' else: diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index 9d1965d..fa86174 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -7,6 +7,7 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ +from __future__ import print_function # # __COPYRIGHT__ @@ -144,10 +145,10 @@ def _get_swig_version(env, swig): out = pipe.stdout.read() match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: - if verbose: print "Version is:%s"%match.group(1) + if verbose: print("Version is:%s"%match.group(1)) return match.group(1) else: - if verbose: print "Unable to detect version: [%s]"%out + if verbose: print("Unable to detect version: [%s]"%out) def generate(env): """Add Builders and construction variables for swig to an Environment.""" |