-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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) | ||
# 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
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: | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.