Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Get the wix tool working #3294

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 61 additions & 22 deletions src/engine/SCons/Tool/wix.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,28 @@
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import glob

import SCons.Builder
import SCons.Action
import os

def generate(env):
"""Add Builders and construction variables for WiX to an Environment."""
if not exists(env):
return
path = os.environ['PATH'].split(os.pathsep)
try:
path.insert(0, os.path.join(os.environ['WIX'], "bin"))
except KeyError:
pass

env['WIXCANDLE'] = env.WhereIs('candle', path)
env['WIXCANDLEFLAGS'] = ['-nologo']
env['WIXCANDLEINCLUDE'] = []
env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}'

env['WIXLIGHTFLAGS'].append( '-nologo' )
env['WIXLIGHT'] = env.WhereIs('light', path)
env['WIXLIGHTFLAGS'] = ['-nologo']
env['WIXLIGHTCOM'] = "$WIXLIGHT $WIXLIGHTFLAGS -out ${TARGET} ${SOURCES}"
env['WIXSRCSUF'] = '.wxs'
env['WIXOBJSUF'] = '.wixobj'
Expand All @@ -63,38 +70,70 @@ def generate(env):
env['BUILDERS']['WiX'] = linker_builder

def exists(env):
"""simplified exists function for wix tool

old one is still here as old_exists.
Does depend on the OS path and the WIX setting.
We have to find this thing somehow...
"""
path = os.environ['PATH'].split(os.pathsep)
try:
path.insert(0, os.path.join(os.environ['WIX'], "bin"))
except KeyError:
pass
return env.WhereIs('candle', path)

def old_exists(env):
env['WIXCANDLE'] = 'candle.exe'
env['WIXLIGHT'] = 'light.exe'

# try to find the candle.exe and light.exe tools and
# add the install directory to light libpath.
def check_wix(e, p):
"""try to find the candle and light tools; add to path if found."""
try:
files = os.listdir(p)
if e['WIXCANDLE'] in files and e['WIXLIGHT'] in files:
e.PrependENVPath('PATH', p)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the "exists" function to mean "I want to know if this thing currently exists in my environment" not "find and add it to my environment". Is there any documentation regarding the goal of the exists function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any - I was asking this not long ago on the list (seems everybody just writes a tool by stealing from another tool, which is fine). Yes, I expect you're right about the intent, this is the resurrection of an old patch before I'd seen some of the recent discussion. I'm still willing to add some verbiage to the docs on generate/exists if I figure out what we should say.
The problem is... if we find the tool and so report (only), then somebody else has to repeat the work later to find it again, and that's hardly ideal either? We had that issue with the java tests until things got more unified.

# include appropriate flags if running WiX 2.0
if 'wixui.wixlib' in files and 'WixUI_en-us.wxl' in files:
e['WIXLIGHTFLAGS'] = [os.path.join(p, 'wixui.wixlib'),
'-loc',
os.path.join(p, 'WixUI_en-us.wxl')]
else:
e['WIXLIGHTFLAGS'] = []
return 1
except OSError:
pass # ignore this, could be a stale PATH entry.
return None

# look in existing paths first
for path in os.environ['PATH'].split(os.pathsep):
if not path:
continue

# workaround for some weird python win32 bug.
if path[0] == '"' and path[-1:]=='"':
if path[0] == '"' and path[-1:] == '"':
path = path[1:-1]

# normalize the path
path = os.path.normpath(path)

# search for the tools in the PATH environment variable
try:
files = os.listdir(path)
if env['WIXCANDLE'] in files and env['WIXLIGHT'] in files:
env.PrependENVPath('PATH', path)
# include appropriate flags if running WiX 2.0
if 'wixui.wixlib' in files and 'WixUI_en-us.wxl' in files:
env['WIXLIGHTFLAGS'] = [ os.path.join( path, 'wixui.wixlib' ),
'-loc',
os.path.join( path, 'WixUI_en-us.wxl' ) ]
else:
env['WIXLIGHTFLAGS'] = []
return 1
except OSError:
pass # ignore this, could be a stale PATH entry.

if check_wix(env, path):
return 1

# Wix is not in scons' PATH. Let's look in typical install locations.
wix_env = os.environ.get('WIX', None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the construction environment should tend not to be dependent on the system environment?

if wix_env:
wix_installs = [os.path.join(wix_env, 'bin')]
else:
wix_path = r'C:\Program Files (x86)\WiX Toolset v*.*\bin'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only would ever exist in "C:\Program Files (x86)" and not the 64 bit variant "C:\Program Files"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, apparently, the tools themeselves are 32-bit only (which I think is also true of all the visual studio stuff). No 64-bit installer exists.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, maybe... seems I've later been told if you do find a 32-bit windows install the path used by a installers will be "Program Files", not "Program Files (x86)"... I don't have one of those setups so I don't know if that applies to all packages, some packages, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes That's the case. We had to do this for finding vswhere.exe as well.
On a 32 bit install there is only Program files. On a 64 bit windows install there is Program Files (which is 64 bit), and Program Files (x86) which is 32 bit.

wix_installs = glob.glob(wix_path)
for path in wix_installs:
if check_wix(env, path):
return 1

# not found: don't leave remnants in the construction env
del env['WIXCANDLE']
del env['WIXLIGHT']
return None

# Local Variables:
Expand Down
1 change: 1 addition & 0 deletions test/packaging/msi/explicit-target.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
SUMMARY = 'balalalalal',
DESCRIPTION = 'this should be reallly really long',
VENDOR = 'Nanosoft_2000',
X_MSI_LANGUAGE = '1003',
source = env.FindInstalledFiles(),
target = "mypackage.msi",
)
Expand Down
3 changes: 3 additions & 0 deletions test/packaging/msi/file-placement.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
SUMMARY = 'balalalalal',
DESCRIPTION = 'this should be reallly really long',
VENDOR = 'Nanosoft_2000',
X_MSI_LANGUAGE = '1003',
source = [ f1 ],
)
""")
Expand Down Expand Up @@ -100,6 +101,7 @@
SUMMARY = 'balalalalal',
DESCRIPTION = 'this should be reallly really long',
VENDOR = 'Nanosoft_2000',
X_MSI_LANGUAGE = '1003',
LICENSE = 'afl',
source = [ f1, f2, f3, f4, f5, f6, f7 ],
)
Expand Down Expand Up @@ -150,6 +152,7 @@
DESCRIPTION = 'this should be reallly really long',
VENDOR = 'Nanosoft_2000',
LICENSE = 'afl',
X_MSI_LANGUAGE = '1003',
source = [ f1, f2, f3, f4 ],
)
""")
Expand Down
2 changes: 2 additions & 0 deletions test/packaging/msi/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
SUMMARY = 'balalalalal',
DESCRIPTION = 'this should be reallly really long',
VENDOR = 'Nanosoft_2000',
X_MSI_LANGUAGE = '1003',
source = [ f1, f2 ],
)

Expand Down Expand Up @@ -113,6 +114,7 @@
SUMMARY = 'balalalalal',
DESCRIPTION = 'this should be reallly really long',
VENDOR = 'Nanosoft_tx2000',
X_MSI_LANGUAGE = '1003',
source = [ f1, f2, f3, f4, f5 ],
)

Expand Down