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
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