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

Xpack: wix toolset support #4788

Merged
merged 15 commits into from
May 27, 2024
Prev Previous commit
Next Next commit
Handle license
A2va committed May 8, 2024
commit ec28f1ef6eddce80c7cd86f1e57a19532d3e681c
27 changes: 26 additions & 1 deletion xmake/plugins/pack/wix/main.lua
Original file line number Diff line number Diff line change
@@ -55,6 +55,20 @@ function _translate_filepath(package, filepath)
return path.relative(filepath, package:install_rootdir())
end

function _to_rtf_string(str)
if str == "" then
return str
end

local escape_text = str:gsub("\\", "\\\\")
escape_text = escape_text:gsub("{", "\\{")
escape_text = escape_text:gsub("}", "\\}")

local rtf = "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard ";
rtf = rtf .. escape_text:gsub("\r\n", " \\par ") .. "}"
return rtf
end

-- get a table where the key is a directory and the value a list of files
-- used to regroup all files that are placed in the same directory under the same component.
function _get_cp_kind_table(package, cmds, opt)
@@ -199,6 +213,18 @@ function _get_specvars(package)
table.join2(features, _build_feature(component, {name = "Install " .. name}))
end

specvars.PACKAGE_LICENSEFILE = function ()
local rtf_string = ""
local licensefile = package:get("licensefile")
if licensefile then
rtf_string = _to_rtf_string(io.readfile(licensefile))
end

local rtf_file = path.join(package:buildir(), "license.rtf")
io.writefile(rtf_file, rtf_string)
return rtf_file
end

specvars.PACKAGE_WIX_CMDS = table.concat(features, "\n ")
specvars.PACKAGE_WIX_UPGRADECODE = hash.uuid(package:name())

@@ -257,7 +283,6 @@ function main(package)
end

cprint("packing %s", package:outputfile())

-- get wix
local wix, oldenvs = _get_wix()

1 change: 1 addition & 0 deletions xmake/scripts/xpack/wix/msi.wxs
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
<Icon Id="Icon.ico" SourceFile="$(PackageIconFile)"/>
<?endif ?>
<MediaTemplate EmbedCab="true" />
<WixVariable Id="WixUILicenseRtf" Value="$(PackageLicenseFile)" />
<ui:WixUI Id="WixUI_FeatureTree" InstallDirectory="INSTALLFOLDER" />
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="CompanyFolder" Name="$(PackageCompany)">