From c8884e0988df4e3c854da90bc5d12dba4af677c6 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 15 Nov 2008 21:54:24 +0000 Subject: [PATCH] scons 1.1.0 support git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5767 212acab6-be3b-0410-9dea-997c60f758d6 --- SCons/Config/gnu | 56 +- SCons/Config/hpc++ | 20 +- SCons/Config/ms | 54 +- SCons/utils.py | 8 +- SConstruct | 1426 ++++++++++++++++++++++---------------------- 5 files changed, 782 insertions(+), 782 deletions(-) diff --git a/SCons/Config/gnu b/SCons/Config/gnu index 09ee6f79..a298fb0c 100644 --- a/SCons/Config/gnu +++ b/SCons/Config/gnu @@ -62,27 +62,27 @@ stub_env = defenv.Clone() cross_env(stub_env) if not defenv['DEBUG']: - stub_env.Append(CCFLAGS = '-Os') # optimize for size -stub_env.Append(CCFLAGS = '-Wall') # all warnings -stub_env.Append(CCFLAGS = '-x c') # force compile as c -stub_env.Append(CCFLAGS = '-fno-strict-aliasing') # not safe for strict aliasing + stub_env.Append(CCFLAGS = ['-Os']) # optimize for size +stub_env.Append(CCFLAGS = ['-Wall']) # all warnings +stub_env.Append(CCFLAGS = ['-x c']) # force compile as c +stub_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']: - stub_env.Append(LINKFLAGS = '-s') # strip -stub_env.Append(LINKFLAGS = '-mwindows') # build windows executables -stub_env.Append(LINKFLAGS = '$NODEFLIBS_FLAG') # no standard libraries -stub_env.Append(LINKFLAGS = '$ALIGN_FLAG') # 512 bytes align -stub_env.Append(LINKFLAGS = '-Wl,-e,_WinMain@16') # entry point -stub_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file + stub_env.Append(LINKFLAGS = ['-s']) # strip +stub_env.Append(LINKFLAGS = ['-mwindows']) # build windows executables +stub_env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) # no standard libraries +stub_env.Append(LINKFLAGS = ['$ALIGN_FLAG']) # 512 bytes align +stub_env.Append(LINKFLAGS = ['-Wl,-e,_WinMain@16']) # entry point +stub_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file ### makensis environment makensis_env = defenv.Clone() if not defenv['DEBUG']: - makensis_env.Append(CCFLAGS = '-O2') # optimize -makensis_env.Append(CCFLAGS = '-Wall') # all warnings -makensis_env.Append(CXXFLAGS = '-Wno-non-virtual-dtor') # ignore virtual dtor warnings + makensis_env.Append(CCFLAGS = ['-O2']) # optimize +makensis_env.Append(CCFLAGS = ['-Wall']) # all warnings +makensis_env.Append(CXXFLAGS = ['-Wno-non-virtual-dtor']) # ignore virtual dtor warnings conf = FlagsConfigure(makensis_env) conf.CheckCompileFlag('-m32') # @@ -98,24 +98,24 @@ plugin_env = defenv.Clone() cross_env(plugin_env) if not defenv['DEBUG']: - plugin_env.Append(CCFLAGS = '-Os') # optimize for size -plugin_env.Append(CCFLAGS = '-Wall') # level 3 warnings -plugin_env.Append(CCFLAGS = '-fno-strict-aliasing') # not safe for strict aliasing + plugin_env.Append(CCFLAGS = ['-Os']) # optimize for size +plugin_env.Append(CCFLAGS = ['-Wall']) # level 3 warnings +plugin_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']: - plugin_env.Append(LINKFLAGS = '-s') # strip -plugin_env.Append(LINKFLAGS = '-mwindows') # build windows executables -plugin_env.Append(LINKFLAGS = '$ALIGN_FLAG') # 512 bytes align -plugin_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file + plugin_env.Append(LINKFLAGS = ['-s']) # strip +plugin_env.Append(LINKFLAGS = ['-mwindows']) # build windows executables +plugin_env.Append(LINKFLAGS = ['$ALIGN_FLAG']) # 512 bytes align +plugin_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file ### cross-platform util environment cp_util_env = defenv.Clone() if not defenv['DEBUG']: - cp_util_env.Append(CCFLAGS = '-O2') # optimize -cp_util_env.Append(CCFLAGS = '-Wall') # all warnings -cp_util_env.Append(CCFLAGS = '-fno-strict-aliasing') # not safe for strict aliasing + cp_util_env.Append(CCFLAGS = ['-O2']) # optimize +cp_util_env.Append(CCFLAGS = ['-Wall']) # all warnings +cp_util_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing conf = FlagsConfigure(cp_util_env) conf.CheckLinkFlag('$MAP_FLAG') # generate map file @@ -126,12 +126,12 @@ conf.Finish() util_env = cp_util_env.Clone() cross_env(util_env) -util_env.Append(LINKFLAGS = '-mwindows') # build windows executables -util_env.Append(LINKFLAGS = '$ALIGN_FLAG') # 512 bytes align +util_env.Append(LINKFLAGS = ['-mwindows']) # build windows executables +util_env.Append(LINKFLAGS = ['$ALIGN_FLAG']) # 512 bytes align conf = FlagsConfigure(util_env) if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']: - util_env.Append(LINKFLAGS = '-s') # strip + util_env.Append(LINKFLAGS = ['-s']) # strip conf.Finish() ### cross-platform util environment adjustments @@ -177,8 +177,8 @@ def check_requirement(ctx, func, trigger): flags = ctx.env['LINKFLAGS'] - ctx.env.Append(LINKFLAGS = '$NODEFLIBS_FLAG') - ctx.env.Append(LINKFLAGS = '-Wl,-e,___main') + ctx.env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) + ctx.env.Append(LINKFLAGS = ['-Wl,-e,___main']) test = """ int __main() { diff --git a/SCons/Config/hpc++ b/SCons/Config/hpc++ index 22d915fa..04214810 100644 --- a/SCons/Config/hpc++ +++ b/SCons/Config/hpc++ @@ -25,28 +25,28 @@ makensis_env = defenv.Clone() ### use "$CXX -Ae" as the "$CC" compiler to build makensis makensis_env['CC'] = makensis_env['CXX'] -makensis_env.Append(CFLAGS = '-Ae') +makensis_env.Append(CFLAGS = ['-Ae']) ### required to build makensis -makensis_env.Append(LINKFLAGS = '-AA') -makensis_env.Append(LINKFLAGS = '+DD32') -makensis_env.Append(LINKFLAGS = '-mt') +makensis_env.Append(LINKFLAGS = ['-AA']) +makensis_env.Append(LINKFLAGS = ['+DD32']) +makensis_env.Append(LINKFLAGS = ['-mt']) -makensis_env.Append(CXXFLAGS = '-AA') -makensis_env.Append(CCFLAGS = '+DD32') -makensis_env.Append(CCFLAGS = '-mt') +makensis_env.Append(CXXFLAGS = ['-AA']) +makensis_env.Append(CCFLAGS = ['+DD32']) +makensis_env.Append(CCFLAGS = ['-mt']) ### debug for makensis if makensis_env['DEBUG']: - makensis_env.Append(CCFLAGS = '-g') - makensis_env.Append(LINKFLAGS = '-g') + makensis_env.Append(CCFLAGS = ['-g']) + makensis_env.Append(LINKFLAGS = ['-g']) ### strip for makensis if not makensis_env['DEBUG'] and makensis_env['STRIP']: - makensis_env.Append(LINKFLAGS = '-s') + makensis_env.Append(LINKFLAGS = ['-s']) # # aCC defines _BIG_ENDIAN, but we use __BIG_ENDIAN__ so check and define as diff --git a/SCons/Config/ms b/SCons/Config/ms index 1b9a41da..8d9d027c 100644 --- a/SCons/Config/ms +++ b/SCons/Config/ms @@ -15,7 +15,7 @@ defenv['MSVCRT_FLAG'] = '/MD' if float(defenv['MSVS_VERSION'].replace('Exp','')) >= 8.0: defenv['EXCEPTION_FLAG'] = '/EHsc' - defenv.Append(CCFLAGS = '/GS-') + defenv.Append(CCFLAGS = ['/GS-']) defenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS', '_CRT_NONSTDC_NO_WARNINGS']) else: defenv['EXCEPTION_FLAG'] = '/GX' @@ -23,9 +23,9 @@ else: ### debug if defenv['DEBUG']: - defenv.Append(CCFLAGS = '/Zi') - defenv.Append(CCFLAGS = '/Fd${TARGET.dir}\\${TARGET.dir.file}.pdb') - defenv.Append(LINKFLAGS = '/debug') + defenv.Append(CCFLAGS = ['/Zi']) + defenv.Append(CCFLAGS = ['/Fd${TARGET.dir}\\${TARGET.dir.file}.pdb']) + defenv.Append(LINKFLAGS = ['/debug']) ### workarounds @@ -73,49 +73,49 @@ conf.Finish() stub_env = defenv.Clone() if not defenv['DEBUG']: - stub_env.Append(CCFLAGS = '/O1') # optimize for size -stub_env.Append(CCFLAGS = '/W3') # level 3 warnings + stub_env.Append(CCFLAGS = ['/O1']) # optimize for size +stub_env.Append(CCFLAGS = ['/W3']) # level 3 warnings -stub_env.Append(LINKFLAGS = '/opt:nowin98') # 512 bytes align -stub_env.Append(LINKFLAGS = '/entry:WinMain') # entry point -stub_env.Append(LINKFLAGS = '$NODEFLIBS_FLAG') # no default libraries -stub_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file -stub_env.Append(CCFLAGS = '/FAcs') # full listing files -stub_env.Append(CCFLAGS = '/Fa${TARGET}.lst') # listing file name +stub_env.Append(LINKFLAGS = ['/opt:nowin98']) # 512 bytes align +stub_env.Append(LINKFLAGS = ['/entry:WinMain']) # entry point +stub_env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) # no default libraries +stub_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file +stub_env.Append(CCFLAGS = ['/FAcs']) # full listing files +stub_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name ### makensis environment makensis_env = defenv.Clone() if not defenv['DEBUG']: - makensis_env.Append(CCFLAGS = '/O2') # optimize for speed -makensis_env.Append(CCFLAGS = '$EXCEPTION_FLAG') # enable exceptions -makensis_env.Append(CCFLAGS = '/W3') # level 3 warnings + makensis_env.Append(CCFLAGS = ['/O2']) # optimize for speed +makensis_env.Append(CCFLAGS = ['$EXCEPTION_FLAG']) # enable exceptions +makensis_env.Append(CCFLAGS = ['/W3']) # level 3 warnings -makensis_env.Append(LINKFLAGS = '/opt:nowin98') # 512 bytes align -makensis_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file +makensis_env.Append(LINKFLAGS = ['/opt:nowin98']) # 512 bytes align +makensis_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file ### plugin environment plugin_env = defenv.Clone(no_import_lib = 1) if not defenv['DEBUG']: - plugin_env.Append(CCFLAGS = '/O1') # optimize for size -plugin_env.Append(CCFLAGS = '/W3') # level 3 warnings + plugin_env.Append(CCFLAGS = ['/O1']) # optimize for size +plugin_env.Append(CCFLAGS = ['/W3']) # level 3 warnings -plugin_env.Append(LINKFLAGS = '/opt:nowin98') # 512 bytes align -plugin_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file +plugin_env.Append(LINKFLAGS = ['/opt:nowin98']) # 512 bytes align +plugin_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file ### util environment util_env = defenv.Clone() if not defenv['DEBUG']: - util_env.Append(CCFLAGS = '/O1') # optimize for speed -util_env.Append(CCFLAGS = '/W3') # level 3 warnings + util_env.Append(CCFLAGS = ['/O1']) # optimize for speed +util_env.Append(CCFLAGS = ['/W3']) # level 3 warnings -util_env.Append(LINKFLAGS = '/opt:nowin98') # 512 bytes align -util_env.Append(LINKFLAGS = '$MAP_FLAG') # generate map file +util_env.Append(LINKFLAGS = ['/opt:nowin98']) # 512 bytes align +util_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file ### cross-platform util environment @@ -132,8 +132,8 @@ def check_requirement(ctx, func, trigger): flags = ctx.env['LINKFLAGS'] - ctx.env.Append(LINKFLAGS = '$NODEFLIBS_FLAG') - ctx.env.Append(LINKFLAGS = '${ENTRY_FLAG("main")}') + ctx.env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) + ctx.env.Append(LINKFLAGS = ['/entry:main']) test = """ int main() { diff --git a/SCons/utils.py b/SCons/utils.py index feee7ec1..0b35807f 100644 --- a/SCons/utils.py +++ b/SCons/utils.py @@ -17,7 +17,7 @@ def check_compile_flag(ctx, flag): ctx.Message('Checking for compiler flag %s... ' % flag) old_flags = ctx.env['CCFLAGS'] - ctx.env.Append(CCFLAGS = flag) + ctx.env.Append(CCFLAGS = [flag]) test = """ int main() { @@ -29,7 +29,7 @@ def check_compile_flag(ctx, flag): ctx.Result(result) if not result: - ctx.env.Replace(CCFLAGS = old_flags) + ctx.env.Replace(CCFLAGS = [old_flags]) return result @@ -40,7 +40,7 @@ def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None): ctx.Message('Checking for linker flag %s... ' % flag) old_flags = ctx.env['LINKFLAGS'] - ctx.env.Append(LINKFLAGS = flag) + ctx.env.Append(LINKFLAGS = [flag]) if code: test = code @@ -59,7 +59,7 @@ def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None): ctx.Result(result) if not result: - ctx.env.Replace(LINKFLAGS = old_flags) + ctx.env.Replace(LINKFLAGS = [old_flags]) return result diff --git a/SConstruct b/SConstruct index 2bd87089..ec66ceea 100644 --- a/SConstruct +++ b/SConstruct @@ -1,132 +1,132 @@ -EnsureSConsVersion(0,98) - -stubs = [ - 'bzip2', - 'lzma', - 'zlib' -] - -plugins = [ - 'AdvSplash', - 'Banner', - 'BgImage', - 'Dialer', - 'InstallOptions', - 'LangDLL', - 'Library/TypeLib', - 'Math', - 'nsDialogs', - 'nsExec', - 'NSISdl', - 'Splash', - 'StartMenu', - 'System', - 'UserInfo', - 'VPatch/Source/Plugin' -] - -utils = [ - 'Library/LibraryLocal', - 'Library/RegTool', - 'MakeLangId', - 'Makensisw', - 'NSIS Menu', - 'UIs', - 'VPatch/Source/GenPat', - 'zip2exe' -] - -misc = [ - 'Graphics', - 'Language files', - 'MultiUser', - 'Modern UI', - 'Modern UI 2', - 'VPatch', - 'ExDLL' -] - -doc = [ - 'COPYING' -] - -###################################################################### -####### Build Environment ### -###################################################################### - -path = ARGUMENTS.get('PATH', '') -toolset = ARGUMENTS.get('TOOLSET', '') - -if toolset and path: - defenv = Environment(ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip']) -else: - if path: - defenv = Environment(ENV = {'PATH' : path}) - if toolset: - defenv = Environment(TOOLS = toolset.split(',') + ['zip']) -if not toolset and not path: - defenv = Environment() - -Export('defenv') - -###################################################################### -####### Includes ### -###################################################################### - -SConscript('SCons/utils.py') - -###################################################################### -####### Options ### -###################################################################### - -import os -hhc = 'no' -if defenv.WhereIs('hhc', os.environ['PATH']): - hhc = 'yes' - -from time import strftime, gmtime -cvs_version = strftime('%d-%b-%Y.cvs', gmtime()) - -opts = Options() - -# load configuration options -# it's important this will be done here so NSIS_CONFIG_CONST_DATA_PATH -# will be available for the next few lines and so `dirs` can be set -SConscript('SCons/config.py') - -opts.Update(defenv) -Help(opts.GenerateHelpText(defenv)) - -install_dirs = { - 'relocatable': { - 'dest': '', - 'prefix': '', - 'conf': '$PREFIX', - 'bin': '$PREFIX', - 'data': '$PREFIX', - 'doc': '$PREFIX', - 'inc_c': '$PREFIX', - }, - 'static': { - 'dest': '', - 'prefix': '/usr/local', - 'conf': '$PREFIX/etc', - 'bin': '$PREFIX/bin', - 'data': '$PREFIX/share/nsis', - 'doc': '$PREFIX/share/doc/nsis', - 'inc_c': '$PREFIX/include/nsis', - } -} - -if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: - dirs = install_dirs['static'] -else: - dirs = install_dirs['relocatable'] - -if 'msvc' in defenv['TOOLS'] or 'mstoolkit' in defenv['TOOLS']: - ignore_tests = 'none' -else: - ignore_tests = ','.join(Split(""" +EnsureSConsVersion(0,98) + +stubs = [ + 'bzip2', + 'lzma', + 'zlib' +] + +plugins = [ + 'AdvSplash', + 'Banner', + 'BgImage', + 'Dialer', + 'InstallOptions', + 'LangDLL', + 'Library/TypeLib', + 'Math', + 'nsDialogs', + 'nsExec', + 'NSISdl', + 'Splash', + 'StartMenu', + 'System', + 'UserInfo', + 'VPatch/Source/Plugin' +] + +utils = [ + 'Library/LibraryLocal', + 'Library/RegTool', + 'MakeLangId', + 'Makensisw', + 'NSIS Menu', + 'UIs', + 'VPatch/Source/GenPat', + 'zip2exe' +] + +misc = [ + 'Graphics', + 'Language files', + 'MultiUser', + 'Modern UI', + 'Modern UI 2', + 'VPatch', + 'ExDLL' +] + +doc = [ + 'COPYING' +] + +###################################################################### +####### Build Environment ### +###################################################################### + +path = ARGUMENTS.get('PATH', '') +toolset = ARGUMENTS.get('TOOLSET', '') + +if toolset and path: + defenv = Environment(ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip']) +else: + if path: + defenv = Environment(ENV = {'PATH' : path}) + if toolset: + defenv = Environment(TOOLS = toolset.split(',') + ['zip']) +if not toolset and not path: + defenv = Environment() + +Export('defenv') + +###################################################################### +####### Includes ### +###################################################################### + +SConscript('SCons/utils.py') + +###################################################################### +####### Options ### +###################################################################### + +import os +hhc = 'no' +if defenv.WhereIs('hhc', os.environ['PATH']): + hhc = 'yes' + +from time import strftime, gmtime +cvs_version = strftime('%d-%b-%Y.cvs', gmtime()) + +opts = Options() + +# load configuration options +# it's important this will be done here so NSIS_CONFIG_CONST_DATA_PATH +# will be available for the next few lines and so `dirs` can be set +SConscript('SCons/config.py') + +opts.Update(defenv) +Help(opts.GenerateHelpText(defenv)) + +install_dirs = { + 'relocatable': { + 'dest': '', + 'prefix': '', + 'conf': '$PREFIX', + 'bin': '$PREFIX', + 'data': '$PREFIX', + 'doc': '$PREFIX', + 'inc_c': '$PREFIX', + }, + 'static': { + 'dest': '', + 'prefix': '/usr/local', + 'conf': '$PREFIX/etc', + 'bin': '$PREFIX/bin', + 'data': '$PREFIX/share/nsis', + 'doc': '$PREFIX/share/doc/nsis', + 'inc_c': '$PREFIX/include/nsis', + } +} + +if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: + dirs = install_dirs['static'] +else: + dirs = install_dirs['relocatable'] + +if 'msvc' in defenv['TOOLS'] or 'mstoolkit' in defenv['TOOLS']: + ignore_tests = 'none' +else: + ignore_tests = ','.join(Split(""" Examples/LogicLib.nsi Examples/StrFunc.nsi Examples/TextFunc.nsi @@ -134,593 +134,593 @@ Examples/TextFuncTest.nsi Examples/FileFunc.nsi Examples/FileFuncTest.nsi Examples/Library.nsi -Examples/makensis.nsi +Examples/makensis.nsi Examples/gfx.nsi Examples/System/System.nsi Examples/nsDialogs/example.nsi Examples/nsDialogs/InstallOptions.nsi Examples/nsDialogs/welcome.nsi""") + ['Examples/Modern UI/WelcomeFinish.nsi']) - -# version -opts.Add(('VERSION', 'Version of NSIS', cvs_version)) -opts.Add(('VER_MAJOR', 'Major version of NSIS (recommended for dist-installer)', None)) -opts.Add(('VER_MINOR', 'Minor version of NSIS (recommended for dist-installer)', None)) -opts.Add(('VER_REVISION', 'Revision of NSIS (recommended for dist-installer)', None)) -opts.Add(('VER_BUILD', 'Build version of NSIS (recommended for dist-installer)', None)) -# installation -opts.Add(('PREFIX', 'Installation prefix', dirs['prefix'])) -opts.Add(ListOption('SKIPSTUBS', 'A list of stubs that will not be built', 'none', stubs)) -opts.Add(ListOption('SKIPPLUGINS', 'A list of plug-ins that will not be built', 'none', plugins)) -opts.Add(ListOption('SKIPUTILS', 'A list of utilities that will not be built', 'none', utils)) -opts.Add(ListOption('SKIPMISC', 'A list of plug-ins that will not be built', 'none', misc)) -opts.Add(ListOption('SKIPDOC', 'A list of doc files that will not be built/installed', 'none', doc)) -opts.Add(('SKIPTESTS', 'A comma-separated list of test files that will not be ran', 'none')) -opts.Add(('IGNORETESTS', 'A comma-separated list of test files that will be ran but ignored', ignore_tests)) -# build tools -opts.Add(('PATH', 'A colon-separated list of system paths instead of the default - TEMPORARY AND MAY DEPRECATE', None)) -opts.Add(('TOOLSET', 'A comma-separated list of specific tools used for building instead of the default', None)) -opts.Add(BoolOption('MSTOOLKIT', 'Use Microsoft Visual C++ Toolkit', 'no')) -opts.Add(BoolOption('CHMDOCS', 'Build CHM documentation, requires hhc.exe', hhc)) -opts.Add(PathOption('APPEND_CPPPATH', 'Additional paths to search for include files', None)) -opts.Add(PathOption('APPEND_LIBPATH', 'Additional paths to search for libraries', None)) -opts.Add(('APPEND_CCFLAGS', 'Additional C/C++ compiler flags')) -opts.Add(('APPEND_LINKFLAGS', 'Additional linker flags')) -# build options -opts.Add(BoolOption('DEBUG', 'Build executables with debugging information', 'no')) -opts.Add(PathOption('CODESIGNER', 'A program used to sign executables', None)) -opts.Add(BoolOption('STRIP', 'Strips executables of any unrequired data such as symbols', 'yes')) -opts.Add(BoolOption('STRIP_CP', 'Strips cross-platform executables of any unrequired data such as symbols', 'yes')) -opts.Add(BoolOption('STRIP_W32', 'Strips Win32 executables of any unrequired data such as symbols', 'yes')) -# path related build options -opts.Add(('PREFIX_DEST', 'Intermediate installation prefix (extra install time prefix)', dirs['dest'])) -opts.Add(('PREFIX_CONF', 'Path to install nsisconf.nsh to', dirs['conf'])) -opts.Add(('PREFIX_BIN', 'Path to install native binaries to', dirs['bin'])) -opts.Add(('PREFIX_DATA', 'Path to install nsis data to (plugins, includes, stubs, contrib, win32 binaries)', dirs['data'])) -opts.Add(('PREFIX_DOC','Path to install nsis README / INSTALL / TODO files to.', dirs['doc'])) -opts.Add(('PREFIX_INC_C','Path to install nsis C header files to.', dirs['inc_c'])) - -opts.Update(defenv) -Help(opts.GenerateHelpText(defenv)) - -# add prefixes defines -if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: - defenv.Append(NSIS_CPPDEFINES = [('PREFIX_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))]) - defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DATA', '"%s"' % defenv.subst('$PREFIX_DATA'))]) - -# write configuration into sconf.h and defines.h -sconf_h = open(File('#Source/exehead/sconf.h').abspath, 'w') -sconf_h.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') - -defines_h = open(File('#Source/defines.h').abspath, 'w') -defines_h.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') - -for i in defenv['NSIS_CPPDEFINES']: - if type(i) is not str: - sconf_h.write('#define %s %s\n' % (i[0], i[1])) - if str(i[1])[0] != '"': - defines_h.write('definedlist.add("%s", "%s");\n' % (i[0], i[1])) - else: - defines_h.write('definedlist.add("%s", %s);\n' % (i[0], i[1])) - else: - sconf_h.write('#define %s\n' % (i)) - defines_h.write('definedlist.add("%s");\n' % (i)) -sconf_h.close() -defines_h.close() - -# write version into version.h -f = open(File('#Source/version.h').abspath, 'w') -f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') -f.write('#define NSIS_VERSION "v%s"\n' % defenv['VERSION']) -f.close() - -###################################################################### -####### Functions ### -###################################################################### - -defenv['ZIPDISTDIR'] = defenv.Dir('#nsis-$VERSION') -defenv['INSTDISTDIR'] = defenv.Dir('#.instdist') -defenv['TESTDISTDIR'] = defenv.Dir('#.test') -defenv['DISTSUFFIX'] = '' - -if defenv.has_key('CODESIGNER'): - defenv['DISTSUFFIX'] = '-signed' - -defenv.Execute(Delete('$ZIPDISTDIR')) -defenv.Execute(Delete('$INSTDISTDIR')) -defenv.Execute(Delete('$TESTDISTDIR')) - -def SafeFile(f): - from types import StringType - - if isinstance(f, StringType): - return File(f) - - return f - -def MakeFileList(files): - from types import ListType, TupleType - - if isinstance(files, (ListType, TupleType)): - return map(SafeFile, files) - - return Flatten([SafeFile(files)]) - -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): - names = [names] - - for d in ('$ZIPDISTDIR', '$INSTDISTDIR', '$TESTDISTDIR'): - paths = 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']) : - prefix = '${PREFIX_DEST}${PREFIX_%s}' % component.upper() - paths = map(lambda file: os.path.join(prefix, path, subpath, file), names) - ins = defenv.InstallAs(paths, files) - else: - ins = [] - - if ins: - defenv.Alias('install', ins) - defenv.Alias('install-%s' % component, ins) - if alias: - defenv.Alias(alias, ins) - if install_alias: - defenv.Alias('install-%s' % install_alias, ins) - - return ins - -def DistributeBin(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'bin', '', path, alias) - -def DistributeConf(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'conf', '', path, alias) - -def DistributeW32Bin(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'data', 'Bin', path, alias, 'w32bin') - -def DistributeStubs(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'data', 'Stubs', path, alias, 'stubs') - -def DistributePlugin(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'data', 'Plugins', path, alias, 'plugins') - -def DistributeContrib(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'data', 'Contrib', path, alias, 'contrib') - -def DistributeMenu(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'data', 'Menu', path, alias, 'menu') - -def DistributeInclude(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'data', 'Include', path, alias, 'includes') - -def DistributeDoc(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'doc', '', path, alias) - -def DistributeDocs(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'doc', 'Docs', path, alias, 'docs') - -def DistributeExamples(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'doc', 'Examples', path, alias, 'examples') - -def DistributeIncC(files, names=[], path='', alias=None): - return defenv.Distribute(files, names, 'inc_c', '', path, alias, 'inc-c') - -def Sign(targets): - if defenv.has_key('CODESIGNER'): - for t in targets: - a = defenv.Action('$CODESIGNER "%s"' % t.path) - defenv.AddPostAction(t, a) - -def TestScript(scripts): - defenv.Install('$TESTDISTDIR/Tests', scripts) - -defenv.Distribute = Distribute -defenv.DistributeBin = DistributeBin -defenv.DistributeConf = DistributeConf -defenv.DistributeW32Bin = DistributeW32Bin -defenv.DistributeStubs = DistributeStubs -defenv.DistributePlugin = DistributePlugin -defenv.DistributeContrib = DistributeContrib -defenv.DistributeMenu = DistributeMenu -defenv.DistributeInclude = DistributeInclude -defenv.DistributeDoc = DistributeDoc -defenv.DistributeDocs = DistributeDocs -defenv.DistributeExamples = DistributeExamples -defenv.DistributeIncC = DistributeIncC -defenv.Sign = Sign -defenv.TestScript = TestScript - -###################################################################### -####### Environments ### -###################################################################### - -if defenv['DEBUG']: - defenv.Replace(BUILD_PREFIX = 'build/debug') -else: - defenv.Replace(BUILD_PREFIX = 'build/release') - -if defenv['MSTOOLKIT']: - defenv.Tool('mstoolkit', toolpath = ['SCons/Tools']) - -defenv.Append(CCFLAGS = Split('$APPEND_CCFLAGS')) -defenv.Append(LINKFLAGS = Split('$APPEND_LINKFLAGS')) -defenv.Append(CPPPATH = Split('$APPEND_CPPPATH')) -defenv.Append(LIBPATH = Split('$APPEND_LIBPATH')) - -defenv.Default('$BUILD_PREFIX') - -tools = defenv['TOOLS'] - -envs = [] - -if 'msvc' in tools or 'mstoolkit' in tools: - envs = SConscript('SCons/Config/ms') -elif 'gcc' in tools: - envs = SConscript('SCons/Config/gnu') -elif 'hpc++' in tools: - envs = SConscript('SCons/Config/hpc++') -else: - envs = SConscript('SCons/Config/default') - -stub_env = envs[0] -makensis_env = envs[1] -plugin_env = envs[2] -util_env = envs[3] -cp_util_env = envs[4] -test_env = envs[5] - -###################################################################### -####### Distribution ### -###################################################################### - -dist_zip = 'nsis-${VERSION}${DISTSUFFIX}.zip' -zip_target = defenv.Zip(dist_zip, '$ZIPDISTDIR') -defenv.Alias('dist-zip', zip_target) - -AlwaysBuild(defenv.AddPostAction(zip_target, Delete('$ZIPDISTDIR'))) - -if defenv['PLATFORM'] == 'win32': - optchar = '/' -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'): - defenv['INSTVER'] += ' %sDVER_MAJOR=$VER_MAJOR' % optchar - defenv['INSTVER'] += ' %sDVER_MINOR=$VER_MINOR' % optchar - defenv['INSTVER'] += ' %sDVER_REVISION=$VER_REVISION' % optchar - defenv['INSTVER'] += ' %sDVER_BUILD=$VER_BUILD' % optchar - -inst_env = {} -inst_env['NSISDIR'] = os.path.abspath(str(defenv['INSTDISTDIR'])) -inst_env['NSISCONFDIR'] = os.path.abspath(str(defenv['INSTDISTDIR'])) - -installer_target = defenv.Command('nsis-${VERSION}-setup${DISTSUFFIX}.exe', - '$INSTDISTDIR' + os.sep + 'Examples' + os.sep + 'makensis.nsi', - '$INSTDISTDIR' + os.sep + 'makensis$PROGSUFFIX ' + - '%sDOUTFILE=$TARGET.abspath $INSTVER $SOURCE' % optchar, - ENV = inst_env) -defenv.Depends(installer_target, '$INSTDISTDIR') -defenv.Sign(installer_target) -defenv.Alias('dist-installer', installer_target) - -AlwaysBuild(defenv.AddPostAction(installer_target, Delete('$INSTDISTDIR'))) - -defenv.Alias('dist', ['dist-zip', 'dist-installer']) - -###################################################################### -####### Distribute Basics ### -###################################################################### - -for d in doc: - if d in defenv['SKIPDOC']: - continue - defenv.DistributeDoc(d) - -defenv.DistributeConf('nsisconf.nsh') - -###################################################################### -####### Stubs ### -###################################################################### - -def BuildStub(compression, solid): - env = stub_env.Clone() - - suffix = '' - if solid: - suffix = '_solid' - - build_dir = '$BUILD_PREFIX/stub_%s%s' % (compression, suffix) - - exports = { 'env' : env, 'compression' : compression, 'solid_compression' : solid } - - target = defenv.SConscript(dirs = 'Source/exehead', build_dir = build_dir, duplicate = False, exports = exports) - env.SideEffect('%s/stub_%s.map' % (build_dir, stub), target) - - env.DistributeStubs(target, names=compression+suffix) - - defenv.Alias(compression, target) - defenv.Alias('stubs', target) - -for stub in stubs: - if stub in defenv['SKIPSTUBS']: - continue - - BuildStub(stub, False) - BuildStub(stub, True) - -defenv.DistributeStubs('Source/exehead/uninst.ico',names='uninst') - -###################################################################### -####### makensis ### -###################################################################### - -build_dir = '$BUILD_PREFIX/makensis' -exports = { 'env' : makensis_env } - -makensis = defenv.SConscript(dirs = 'Source', build_dir = build_dir, duplicate = False, exports = exports) - -makensis_env.SideEffect('%s/makensis.map' % build_dir, makensis) - -defenv.Alias('makensis', makensis) - -ins = defenv.DistributeBin(makensis,alias='install-compiler') - -###################################################################### -####### Common Functions ### -###################################################################### - -def AddEnvStandardFlags(env, defines, flags, entry, nodeflib): - if defines: - env.Append(CPPDEFINES = defines) - if flags: - env.Append(CCFLAGS = flags) - - if entry: - env.Append(LINKFLAGS = '${ENTRY_FLAG("%s")}' % entry) - - if nodeflib: - env.Append(LINKFLAGS = '$NODEFLIBS_FLAG') # no default libraries - -def AppendRES(env, source, res, resources): - if res: - target = MakeFileList(res)[0].name.replace('.rc', '-rc') - target_res = env.RES(target, res) - if resources: - env.Depends(target_res, resources) - source.append(target_res) - -def CleanMap(env, target, target_name): - env.Clean(target, File(target_name + '.map')) - -def DistributeExtras(env, target, examples, docs): - if examples: - env.DistributeExamples(examples, path=target) - if docs: - env.DistributeDocs(docs, path=target) - -###################################################################### -####### Plug-ins ### -###################################################################### - -def BuildPlugin(target, source, libs, examples = None, docs = None, - entry = 'DllMain', res = None, resources = None, - defines = None, flags = None, nodeflib = True, - cppused = False): - env = plugin_env.Clone() - - if cppused and env['CPP_REQUIRES_STDLIB']: - nodeflib = False - - AddEnvStandardFlags(env, defines, flags, entry, nodeflib) - - AppendRES(env, source, res, resources) - - plugin = env.SharedLibrary(target, source, LIBS = libs) - defenv.Alias(target, plugin) - defenv.Alias('plugins', plugin) - - defenv.Sign(plugin) - - CleanMap(env, plugin, target) - - for i in plugin: - if str(i)[-4:].lower() == '.dll': - plugin = i - break - env.DistributePlugin(plugin) - - DistributeExtras(env, target, examples, docs) - -for plugin in plugins: - if plugin in defenv['SKIPPLUGINS']: - continue - - path = 'Contrib/' + plugin - build_dir = '$BUILD_PREFIX/' + plugin - exports = {'BuildPlugin' : BuildPlugin, 'env' : plugin_env.Clone()} - - defenv.SConscript(dirs = path, build_dir = build_dir, duplicate = False, exports = exports) - -###################################################################### -####### Utilities ### -###################################################################### - -def BuildUtilEnv(defines = None, flags = None, entry = None, - nodeflib = None, cross_platform = False): - if not cross_platform: - env = util_env.Clone() - else: - env = cp_util_env.Clone() - - AddEnvStandardFlags(env, defines, flags, entry, nodeflib) - - return env - -def BuildUtil(target, source, libs, entry = None, res = None, - resources = None, defines = None, flags = None, - nodeflib = False, file_name = '', path='', contrib = False, - examples = None, docs = None, cross_platform = False, - root_util = False): - env = BuildUtilEnv(defines, flags, entry, nodeflib, cross_platform) - - AppendRES(env, source, res, resources) - - if file_name != '': - target = "%s/%s" % (target, file_name) - - # make sure the environment suffix fits - if env['PROGSUFFIX'] not in target: - if '.' in target: - env['PROGSUFFIX'] = target[target.rindex('.'):] - - util = env.Program(target, source, LIBS = libs) - defenv.Alias(target, util) - defenv.Alias('utils', util) - - defenv.Sign(util) - - CleanMap(env, util, target) - - if contrib: - ins = env.DistributeContrib(util, path=path, alias='install-utils') - elif cross_platform and not env['PLATFORM'] == 'win32' or root_util and env['PLATFORM'] == 'win32': - ins = env.DistributeBin(util, path=path, alias='install-utils') - else: - ins = env.DistributeW32Bin(util, path=path, alias='install-utils') - - DistributeExtras(env, target, examples, docs) - - return util - -for util in utils: - if util in defenv['SKIPUTILS']: - continue - - path = 'Contrib/' + util - build_dir = '$BUILD_PREFIX/' + util - exports = {'BuildUtil' : BuildUtil, 'BuildUtilEnv' : BuildUtilEnv, 'env' : util_env} - - defenv.SConscript(dirs = path, build_dir = build_dir, duplicate = False, exports = exports) - -###################################################################### -####### Documentation ### -###################################################################### - -halibut = defenv.SConscript( - dirs = 'Docs/src/bin/halibut', - build_dir = '$BUILD_PREFIX/halibut', - duplicate = False, - exports = {'env' : defenv.Clone()} -) - -if defenv['CHMDOCS']: - defenv.SConscript( - dirs = 'Docs/src', - build_dir = '$BUILD_PREFIX/Docs/chm', - duplicate = False, - exports = {'halibut' : halibut, 'env' : defenv.Clone(), 'build_chm' : True} - ) -else: - defenv.SConscript( - dirs = 'Docs/src', - build_dir = '$BUILD_PREFIX/Docs/html', - duplicate = False, - exports = {'halibut' : halibut, 'env' : defenv.Clone(), 'build_chm' : False} - ) - -###################################################################### -####### Examples ### -###################################################################### - -defenv.SConscript( - dirs = 'Examples', - exports = {'env': defenv.Clone()} -) - -###################################################################### -####### Includes ### -###################################################################### - -defenv.SConscript( - dirs = 'Include', - exports = {'env': defenv.Clone()} -) - -###################################################################### -####### Miscellaneous ### -###################################################################### - -for i in misc: - if i in defenv['SKIPMISC']: - continue - - defenv.SConscript(dirs = 'Contrib/%s' % i) - -###################################################################### -####### Tests ### -###################################################################### - -# test code - -build_dir = '$BUILD_PREFIX/tests' -exports = {'env' : test_env.Clone()} - -defenv.SConscript( - dirs = 'Source/Tests', - duplicate = False, - exports = exports, - build_dir = build_dir -) - -defenv.Ignore('$BUILD_PREFIX', '$BUILD_PREFIX/tests') - -# test scripts - -test_scripts_env = defenv.Clone(ENV = os.environ) # env needed for some scripts -test_scripts_env['ENV']['NSISDIR'] = os.path.abspath(str(defenv['TESTDISTDIR'])) -test_scripts_env['ENV']['NSISCONFDIR'] = os.path.abspath(str(defenv['TESTDISTDIR'])) - -def test_scripts(target, source, env): - from os import walk, sep - - instdir = source[0].path - - makensis = instdir + sep + 'makensis' - - tdlen = len(env.subst('$TESTDISTDIR')) - skipped_tests = env['SKIPTESTS'].split(',') - ignored_tests = env['IGNORETESTS'].split(',') - - for root, dirs, files in walk(instdir): - for file in files: - if file[-4:] == '.nsi': - nsi = root + sep + file - nsif = nsi[tdlen + 1:] - - if nsif in skipped_tests: - continue - - if nsif in ignored_tests: - cmd = env.Command(None, nsi, '-%s $SOURCE' % makensis) - else: - cmd = env.Command(None, nsi, '%s $SOURCE' % makensis) - AlwaysBuild(cmd) - env.Alias('test-scripts', cmd) - - return None - -test = test_scripts_env.Command('test-scripts.log', '$TESTDISTDIR', test_scripts) -test_scripts_env.Alias('test-scripts', test) - -# test all - -defenv.Alias('test', ['test-code', 'test-scripts']) + +# version +opts.Add(('VERSION', 'Version of NSIS', cvs_version)) +opts.Add(('VER_MAJOR', 'Major version of NSIS (recommended for dist-installer)', None)) +opts.Add(('VER_MINOR', 'Minor version of NSIS (recommended for dist-installer)', None)) +opts.Add(('VER_REVISION', 'Revision of NSIS (recommended for dist-installer)', None)) +opts.Add(('VER_BUILD', 'Build version of NSIS (recommended for dist-installer)', None)) +# installation +opts.Add(('PREFIX', 'Installation prefix', dirs['prefix'])) +opts.Add(ListOption('SKIPSTUBS', 'A list of stubs that will not be built', 'none', stubs)) +opts.Add(ListOption('SKIPPLUGINS', 'A list of plug-ins that will not be built', 'none', plugins)) +opts.Add(ListOption('SKIPUTILS', 'A list of utilities that will not be built', 'none', utils)) +opts.Add(ListOption('SKIPMISC', 'A list of plug-ins that will not be built', 'none', misc)) +opts.Add(ListOption('SKIPDOC', 'A list of doc files that will not be built/installed', 'none', doc)) +opts.Add(('SKIPTESTS', 'A comma-separated list of test files that will not be ran', 'none')) +opts.Add(('IGNORETESTS', 'A comma-separated list of test files that will be ran but ignored', ignore_tests)) +# build tools +opts.Add(('PATH', 'A colon-separated list of system paths instead of the default - TEMPORARY AND MAY DEPRECATE', None)) +opts.Add(('TOOLSET', 'A comma-separated list of specific tools used for building instead of the default', None)) +opts.Add(BoolOption('MSTOOLKIT', 'Use Microsoft Visual C++ Toolkit', 'no')) +opts.Add(BoolOption('CHMDOCS', 'Build CHM documentation, requires hhc.exe', hhc)) +opts.Add(PathOption('APPEND_CPPPATH', 'Additional paths to search for include files', None)) +opts.Add(PathOption('APPEND_LIBPATH', 'Additional paths to search for libraries', None)) +opts.Add(('APPEND_CCFLAGS', 'Additional C/C++ compiler flags')) +opts.Add(('APPEND_LINKFLAGS', 'Additional linker flags')) +# build options +opts.Add(BoolOption('DEBUG', 'Build executables with debugging information', 'no')) +opts.Add(PathOption('CODESIGNER', 'A program used to sign executables', None)) +opts.Add(BoolOption('STRIP', 'Strips executables of any unrequired data such as symbols', 'yes')) +opts.Add(BoolOption('STRIP_CP', 'Strips cross-platform executables of any unrequired data such as symbols', 'yes')) +opts.Add(BoolOption('STRIP_W32', 'Strips Win32 executables of any unrequired data such as symbols', 'yes')) +# path related build options +opts.Add(('PREFIX_DEST', 'Intermediate installation prefix (extra install time prefix)', dirs['dest'])) +opts.Add(('PREFIX_CONF', 'Path to install nsisconf.nsh to', dirs['conf'])) +opts.Add(('PREFIX_BIN', 'Path to install native binaries to', dirs['bin'])) +opts.Add(('PREFIX_DATA', 'Path to install nsis data to (plugins, includes, stubs, contrib, win32 binaries)', dirs['data'])) +opts.Add(('PREFIX_DOC','Path to install nsis README / INSTALL / TODO files to.', dirs['doc'])) +opts.Add(('PREFIX_INC_C','Path to install nsis C header files to.', dirs['inc_c'])) + +opts.Update(defenv) +Help(opts.GenerateHelpText(defenv)) + +# add prefixes defines +if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: + defenv.Append(NSIS_CPPDEFINES = [('PREFIX_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))]) + defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DATA', '"%s"' % defenv.subst('$PREFIX_DATA'))]) + +# write configuration into sconf.h and defines.h +sconf_h = open(File('#Source/exehead/sconf.h').abspath, 'w') +sconf_h.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') + +defines_h = open(File('#Source/defines.h').abspath, 'w') +defines_h.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') + +for i in defenv['NSIS_CPPDEFINES']: + if type(i) is not str: + sconf_h.write('#define %s %s\n' % (i[0], i[1])) + if str(i[1])[0] != '"': + defines_h.write('definedlist.add("%s", "%s");\n' % (i[0], i[1])) + else: + defines_h.write('definedlist.add("%s", %s);\n' % (i[0], i[1])) + else: + sconf_h.write('#define %s\n' % (i)) + defines_h.write('definedlist.add("%s");\n' % (i)) +sconf_h.close() +defines_h.close() + +# write version into version.h +f = open(File('#Source/version.h').abspath, 'w') +f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') +f.write('#define NSIS_VERSION "v%s"\n' % defenv['VERSION']) +f.close() + +###################################################################### +####### Functions ### +###################################################################### + +defenv['ZIPDISTDIR'] = defenv.Dir('#nsis-$VERSION') +defenv['INSTDISTDIR'] = defenv.Dir('#.instdist') +defenv['TESTDISTDIR'] = defenv.Dir('#.test') +defenv['DISTSUFFIX'] = '' + +if defenv.has_key('CODESIGNER'): + defenv['DISTSUFFIX'] = '-signed' + +defenv.Execute(Delete('$ZIPDISTDIR')) +defenv.Execute(Delete('$INSTDISTDIR')) +defenv.Execute(Delete('$TESTDISTDIR')) + +def SafeFile(f): + from types import StringType + + if isinstance(f, StringType): + return File(f) + + return f + +def MakeFileList(files): + from types import ListType, TupleType + + if isinstance(files, (ListType, TupleType)): + return map(SafeFile, files) + + return Flatten([SafeFile(files)]) + +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): + names = [names] + + for d in ('$ZIPDISTDIR', '$INSTDISTDIR', '$TESTDISTDIR'): + paths = 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']) : + prefix = '${PREFIX_DEST}${PREFIX_%s}' % component.upper() + paths = map(lambda file: os.path.join(prefix, path, subpath, file), names) + ins = defenv.InstallAs(paths, files) + else: + ins = [] + + if ins: + defenv.Alias('install', ins) + defenv.Alias('install-%s' % component, ins) + if alias: + defenv.Alias(alias, ins) + if install_alias: + defenv.Alias('install-%s' % install_alias, ins) + + return ins + +def DistributeBin(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'bin', '', path, alias) + +def DistributeConf(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'conf', '', path, alias) + +def DistributeW32Bin(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'data', 'Bin', path, alias, 'w32bin') + +def DistributeStubs(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'data', 'Stubs', path, alias, 'stubs') + +def DistributePlugin(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'data', 'Plugins', path, alias, 'plugins') + +def DistributeContrib(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'data', 'Contrib', path, alias, 'contrib') + +def DistributeMenu(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'data', 'Menu', path, alias, 'menu') + +def DistributeInclude(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'data', 'Include', path, alias, 'includes') + +def DistributeDoc(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'doc', '', path, alias) + +def DistributeDocs(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'doc', 'Docs', path, alias, 'docs') + +def DistributeExamples(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'doc', 'Examples', path, alias, 'examples') + +def DistributeIncC(files, names=[], path='', alias=None): + return defenv.Distribute(files, names, 'inc_c', '', path, alias, 'inc-c') + +def Sign(targets): + if defenv.has_key('CODESIGNER'): + for t in targets: + a = defenv.Action('$CODESIGNER "%s"' % t.path) + defenv.AddPostAction(t, a) + +def TestScript(scripts): + defenv.Install('$TESTDISTDIR/Tests', scripts) + +defenv.Distribute = Distribute +defenv.DistributeBin = DistributeBin +defenv.DistributeConf = DistributeConf +defenv.DistributeW32Bin = DistributeW32Bin +defenv.DistributeStubs = DistributeStubs +defenv.DistributePlugin = DistributePlugin +defenv.DistributeContrib = DistributeContrib +defenv.DistributeMenu = DistributeMenu +defenv.DistributeInclude = DistributeInclude +defenv.DistributeDoc = DistributeDoc +defenv.DistributeDocs = DistributeDocs +defenv.DistributeExamples = DistributeExamples +defenv.DistributeIncC = DistributeIncC +defenv.Sign = Sign +defenv.TestScript = TestScript + +###################################################################### +####### Environments ### +###################################################################### + +if defenv['DEBUG']: + defenv.Replace(BUILD_PREFIX = 'build/debug') +else: + defenv.Replace(BUILD_PREFIX = 'build/release') + +if defenv['MSTOOLKIT']: + defenv.Tool('mstoolkit', toolpath = ['SCons/Tools']) + +defenv.Append(CCFLAGS = Split('$APPEND_CCFLAGS')) +defenv.Append(LINKFLAGS = Split('$APPEND_LINKFLAGS')) +defenv.Append(CPPPATH = Split('$APPEND_CPPPATH')) +defenv.Append(LIBPATH = Split('$APPEND_LIBPATH')) + +defenv.Default('$BUILD_PREFIX') + +tools = defenv['TOOLS'] + +envs = [] + +if 'msvc' in tools or 'mstoolkit' in tools: + envs = SConscript('SCons/Config/ms') +elif 'gcc' in tools: + envs = SConscript('SCons/Config/gnu') +elif 'hpc++' in tools: + envs = SConscript('SCons/Config/hpc++') +else: + envs = SConscript('SCons/Config/default') + +stub_env = envs[0] +makensis_env = envs[1] +plugin_env = envs[2] +util_env = envs[3] +cp_util_env = envs[4] +test_env = envs[5] + +###################################################################### +####### Distribution ### +###################################################################### + +dist_zip = 'nsis-${VERSION}${DISTSUFFIX}.zip' +zip_target = defenv.Zip(dist_zip, '$ZIPDISTDIR') +defenv.Alias('dist-zip', zip_target) + +AlwaysBuild(defenv.AddPostAction(zip_target, Delete('$ZIPDISTDIR'))) + +if defenv['PLATFORM'] == 'win32': + optchar = '/' +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'): + defenv['INSTVER'] += ' %sDVER_MAJOR=$VER_MAJOR' % optchar + defenv['INSTVER'] += ' %sDVER_MINOR=$VER_MINOR' % optchar + defenv['INSTVER'] += ' %sDVER_REVISION=$VER_REVISION' % optchar + defenv['INSTVER'] += ' %sDVER_BUILD=$VER_BUILD' % optchar + +inst_env = {} +inst_env['NSISDIR'] = os.path.abspath(str(defenv['INSTDISTDIR'])) +inst_env['NSISCONFDIR'] = os.path.abspath(str(defenv['INSTDISTDIR'])) + +installer_target = defenv.Command('nsis-${VERSION}-setup${DISTSUFFIX}.exe', + '$INSTDISTDIR' + os.sep + 'Examples' + os.sep + 'makensis.nsi', + '$INSTDISTDIR' + os.sep + 'makensis$PROGSUFFIX ' + + '%sDOUTFILE=$TARGET.abspath $INSTVER $SOURCE' % optchar, + ENV = inst_env) +defenv.Depends(installer_target, '$INSTDISTDIR') +defenv.Sign(installer_target) +defenv.Alias('dist-installer', installer_target) + +AlwaysBuild(defenv.AddPostAction(installer_target, Delete('$INSTDISTDIR'))) + +defenv.Alias('dist', ['dist-zip', 'dist-installer']) + +###################################################################### +####### Distribute Basics ### +###################################################################### + +for d in doc: + if d in defenv['SKIPDOC']: + continue + defenv.DistributeDoc(d) + +defenv.DistributeConf('nsisconf.nsh') + +###################################################################### +####### Stubs ### +###################################################################### + +def BuildStub(compression, solid): + env = stub_env.Clone() + + suffix = '' + if solid: + suffix = '_solid' + + build_dir = '$BUILD_PREFIX/stub_%s%s' % (compression, suffix) + + exports = { 'env' : env, 'compression' : compression, 'solid_compression' : solid } + + target = defenv.SConscript(dirs = 'Source/exehead', build_dir = build_dir, duplicate = False, exports = exports) + env.SideEffect('%s/stub_%s.map' % (build_dir, stub), target) + + env.DistributeStubs(target, names=compression+suffix) + + defenv.Alias(compression, target) + defenv.Alias('stubs', target) + +for stub in stubs: + if stub in defenv['SKIPSTUBS']: + continue + + BuildStub(stub, False) + BuildStub(stub, True) + +defenv.DistributeStubs('Source/exehead/uninst.ico',names='uninst') + +###################################################################### +####### makensis ### +###################################################################### + +build_dir = '$BUILD_PREFIX/makensis' +exports = { 'env' : makensis_env } + +makensis = defenv.SConscript(dirs = 'Source', build_dir = build_dir, duplicate = False, exports = exports) + +makensis_env.SideEffect('%s/makensis.map' % build_dir, makensis) + +defenv.Alias('makensis', makensis) + +ins = defenv.DistributeBin(makensis,alias='install-compiler') + +###################################################################### +####### Common Functions ### +###################################################################### + +def AddEnvStandardFlags(env, defines, flags, entry, nodeflib): + if defines: + env.Append(CPPDEFINES = defines) + if flags: + env.Append(CCFLAGS = flags) + + if entry: + env.Append(LINKFLAGS = ['${ENTRY_FLAG("%s")}' % entry]) + + if nodeflib: + env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) # no default libraries + +def AppendRES(env, source, res, resources): + if res: + target = MakeFileList(res)[0].name.replace('.rc', '-rc') + target_res = env.RES(target, res) + if resources: + env.Depends(target_res, resources) + source.append(target_res) + +def CleanMap(env, target, target_name): + env.Clean(target, File(target_name + '.map')) + +def DistributeExtras(env, target, examples, docs): + if examples: + env.DistributeExamples(examples, path=target) + if docs: + env.DistributeDocs(docs, path=target) + +###################################################################### +####### Plug-ins ### +###################################################################### + +def BuildPlugin(target, source, libs, examples = None, docs = None, + entry = 'DllMain', res = None, resources = None, + defines = None, flags = None, nodeflib = True, + cppused = False): + env = plugin_env.Clone() + + if cppused and env['CPP_REQUIRES_STDLIB']: + nodeflib = False + + AddEnvStandardFlags(env, defines, flags, entry, nodeflib) + + AppendRES(env, source, res, resources) + + plugin = env.SharedLibrary(target, source, LIBS = libs) + defenv.Alias(target, plugin) + defenv.Alias('plugins', plugin) + + defenv.Sign(plugin) + + CleanMap(env, plugin, target) + + for i in plugin: + if str(i)[-4:].lower() == '.dll': + plugin = i + break + env.DistributePlugin(plugin) + + DistributeExtras(env, target, examples, docs) + +for plugin in plugins: + if plugin in defenv['SKIPPLUGINS']: + continue + + path = 'Contrib/' + plugin + build_dir = '$BUILD_PREFIX/' + plugin + exports = {'BuildPlugin' : BuildPlugin, 'env' : plugin_env.Clone()} + + defenv.SConscript(dirs = path, build_dir = build_dir, duplicate = False, exports = exports) + +###################################################################### +####### Utilities ### +###################################################################### + +def BuildUtilEnv(defines = None, flags = None, entry = None, + nodeflib = None, cross_platform = False): + if not cross_platform: + env = util_env.Clone() + else: + env = cp_util_env.Clone() + + AddEnvStandardFlags(env, defines, flags, entry, nodeflib) + + return env + +def BuildUtil(target, source, libs, entry = None, res = None, + resources = None, defines = None, flags = None, + nodeflib = False, file_name = '', path='', contrib = False, + examples = None, docs = None, cross_platform = False, + root_util = False): + env = BuildUtilEnv(defines, flags, entry, nodeflib, cross_platform) + + AppendRES(env, source, res, resources) + + if file_name != '': + target = "%s/%s" % (target, file_name) + + # make sure the environment suffix fits + if env['PROGSUFFIX'] not in target: + if '.' in target: + env['PROGSUFFIX'] = target[target.rindex('.'):] + + util = env.Program(target, source, LIBS = libs) + defenv.Alias(target, util) + defenv.Alias('utils', util) + + defenv.Sign(util) + + CleanMap(env, util, target) + + if contrib: + ins = env.DistributeContrib(util, path=path, alias='install-utils') + elif cross_platform and not env['PLATFORM'] == 'win32' or root_util and env['PLATFORM'] == 'win32': + ins = env.DistributeBin(util, path=path, alias='install-utils') + else: + ins = env.DistributeW32Bin(util, path=path, alias='install-utils') + + DistributeExtras(env, target, examples, docs) + + return util + +for util in utils: + if util in defenv['SKIPUTILS']: + continue + + path = 'Contrib/' + util + build_dir = '$BUILD_PREFIX/' + util + exports = {'BuildUtil' : BuildUtil, 'BuildUtilEnv' : BuildUtilEnv, 'env' : util_env} + + defenv.SConscript(dirs = path, build_dir = build_dir, duplicate = False, exports = exports) + +###################################################################### +####### Documentation ### +###################################################################### + +halibut = defenv.SConscript( + dirs = 'Docs/src/bin/halibut', + build_dir = '$BUILD_PREFIX/halibut', + duplicate = False, + exports = {'env' : defenv.Clone()} +) + +if defenv['CHMDOCS']: + defenv.SConscript( + dirs = 'Docs/src', + build_dir = '$BUILD_PREFIX/Docs/chm', + duplicate = False, + exports = {'halibut' : halibut, 'env' : defenv.Clone(), 'build_chm' : True} + ) +else: + defenv.SConscript( + dirs = 'Docs/src', + build_dir = '$BUILD_PREFIX/Docs/html', + duplicate = False, + exports = {'halibut' : halibut, 'env' : defenv.Clone(), 'build_chm' : False} + ) + +###################################################################### +####### Examples ### +###################################################################### + +defenv.SConscript( + dirs = 'Examples', + exports = {'env': defenv.Clone()} +) + +###################################################################### +####### Includes ### +###################################################################### + +defenv.SConscript( + dirs = 'Include', + exports = {'env': defenv.Clone()} +) + +###################################################################### +####### Miscellaneous ### +###################################################################### + +for i in misc: + if i in defenv['SKIPMISC']: + continue + + defenv.SConscript(dirs = 'Contrib/%s' % i) + +###################################################################### +####### Tests ### +###################################################################### + +# test code + +build_dir = '$BUILD_PREFIX/tests' +exports = {'env' : test_env.Clone()} + +defenv.SConscript( + dirs = 'Source/Tests', + duplicate = False, + exports = exports, + build_dir = build_dir +) + +defenv.Ignore('$BUILD_PREFIX', '$BUILD_PREFIX/tests') + +# test scripts + +test_scripts_env = defenv.Clone(ENV = os.environ) # env needed for some scripts +test_scripts_env['ENV']['NSISDIR'] = os.path.abspath(str(defenv['TESTDISTDIR'])) +test_scripts_env['ENV']['NSISCONFDIR'] = os.path.abspath(str(defenv['TESTDISTDIR'])) + +def test_scripts(target, source, env): + from os import walk, sep + + instdir = source[0].path + + makensis = instdir + sep + 'makensis' + + tdlen = len(env.subst('$TESTDISTDIR')) + skipped_tests = env['SKIPTESTS'].split(',') + ignored_tests = env['IGNORETESTS'].split(',') + + for root, dirs, files in walk(instdir): + for file in files: + if file[-4:] == '.nsi': + nsi = root + sep + file + nsif = nsi[tdlen + 1:] + + if nsif in skipped_tests: + continue + + if nsif in ignored_tests: + cmd = env.Command(None, nsi, '-%s $SOURCE' % makensis) + else: + cmd = env.Command(None, nsi, '%s $SOURCE' % makensis) + AlwaysBuild(cmd) + env.Alias('test-scripts', cmd) + + return None + +test = test_scripts_env.Command('test-scripts.log', '$TESTDISTDIR', test_scripts) +test_scripts_env.Alias('test-scripts', test) + +# test all + +defenv.Alias('test', ['test-code', 'test-scripts'])