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

Fix for Windows x64 builds (WiX Heat ATLHarvester support) #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ src/libs/openssl/openssl
.kdev*
tags
bin
*.bak
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Using Subversion

If you choose to use subversion to check out FireBreath, make sure you also check out the firebreath-boost project as src/3rdParty/boost/ (you'll have to remove the existing directory).

Note on Building Windows Projects
=================================

In order to build Windows projects, you need:
* [WiX Toolset 3.7](http://wix.codeplex.com/releases/view/99514) (higher versions cause problems)
* [ATLHarvester](https://wix.codeplex.com/SourceControl/network/forks/roberthyang/NewHeatExtension/latest#ATLHarvesterExtension/readme.txt) extension, which adds x64 support to Heat.
* Python 2.7 with lxml

Good luck!
85 changes: 85 additions & 0 deletions cmake/FixFragment_HKCU_x64.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:w="http://schemas.microsoft.com/wix/2006/wi">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

<!-- Identity template -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="/w:Wix" >
<w:Wix>
<xsl:apply-templates select="w:Fragment" />
</w:Wix>
</xsl:template>

<xsl:template match="w:Fragment" >
<w:Fragment>
<xsl:apply-templates select="w:DirectoryRef" />
<xsl:apply-templates select="w:ComponentGroup"/>
</w:Fragment>
</xsl:template>

<xsl:template match="/w:Wix/w:Fragment/w:DirectoryRef">
<w:DirectoryRef Id="{@Id}" />
</xsl:template>

<xsl:template match="w:Component">
<w:Component Id="{@Id}" Guid="{@Guid}" Directory="{@Directory}">
<!-- http://stackoverflow.com/questions/22932942/wix-heat-exe-win64-components-win64-yes -->
<xsl:attribute name="Win64">yes</xsl:attribute>
<xsl:apply-templates select="w:File" />
<xsl:apply-templates select="w:ProgId" />
<xsl:apply-templates select="w:RegistryValue" />
</w:Component>
</xsl:template>

<xsl:template match="w:TypeLib">
<w:TypeLib Id="{@Id}" Description="{@Description}" HelpDirectory="{@HelpDirectory}" Language="{@Language}" MajorVersion="{@MajorVersion}" MinorVersion="{@MinorVersion}">
<xsl:apply-templates select="*" />
</w:TypeLib>
</xsl:template>

<xsl:template match="w:File">
<w:File Id="{@Id}" Source="{@Source}">
<xsl:apply-templates select="w:TypeLib" />
</w:File>
</xsl:template>

<xsl:template match="w:RegistryValue">
<w:RegistryValue Key="{@Key}" Value="{@Value}" Type="{@Type}" Action="{@Action}">
<xsl:if test="@Name != ''"> <xsl:attribute name="Name"> <xsl:value-of select="@Name" /> </xsl:attribute> </xsl:if>
<xsl:if test="@Id != ''"> <xsl:attribute name="Id"> <xsl:value-of select="@Id" /> </xsl:attribute> </xsl:if>
<xsl:choose>
<xsl:when test="@Root='HKLM'">
<xsl:attribute name="Root">HKCU</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="Root"><xsl:value-of select="@Root" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@Name = 'Path'">
<xsl:attribute name="KeyPath">yes</xsl:attribute>
</xsl:if>
</w:RegistryValue>
</xsl:template>

<xsl:template match="w:ComponentGroup">
<w:ComponentGroup Id="{@Id}">
<xsl:apply-templates select="w:Component"/>
<!-- Intersection in XSLT 1.0 (Michael Kay) -->
</w:ComponentGroup>
</xsl:template>

<xsl:template match="w:ComponentRef">
<w:ComponentRef Id="{@Id}"/>
</xsl:template>

</xsl:stylesheet>
File renamed without changes.
85 changes: 85 additions & 0 deletions cmake/FixFragment_HKLM_x64.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:w="http://schemas.microsoft.com/wix/2006/wi">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

<!-- Identity template -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="/w:Wix" >
<w:Wix>
<xsl:apply-templates select="w:Fragment" />
</w:Wix>
</xsl:template>

<xsl:template match="w:Fragment" >
<w:Fragment>
<xsl:apply-templates select="w:DirectoryRef" />
<xsl:apply-templates select="w:ComponentGroup"/>
</w:Fragment>
</xsl:template>

<xsl:template match="/w:Wix/w:Fragment/w:DirectoryRef">
<w:DirectoryRef Id="{@Id}" />
</xsl:template>

<xsl:template match="w:Component">
<w:Component Id="{@Id}" Guid="{@Guid}" Directory="{@Directory}">
<!-- http://stackoverflow.com/questions/22932942/wix-heat-exe-win64-components-win64-yes -->
<xsl:attribute name="Win64">yes</xsl:attribute>
<xsl:apply-templates select="w:File" />
<xsl:apply-templates select="w:ProgId" />
<xsl:apply-templates select="w:RegistryValue" />
</w:Component>
</xsl:template>

<xsl:template match="w:TypeLib">
<w:TypeLib Id="{@Id}" Description="{@Description}" HelpDirectory="{@HelpDirectory}" Language="{@Language}" MajorVersion="{@MajorVersion}" MinorVersion="{@MinorVersion}">
<xsl:apply-templates select="*" />
</w:TypeLib>
</xsl:template>

<xsl:template match="w:File">
<w:File Id="{@Id}" Source="{@Source}">
<xsl:apply-templates select="w:TypeLib" />
</w:File>
</xsl:template>

<xsl:template match="w:RegistryValue">
<w:RegistryValue Key="{@Key}" Value="{@Value}" Type="{@Type}" Action="{@Action}">
<xsl:if test="@Name != ''"> <xsl:attribute name="Name"> <xsl:value-of select="@Name" /> </xsl:attribute> </xsl:if>
<xsl:if test="@Id != ''"> <xsl:attribute name="Id"> <xsl:value-of select="@Id" /> </xsl:attribute> </xsl:if>
<xsl:choose>
<xsl:when test="@Root='HKCU'">
<xsl:attribute name="Root">HKLM</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="Root"><xsl:value-of select="@Root" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@Name = 'Path'">
<xsl:attribute name="KeyPath">yes</xsl:attribute>
</xsl:if>
</w:RegistryValue>
</xsl:template>

<xsl:template match="w:ComponentGroup">
<w:ComponentGroup Id="{@Id}">
<xsl:apply-templates select="w:Component"/>
<!-- Intersection in XSLT 1.0 (Michael Kay) -->
</w:ComponentGroup>
</xsl:template>

<xsl:template match="w:ComponentRef">
<w:ComponentRef Id="{@Id}"/>
</xsl:template>

</xsl:stylesheet>
File renamed without changes.
23 changes: 17 additions & 6 deletions cmake/Win.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,27 @@ function (add_wix_installer PROJNAME WIX_SOURCEFILES WIX_COMPGROUP WIX_OUTDIR WI
set(SOURCELIST ${SOURCELIST} ${CMAKE_CURRENT_BINARY_DIR}/${_tmp_File})
ENDFOREACH()

# FixFragment_${KEY}_${ARCH}.xslt
set(_WIX_HEAT_TRANSFORM "FixFragment")
if (WIX_FORCE_PER STREQUAL "machine")
set(_WIX_HEAT_TRANSFORM "FixFragment_HKLM.xslt")
set(_WIX_HEAT_TRANSFORM "${_WIX_HEAT_TRANSFORM}_HKLM")
else()
set(_WIX_HEAT_TRANSFORM "FixFragment_HKCU.xslt")
set(_WIX_HEAT_TRANSFORM "${_WIX_HEAT_TRANSFORM}_HKCU")
endif()
if (FB_PLATFORM_ARCH_64)
set(_WIX_HEAT_TRANSFORM "${_WIX_HEAT_TRANSFORM}_x64.xslt")
else()
set(_WIX_HEAT_TRANSFORM "${_WIX_HEAT_TRANSFORM}_x86.xslt")
endif()

set (WIX_HEAT_FLAGS ${WIX_HEAT_FLAGS} -var var.BINSRC -t "${FB_ROOT}\\cmake\\${_WIX_HEAT_TRANSFORM}")
set (WIX_CANDLE_FLAGS ${WIX_LINK_FLAGS} -dBINSRC=${WIX_OUTDIR} -dPLUGINSRC=${FB_CURRENT_PLUGIN_DIR})
set (WIX_LINK_FLAGS ${WIX_LINK_FLAGS} -sw1076)
if (FB_PLATFORM_ARCH_64)
set (WIX_CANDLE_FLAGS ${WIX_CANDLE_FLAGS} -arch x64) # 64-bit support in Candle
endif()
WIX_HEAT(WIX_DLLFILES WIXDLLWXS_LIST NONE)

set (WIX_HEAT_FLAGS ${WIX_HEAT_FLAGS} -var var.BINSRC "-t:${FB_ROOT}\\cmake\\${_WIX_HEAT_TRANSFORM}")
set (WIX_CANDLE_FLAGS ${WIX_LINK_FLAGS} -dBINSRC=${WIX_OUTDIR} -dPLUGINSRC=${FB_CURRENT_PLUGIN_DIR})
set (WIX_LINK_FLAGS ${WIX_LINK_FLAGS} -sw1076)
WIX_HEAT(WIX_DLLFILES WIXDLLWXS_LIST NONE)
set (SOURCELIST ${SOURCELIST} ${WIXDLLWXS_LIST})
WIX_COMPILE(SOURCELIST WIXOBJ_LIST WIXDLLWXS_LIST)
SET (WIX_FULLOBJLIST ${WIXOBJ_LIST} )
Expand Down
40 changes: 40 additions & 0 deletions cmake/fix-wix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'''
Fixes WiX installer files autogenerated by Heat in ATLCOM mode.

@author: Rob "N3X15" Nelson <[email protected]>
'''
import argparse, re, sys, os

from lxml import etree

wix_xmlns = {
'w':"http://schemas.microsoft.com/wix/2006/wi",
'xs':"http://www.w3.org/2001/XMLSchema",
'fn':"http://www.w3.org/2005/xpath-functions"
}
def FixWix(infile, outfile):
tree = None
with open(infile,'r') as f:

Choose a reason for hiding this comment

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

Please change it to 'rb' instead.

tree = etree.parse(f)
for wComponent in tree.xpath('//w:Component', namespaces=wix_xmlns):
#Directory="dir99DE416F55C8960850D5A4FCA3758AD4"
if wComponent.get("Directory").startswith("dir"):
wComponent.set("Directory","TARGETDIR")
print('>>> Fixed {}: Directory="TARGETDIR"'.format(tree.getpath(wComponent)))

for wFile in tree.xpath('//w:File', namespaces=wix_xmlns):
#Source="SourceDir\Release\npHWLink.dll"
if wFile.get("Source").startswith("SourceDir"):
source = wFile.get("Source")
# Source="$(var.BINSRC)\npHWLink.dll"
wFile.set("Source","$(var.BINSRC)\\" + source.split('\\')[-1])
print('>>> Fixed {}: Source="{}"'.format(tree.getpath(wFile),wFile.get("Source")))

with open(outfile,'w') as f:

Choose a reason for hiding this comment

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

Please change it to 'wb' instead

f.write(etree.tostring(tree,pretty_print=True))
if __name__ == '__main__':
argp = argparse.ArgumentParser()
argp.add_argument('input',type=str,help="Output WXS file.")
argp.add_argument('output',type=str,help="Output WXS file.")
args = argp.parse_args()
FixWix(args.input, args.output)
27 changes: 24 additions & 3 deletions cmake/wix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,37 @@ if (WIN32)

DBG_MSG("WIX output: ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}")
DBG_MSG("WIX command: ${WIX_HEAT}")

if(FB_PLATFORM_ARCH_32)
set(WIXHEAT_OP file)
SET (WIXHEAT_OUTPUT_WIXOBJ ${OUTPUT_WIXOBJ} )
else()
set(WIXHEAT_OP atlcom) # 64-bit ATL harvester
SET (WIXHEAT_OUTPUT_WIXOBJ ${_basename}${WIX_HEAT_SUFFIX}_broken.wxs )
endif()

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${WIXHEAT_OUTPUT_WIXOBJ}
COMMAND ${WIX_HEAT}
ARGS file ${SOURCE_WIX_FILE}
-out ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}
ARGS ${WIXHEAT_OP} ${SOURCE_WIX_FILE}
-out ${CMAKE_CURRENT_BINARY_DIR}/${WIXHEAT_OUTPUT_WIXOBJ}
${WIX_HEAT_FLAGS}
DEPENDS ${SOURCE_WIX_FILE}
COMMENT "Compiling ${SOURCE_WIX_FILE} -> ${OUTPUT_WIXOBJ}"
)
# fix-wix.py fixes ATLCOM issues.
if(FB_PLATFORM_ARCH_64)
# TODO: Compile fix-wix with pyinstaller or something so there's fewer dependencies.
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}
COMMAND python
ARGS "${FB_ROOT}\\cmake\\fix-wix.py"
${CMAKE_CURRENT_BINARY_DIR}/${WIXHEAT_OUTPUT_WIXOBJ}
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${WIXHEAT_OUTPUT_WIXOBJ}
COMMENT "Fixing ${OUTPUT_WIXOBJ}"
)
endif()
SET(${_objs} ${${_objs}} ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ} )
ENDFOREACH(_current_DLL)
DBG_MSG("WIX compile output: ${${_objs}}")
Expand Down