SCons builds a very basic Windows installer

This commit is contained in:
Ray Speth 2012-01-03 23:08:25 +00:00
parent a650168f3e
commit 82bc960575
4 changed files with 70 additions and 2 deletions

6
.gitignore vendored
View file

@ -6,7 +6,13 @@
*.obj
*.exe.manifest
build
stage
.sconsign.dblite
.sconf_temp
cantera.conf
config.log
*.lib
*.exp
*.manifest
*.dll
*.msi

View file

@ -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')

View file

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

View file

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