Skip to content

Commit 5418438

Browse files
committed
format code
1 parent 1dfee59 commit 5418438

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

xmake/plugins/pack/wix/main.lua

+10-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import("lib.detect.find_tool")
2222
import("private.action.require.impl.packagenv")
2323
import("private.action.require.impl.install_packages")
24-
2524
import(".batchcmds")
2625

2726
-- get the wixtoolset
@@ -65,7 +64,7 @@ function _to_rtf_string(str)
6564
escape_text = escape_text:gsub("}", "\\}")
6665

6766
local rtf = "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard ";
68-
rtf = rtf .. escape_text:gsub("\r\n", " \\par ") .. "}"
67+
rtf = rtf .. escape_text:gsub("\r\n", " \\par ") .. "}"
6968
return rtf
7069
end
7170

@@ -78,7 +77,7 @@ function _get_cp_kind_table(package, cmds, opt)
7877
if cmd.kind ~= "cp" then
7978
goto continue
8079
end
81-
80+
8281
local option = table.join(cmd.opt or {}, opt)
8382
local srcfiles = os.files(cmd.srcpath)
8483
for _, srcfile in ipairs(srcfiles) do
@@ -111,19 +110,16 @@ function _get_other_commands(package, cmd, opt)
111110
opt = table.join(cmd.opt or {}, opt)
112111
local result = ""
113112
local kind = cmd.kind
114-
115113
if kind == "rm" then
116114
local subdirectory = _translate_filepath(package, path.directory(cmd.filepath))
117115
subdirectory = subdirectory ~= "." and string.format([[Subdirectory="%s"]], subdirectory) or ""
118116
local on = opt.install and [[On="install"]] or [[On="uninstall"]]
119117
local filename = path.filename(cmd.filepath)
120-
121118
result = string.format([[<RemoveFile Directory="INSTALLFOLDER" Name="%s" %s %s/>]], filename, subdirectory, on)
122119
elseif kind == "rmdir" then
123120
local dir = _translate_filepath(package, cmd.dir)
124121
local subdirectory = dir ~= "." and string.format([[Subdirectory="%s"]], dir) or ""
125122
local on = opt.install and [[On="install"]] or [[On="uninstall"]]
126-
127123
result = string.format([[<RemoveFolder Directory="INSTALLFOLDER" %s %s/>]], subdirectory, on)
128124
elseif kind == "mkdir" then
129125
local dir = _translate_filepath(package, cmd.dir)
@@ -148,9 +144,9 @@ function _get_feature_string(name, title, opt)
148144
end
149145

150146
function _get_component_string(id, subdirectory)
151-
local subdirectory = (subdirectory ~= "." and subdirectory ~= nil) and string.format([[Subdirectory="%s"]], subdirectory) or ""
147+
local subdirectory = (subdirectory ~= "." and subdirectory ~= nil) and string.format([[Subdirectory="%s"]], subdirectory) or ""
152148
return string.format([[<Component Id="%s" Guid="%s" Directory="INSTALLFOLDER" %s>]], id:gsub(" ", ""), hash.uuid(id), subdirectory)
153-
end
149+
end
154150

155151
-- for each id/guid in the file wix want them to be unique
156152
-- so compute a hash for each directory based on the file that are inside
@@ -178,12 +174,11 @@ function _build_feature(package, opt)
178174

179175
local installcmds = batchcmds.get_installcmds(package):cmds()
180176
local uninstallcmds = batchcmds.get_uninstallcmds(package):cmds()
181-
177+
182178
local cp_table = _get_cp_kind_table(package, installcmds, opt)
183179
table.remove_if(installcmds, function (_, cmd) return cmd.kind == "cp" end)
184180

185181
local dir_id = _get_dir_id(cp_table)
186-
187182
for dir, files in pairs(cp_table) do
188183
table.insert(result, _get_component_string(dir_id[dir], dir))
189184
for _, file in ipairs(files) do
@@ -192,7 +187,7 @@ function _build_feature(package, opt)
192187
table.insert(result, string.format([[<File Source="%s" Name="%s"/>]], srcfile, dstname))
193188
end
194189
table.insert(result, "</Component>")
195-
end
190+
end
196191

197192
table.insert(result, _get_component_string(name.. "Cmds"))
198193
for _, cmd in ipairs(installcmds) do
@@ -201,7 +196,7 @@ function _build_feature(package, opt)
201196
for _, cmd in ipairs(uninstallcmds) do
202197
table.insert(result, _get_other_commands(package, cmd, {install = false}))
203198
end
204-
199+
205200
table.insert(result, "</Component>")
206201
table.insert(result, "</Feature>")
207202
return result
@@ -220,14 +215,12 @@ end
220215

221216
-- get specvars
222217
function _get_specvars(package)
223-
224218
local installcmds = batchcmds.get_installcmds(package):cmds()
225219
local specvars = table.clone(package:specvars())
226220

227221
local features = {}
228222
table.join2(features, _build_feature(package, {default = true, force = true, config_dir = true}))
229223
table.join2(features, _add_to_path(package))
230-
231224
for name, component in table.orderpairs(package:components()) do
232225
table.join2(features, _build_feature(component, {name = "Install " .. name}))
233226
end
@@ -296,12 +289,14 @@ function _pack_wix(wix, package)
296289
end
297290

298291
function main(package)
292+
299293
-- only for windows
300294
if not is_host("windows") then
301295
return
302296
end
303297

304298
cprint("packing %s", package:outputfile())
299+
305300
-- get wix
306301
local wix, oldenvs = _get_wix()
307302

@@ -310,4 +305,4 @@ function main(package)
310305

311306
-- done
312307
os.setenvs(oldenvs)
313-
end
308+
end

xmake/plugins/pack/xpack.lua

+13-13
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,16 @@ function xpack:inputkind()
190190
local inputkind = self:get("inputkind")
191191
if inputkind == nil then
192192
local inputkinds = {
193-
wix = "binary",
194-
nsis = "binary",
195-
zip = "binary",
196-
targz = "binary",
197-
srczip = "source",
193+
wix = "binary",
194+
nsis = "binary",
195+
zip = "binary",
196+
targz = "binary",
197+
srczip = "source",
198198
srctargz = "source",
199-
runself = "source",
200-
deb = "source",
201-
srpm = "source",
202-
rpm = "source"
199+
runself = "source",
200+
deb = "source",
201+
srpm = "source",
202+
rpm = "source"
203203
}
204204
inputkind = inputkinds[self:format()] or "binary"
205205
end
@@ -322,10 +322,10 @@ end
322322
-- get the specfile path
323323
function xpack:specfile()
324324
local extensions = {
325-
wix = ".wxs",
326-
nsis = ".nsi",
327-
srpm = ".spec",
328-
rpm = ".spec",
325+
wix = ".wxs",
326+
nsis = ".nsi",
327+
srpm = ".spec",
328+
rpm = ".spec",
329329
runself = ".lsm"
330330
}
331331
local extension = extensions[self:format()] or ".spec"

0 commit comments

Comments
 (0)