From 82bc960575d0c1b68b3fc49e7f51fc9d05ed955a Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 3 Jan 2012 23:08:25 +0000 Subject: [PATCH] SCons builds a very basic Windows installer --- .gitignore | 6 ++++++ SConstruct | 17 ++++++++++++++- site_scons/site_tools/wix.py | 42 ++++++++++++++++++++++++++++++++++++ site_scons/wxsgen.py | 7 +++++- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 site_scons/site_tools/wix.py diff --git a/.gitignore b/.gitignore index 2e7af4a69..e2ce9c995 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,13 @@ *.obj *.exe.manifest build +stage .sconsign.dblite .sconf_temp cantera.conf config.log +*.lib +*.exp +*.manifest +*.dll +*.msi diff --git a/SConstruct b/SConstruct index d067db721..944ed157c 100644 --- a/SConstruct +++ b/SConstruct @@ -18,6 +18,7 @@ Basic usage: """ from buildutils import * +import wxsgen if not COMMAND_LINE_TARGETS: # Print usage help @@ -42,7 +43,7 @@ if os.name == 'nt': else: extraEnvArgs['TARGET_ARCH'] = 'x86' -env = Environment(tools=['default', 'textfile', 'subst', 'recursiveInstall'], +env = Environment(tools=['default', 'textfile', 'subst', 'recursiveInstall', 'wix'], ENV={'PATH': os.environ['PATH']}, **extraEnvArgs) @@ -905,6 +906,20 @@ finish_install = env.Command('finish_install', [], postInstallMessage) env.Depends(finish_install, installTargets) install_cantera = Alias('install', finish_install) +def build_wxs(target, source, env): + wxsgen.make_wxs(env['stage_dir'], str(target[0])) + +if 'msi' in COMMAND_LINE_TARGETS: + wxs_target = env.Command(pjoin('build', 'wix', 'cantera.wxs'), + [], build_wxs) + env.AlwaysBuild(wxs_target) + msi_target = env.WiX('cantera.msi', + [pjoin('build', 'wix', 'cantera.wxs')]) + env.Depends(wxs_target, installTargets) + env.Depends(msi_target, wxs_target) + build_msi = Alias('msi', msi_target) + + ### Tests ### if 'test' in COMMAND_LINE_TARGETS or 'test-clean' in COMMAND_LINE_TARGETS: SConscript('test_problems/SConscript') diff --git a/site_scons/site_tools/wix.py b/site_scons/site_tools/wix.py new file mode 100644 index 000000000..865e700ac --- /dev/null +++ b/site_scons/site_tools/wix.py @@ -0,0 +1,42 @@ +""" +Tool to support WiX (Windows Installer XML toolset) +http://blogs.msdn.com/robmen/ +http://sourceforge.net/projects/wix +http://www.scons.org/wiki/WiX_Tool +""" +__revision__ = "Revision: 1.1" +__date__ = "Date: 2004/05/21 20:44:46" +__author__ = "elliot.murphy@veritas.com" +__credits__ = "" + +import os + +import SCons.Defaults +import SCons.Util +import SCons.Scanner + +def generate(env): + """Add Builders and construction variables for WiX to an Environment.""" + env['WIXCANDLE'] = '"%sbin/candle.exe"' % os.environ['WIX'] + env['WIXCANDLEFLAGS'] = ['-nologo'] + env['WIXCANDLEINCLUDE'] = [] + env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}' + + env['WIXLIGHT'] = '"%sbin/light.exe"' % os.environ['WIX'] + env['WIXLIGHTFLAGS'] = ['-nologo', '-spdb'] + env['WIXLIGHTCOM'] = "$WIXLIGHT $WIXLIGHTFLAGS -out ${TARGET} ${SOURCES}" + + object_builder = SCons.Builder.Builder( + action = '$WIXCANDLECOM', + suffix = '.wxiobj', + src_suffix = '.wxs') + + linker_builder = SCons.Builder.Builder( + action = '$WIXLIGHTCOM', + src_suffix = '.wxiobj', + src_builder = object_builder) + + env['BUILDERS']['WiX'] = linker_builder + +def exists(env): + return 1 # TODO: Should we do a better job of detecting? diff --git a/site_scons/wxsgen.py b/site_scons/wxsgen.py index fe9f81ccf..008f1a01e 100644 --- a/site_scons/wxsgen.py +++ b/site_scons/wxsgen.py @@ -49,7 +49,7 @@ def addDirectoryContents(prefix, directory, parent, feature): directories[directory] = Directory(parent, directory, directory) for path, dirs, files in os.walk('/'.join((prefix, directory))): - path = path.lstrip(prefix + '/').replace('\\', '/') + path = path.replace(prefix + '/', '', 1).replace('\\', '/') for d in dirs: dpath = '/'.join((path, d)) ID = dpath.replace('/', '_') @@ -105,6 +105,11 @@ def make_wxs(stageDir, outFile): # Files includes = addDirectoryContents(stageDir, 'include', instdir, complete) binaries = addDirectoryContents(stageDir, 'bin', instdir, complete) + lib_dir = addDirectoryContents(stageDir, 'lib', instdir, complete) + data_dir = addDirectoryContents(stageDir, 'data', instdir, complete) + demos_dir = addDirectoryContents(stageDir, 'demos', instdir, complete) + templates_dir = addDirectoryContents(stageDir, 'templates', instdir, complete) + tutorials_dir = addDirectoryContents(stageDir, 'tutorials', instdir, complete) # Format and save as XML indent(wix)