Port SCons scripts to py3k (xantares/py3k PR)
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7124 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
2b18e58040
commit
d8eb1c60bb
4 changed files with 25 additions and 26 deletions
|
@ -50,8 +50,8 @@ chapters = 5
|
|||
appendices = 9
|
||||
|
||||
htmls = Split('IndexPage.html Contents.html') \
|
||||
+ map(lambda ch: 'Chapter' + str(ch + 1) + '.html', range(chapters)) \
|
||||
+ map(lambda ap: 'Appendix' + chr(ord('A') + ap) + '.html', range(appendices))
|
||||
+ list(map(lambda ch: 'Chapter' + str(ch + 1) + '.html', range(chapters))) \
|
||||
+ list(map(lambda ap: 'Appendix' + chr(ord('A') + ap) + '.html', range(appendices)))
|
||||
|
||||
docsdefault_install_basepath = 'Docs'
|
||||
|
||||
|
@ -137,7 +137,7 @@ def docs_fixer(target, source, env):
|
|||
data = open(html.path,'rb').read()
|
||||
|
||||
for pat, repl in fixes.items():
|
||||
data = re.sub(env.subst(pat), env.subst(repl), data)
|
||||
data = re.sub(env.subst(pat).encode(), env.subst(repl).encode(), data)
|
||||
|
||||
open(html.path, 'wb').write(data)
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ def shlib_emitter(target, source, env):
|
|||
no_import_lib = env.get('no_import_lib', 0)
|
||||
|
||||
if not dll:
|
||||
raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
|
||||
raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX"))
|
||||
|
||||
if not no_import_lib and \
|
||||
not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
|
||||
|
@ -149,9 +149,9 @@ def generate(env):
|
|||
if not path:
|
||||
path = []
|
||||
if SCons.Util.is_String(path):
|
||||
path = string.split(path, os.pathsep)
|
||||
path = str.split(path, os.pathsep)
|
||||
|
||||
env['ENV']['PATH'] = string.join([dir] + path, os.pathsep)
|
||||
env['ENV']['PATH'] = str.join(os.pathsep, [dir] + path)
|
||||
|
||||
# Most of mingw is the same as gcc and friends...
|
||||
gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas']
|
||||
|
|
|
@ -123,11 +123,11 @@ def GetOptionOrEnv(name, defval = None):
|
|||
Get option set on scons command line or in os.environ
|
||||
"""
|
||||
import os
|
||||
#if optenv and optenv.has_key(name):
|
||||
#if optenv and name in optenv:
|
||||
# return optenv[name]
|
||||
if ARGUMENTS.has_key(name):
|
||||
if name in ARGUMENTS:
|
||||
return ARGUMENTS[name]
|
||||
if os.environ.has_key(name):
|
||||
if name in os.environ:
|
||||
return os.environ[name]
|
||||
return defval
|
||||
|
||||
|
|
33
SConstruct
33
SConstruct
|
@ -1,4 +1,5 @@
|
|||
EnsureSConsVersion(1,2)
|
||||
EnsurePythonVersion(2,7)
|
||||
|
||||
stubs = [
|
||||
'bzip2',
|
||||
|
@ -253,14 +254,14 @@ f = open(defenv.File('#$BUILD_CONFIG/nsis-version.h').abspath, 'w')
|
|||
f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n')
|
||||
f.write('#include "%s"\n' % File('#/Source/tchar.h').abspath)
|
||||
|
||||
if (not defenv.has_key('VER_PACKED')) and defenv.has_key('VER_MAJOR') and defenv.has_key('VER_MINOR'):
|
||||
if (not 'VER_PACKED' in defenv) and 'VER_MAJOR' in defenv and 'VER_MINOR' in defenv:
|
||||
packed_r = int(defenv.get('VER_REVISION','0'))
|
||||
packed_b = int(defenv.get('VER_BUILD','0'))
|
||||
defenv['VER_PACKED'] = '0x%0.2i%0.3i%0.2i%0.1i' % (int(defenv['VER_MAJOR']), int(defenv['VER_MINOR']), packed_r, packed_b)
|
||||
if not defenv.has_key('VER_PACKED'):
|
||||
if not 'VER_PACKED' in defenv:
|
||||
import re
|
||||
found = None
|
||||
for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents()): # Try to parse the Halibut history file
|
||||
for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents().decode()): # Try to parse the Halibut history file
|
||||
if v and not found:
|
||||
v = v.group(1).split('.')
|
||||
if len(v) >= 2:
|
||||
|
@ -277,11 +278,11 @@ if int(defenv['VER_PACKED'], 0) < int('0x03000000', 0) or int(defenv['VER_PACKED
|
|||
Exit(1)
|
||||
f.write('#define NSIS_PACKEDVERSION _T("%s")\n' % defenv['VER_PACKED'])
|
||||
|
||||
if defenv.has_key('VER_MAJOR') and defenv.get('VERSION','') == '':
|
||||
if 'VER_MAJOR' in defenv and defenv.get('VERSION','') == '':
|
||||
defenv['VERSION'] = defenv['VER_MAJOR']
|
||||
if defenv.has_key('VER_MINOR'):
|
||||
if 'VER_MINOR' in defenv:
|
||||
defenv['VERSION'] += '.' + defenv['VER_MINOR']
|
||||
if defenv.has_key('VER_REVISION'):
|
||||
if 'VER_REVISION' in defenv:
|
||||
defenv['VERSION'] += '.' + defenv['VER_REVISION']
|
||||
f.write('#define NSIS_VERSION _T("v%s")\n' % defenv['VERSION'])
|
||||
|
||||
|
@ -292,7 +293,7 @@ f.close()
|
|||
######################################################################
|
||||
|
||||
def GetArcCPU(env):
|
||||
if (not env.has_key('TARGET_ARCH')) or env['TARGET_ARCH'] == 'x86':
|
||||
if (not 'TARGET_ARCH' in env) or env['TARGET_ARCH'] == 'x86':
|
||||
return 'x86'
|
||||
return env['TARGET_ARCH']
|
||||
|
||||
|
@ -355,7 +356,7 @@ defenv['DISTSUFFIX'] = ''
|
|||
|
||||
if GetArcCPU(defenv) != 'x86':
|
||||
defenv['DISTSUFFIX'] += GetArcCPU(defenv)
|
||||
if defenv.has_key('CODESIGNER'):
|
||||
if 'CODESIGNER' in defenv:
|
||||
defenv['DISTSUFFIX'] += '-signed'
|
||||
|
||||
defenv.Execute(Delete('$ZIPDISTDIR'))
|
||||
|
@ -363,21 +364,19 @@ defenv.Execute(Delete('$INSTDISTDIR'))
|
|||
defenv.Execute(Delete('$TESTDISTDIR'))
|
||||
|
||||
def Distribute(files, names, component, path, subpath, alias, install_alias=None):
|
||||
from types import StringType
|
||||
|
||||
files = MakeFileList(files)
|
||||
|
||||
names = names or map(lambda x: x.name, files)
|
||||
if isinstance(names, StringType):
|
||||
if isinstance(names, str):
|
||||
names = [names]
|
||||
|
||||
for d in ('$ZIPDISTDIR', '$INSTDISTDIR', '$TESTDISTDIR'):
|
||||
paths = map(lambda file: os.path.join(d, path, subpath, file), names)
|
||||
paths = list(map(lambda file: os.path.join(d, path, subpath, file), names))
|
||||
defenv.InstallAs(paths, files)
|
||||
|
||||
if (defenv.has_key('PREFIX') and defenv['PREFIX']) or (defenv.has_key('PREFIX_DEST') and defenv['PREFIX_DEST']) :
|
||||
if ('PREFIX' in defenv and defenv['PREFIX']) or ('PREFIX_DEST' in defenv and defenv['PREFIX_DEST']) :
|
||||
prefix = '${PREFIX_DEST}${PREFIX_%s}' % component.upper()
|
||||
paths = map(lambda file: os.path.join(prefix, path, subpath, file), names)
|
||||
paths = list(map(lambda file: os.path.join(prefix, path, subpath, file), names))
|
||||
ins = defenv.InstallAs(paths, files)
|
||||
else:
|
||||
ins = []
|
||||
|
@ -434,7 +433,7 @@ def FindMakeNSIS(env, path):
|
|||
return exename
|
||||
|
||||
def Sign(targets):
|
||||
if defenv.has_key('CODESIGNER'):
|
||||
if 'CODESIGNER' in defenv:
|
||||
for t in targets:
|
||||
a = defenv.Action('$CODESIGNER "%s"' % t.path)
|
||||
defenv.AddPostAction(t, a)
|
||||
|
@ -571,8 +570,8 @@ else:
|
|||
optchar = '-'
|
||||
|
||||
defenv['INSTVER'] = '%sDVERSION=$VERSION' % optchar
|
||||
if defenv.has_key('VER_MAJOR') and defenv.has_key('VER_MINOR') \
|
||||
and defenv.has_key('VER_REVISION') and defenv.has_key('VER_BUILD'):
|
||||
if 'VER_MAJOR' in defenv and 'VER_MINOR' in defenv \
|
||||
and 'VER_REVISION' in defenv and 'VER_BUILD' in defenv:
|
||||
defenv['INSTVER'] += ' %sDVER_MAJOR=$VER_MAJOR' % optchar
|
||||
defenv['INSTVER'] += ' %sDVER_MINOR=$VER_MINOR' % optchar
|
||||
defenv['INSTVER'] += ' %sDVER_REVISION=$VER_REVISION' % optchar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue