summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA2va <[email protected]>2024-05-08 14:53:25 +0200
committerA2va <[email protected]>2024-05-08 14:53:25 +0200
commitec28f1ef6eddce80c7cd86f1e57a19532d3e681c (patch)
treed76aca07080cf2fe5dd2b46885e9ff73ee99caf4
parentcd3b9b037ece3d8dce7711f4143351733ce2a2ba (diff)
Handle license
-rw-r--r--xmake/plugins/pack/wix/main.lua27
-rw-r--r--xmake/scripts/xpack/wix/msi.wxs1
2 files changed, 27 insertions, 1 deletions
diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua
index 403ccca3e..938cb424f 100644
--- a/xmake/plugins/pack/wix/main.lua
+++ b/xmake/plugins/pack/wix/main.lua
@@ -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()
diff --git a/xmake/scripts/xpack/wix/msi.wxs b/xmake/scripts/xpack/wix/msi.wxs
index 6bbab6457..82ec2e88a 100644
--- a/xmake/scripts/xpack/wix/msi.wxs
+++ b/xmake/scripts/xpack/wix/msi.wxs
@@ -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)">