Skip to content

Commit 6975cf5

Browse files
authored
Merge pull request #5153 from xmake-io/wix
Xpack: wix toolset support
2 parents 707bfc3 + eb4ad9b commit 6975cf5

File tree

8 files changed

+390
-19
lines changed

8 files changed

+390
-19
lines changed

core/xpack.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ xpack("xmake")
55
set_copyright("Copyright (C) 2015-present, TBOOX Open Source Group")
66
set_author("[email protected]")
77
set_licensefile("../LICENSE.md")
8-
set_formats("nsis", "zip")
8+
set_formats("nsis", "wix", "zip")
99
add_targets("demo")
1010
set_bindir(".")
1111
set_iconfile("src/demo/xmake.ico")
@@ -33,7 +33,7 @@ xpack("xmake")
3333
import("utils.archive")
3434
import("core.base.global")
3535
local format = package:format()
36-
if package:is_plat("windows") and (format == "nsis" or format == "zip") then
36+
if package:is_plat("windows") and (format == "nsis" or format == "wix" or format == "zip") then
3737
local winenv = path.join(os.programdir(), "winenv")
3838
if os.isdir(winenv) then
3939
package:add("installfiles", path.join(winenv, "**"), {rootdir = path.directory(winenv)})
@@ -69,6 +69,11 @@ xpack_component("LongPath")
6969
; Enable long path
7070
WriteRegDWORD ${HKLM} "SYSTEM\CurrentControlSet\Control\FileSystem" "LongPathsEnabled" 1
7171
${EndIf}]])
72+
batchcmds:rawcmd("wix", [[
73+
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\FileSystem">
74+
<RegistryValue Type="integer" Name="LongPathsEnabled" Value="1" KeyPath="yes"/>
75+
</RegistryKey>
76+
]])
7277
end)
7378

7479
xpack("xmakesrc")

tests/plugins/pack/xmake.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ target("foo")
1919
add_packages("zlib")
2020

2121
xpack("test")
22-
set_formats("nsis", "srpm", "rpm", "zip", "targz", "srczip", "srctargz", "runself")
22+
set_formats("nsis", "srpm", "rpm", "zip", "targz", "srczip", "srctargz", "runself", "wix")
2323
set_title("hello")
2424
set_author("ruki")
2525
set_description("A test installer.")
@@ -61,6 +61,11 @@ xpack_component("LongPath")
6161
set_title("Enable Long Path")
6262
set_description("Increases the maximum path length limit, up to 32,767 characters (before 256).")
6363
on_installcmd(function (component, batchcmds)
64+
batchcmds:rawcmd("wix", [[
65+
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\FileSystem">
66+
<RegistryValue Type="integer" Name="LongPathsEnabled" Value="1" KeyPath="yes"/>
67+
</RegistryKey>
68+
]])
6469
batchcmds:rawcmd("nsis", [[
6570
${If} $NoAdmin == "false"
6671
; Enable long path

xmake/core/package/package.lua

+1
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ function _instance:manifest_save()
889889
manifest.mode = self:mode()
890890
manifest.configs = self:configs()
891891
manifest.envs = self:_rawenvs()
892+
manifest.pathenvs = self:_pathenvs():to_array()
892893

893894
-- save enabled library deps
894895
if self:librarydeps() then

xmake/modules/private/action/require/impl/packagenv.lua

+8-4
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@
1919
--
2020

2121
-- imports
22+
import("core.base.hashset")
2223
import("core.package.package", {alias = "core_package"})
2324

2425
-- enter the package environments
25-
function _enter_package(package_name, envs, installdir)
26+
function _enter_package(package_name, envs, pathenvs, installdir)
27+
if pathenvs then
28+
pathenvs = hashset.from(pathenvs)
29+
end
2630
for name, values in pairs(envs) do
27-
if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then
31+
if pathenvs and pathenvs:has(name) then
2832
for _, value in ipairs(values) do
2933
if path.is_absolute(value) then
3034
os.addenv(name, value)
3135
else
32-
os.addenv(name, path.join(installdir, value))
36+
os.addenv(name, path.normalize(path.join(installdir, value)))
3337
end
3438
end
3539
else
@@ -45,7 +49,7 @@ function enter(...)
4549
for _, manifest_file in ipairs(os.files(path.join(core_package.installdir(), name:sub(1, 1), name, "*", "*", "manifest.txt"))) do
4650
local manifest = io.load(manifest_file)
4751
if manifest and manifest.plat == os.host() and manifest.arch == os.arch() then
48-
_enter_package(name, manifest.envs, path.directory(manifest_file))
52+
_enter_package(name, manifest.envs, manifest.pathenvs, path.directory(manifest_file))
4953
end
5054
end
5155
end

0 commit comments

Comments
 (0)