From 984b6774019b2afb8c7b5cfdbfdc5b191e227e50 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Sat, 10 Jan 2015 16:13:49 -0800 Subject: [PATCH] Fix for Windows x64 builds (WiX Heat ATLHarvester support) * Adds ATLHarvester extension support to WiX buildscripts * Added python script to fix some minor screwups that ATLHarvester makes * Added x64 editions of FixFragment*.xslt * Candle now gets told to use x64 support when building for that arch. * README updated with new/clarified Windows dependencies. Yes, I'm aware there's probably a better way to do this, but it Works For Me(tm). --- .gitignore | 1 + README.md | 6 ++ cmake/FixFragment_HKCU_x64.xslt | 85 +++++++++++++++++++ ...nt_HKCU.xslt => FixFragment_HKCU_x86.xslt} | 0 cmake/FixFragment_HKLM_x64.xslt | 85 +++++++++++++++++++ ...nt_HKLM.xslt => FixFragment_HKLM_x86.xslt} | 0 cmake/Win.cmake | 23 +++-- cmake/fix-wix.py | 40 +++++++++ cmake/wix.cmake | 27 +++++- 9 files changed, 258 insertions(+), 9 deletions(-) create mode 100644 cmake/FixFragment_HKCU_x64.xslt rename cmake/{FixFragment_HKCU.xslt => FixFragment_HKCU_x86.xslt} (100%) mode change 100755 => 100644 create mode 100644 cmake/FixFragment_HKLM_x64.xslt rename cmake/{FixFragment_HKLM.xslt => FixFragment_HKLM_x86.xslt} (100%) create mode 100644 cmake/fix-wix.py diff --git a/.gitignore b/.gitignore index 22630b3f..ea231360 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ src/libs/openssl/openssl .kdev* tags bin +*.bak diff --git a/README.md b/README.md index 6b77ad9e..9c57de1f 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/cmake/FixFragment_HKCU_x64.xslt b/cmake/FixFragment_HKCU_x64.xslt new file mode 100644 index 00000000..cba167e1 --- /dev/null +++ b/cmake/FixFragment_HKCU_x64.xslt @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + yes + + + + + + + + + + + + + + + + + + + + + + + + + HKCU + + + + + + + yes + + + + + + + + + + + + + + + + diff --git a/cmake/FixFragment_HKCU.xslt b/cmake/FixFragment_HKCU_x86.xslt old mode 100755 new mode 100644 similarity index 100% rename from cmake/FixFragment_HKCU.xslt rename to cmake/FixFragment_HKCU_x86.xslt diff --git a/cmake/FixFragment_HKLM_x64.xslt b/cmake/FixFragment_HKLM_x64.xslt new file mode 100644 index 00000000..4530eb63 --- /dev/null +++ b/cmake/FixFragment_HKLM_x64.xslt @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + yes + + + + + + + + + + + + + + + + + + + + + + + + + HKLM + + + + + + + yes + + + + + + + + + + + + + + + + diff --git a/cmake/FixFragment_HKLM.xslt b/cmake/FixFragment_HKLM_x86.xslt similarity index 100% rename from cmake/FixFragment_HKLM.xslt rename to cmake/FixFragment_HKLM_x86.xslt diff --git a/cmake/Win.cmake b/cmake/Win.cmake index 3269f265..8153f1ac 100755 --- a/cmake/Win.cmake +++ b/cmake/Win.cmake @@ -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} ) diff --git a/cmake/fix-wix.py b/cmake/fix-wix.py new file mode 100644 index 00000000..32c3a0f7 --- /dev/null +++ b/cmake/fix-wix.py @@ -0,0 +1,40 @@ +''' +Fixes WiX installer files autogenerated by Heat in ATLCOM mode. + +@author: Rob "N3X15" Nelson +''' +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: + 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: + 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) diff --git a/cmake/wix.cmake b/cmake/wix.cmake index 23707a3c..9a030ce2 100755 --- a/cmake/wix.cmake +++ b/cmake/wix.cmake @@ -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}}")