summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-14 23:04:06 +0800
committerruki <[email protected]>2023-11-14 23:04:06 +0800
commit661940b67e586377a362dd956b699244aa3165ec (patch)
tree40fb0d6edba05b1848bc364ca7629633f283c8ef
parenta6712c961f931d3691e8ef3cf51ff3979610fec9 (diff)
improve some cmds
-rw-r--r--tests/plugins/pack/assets/file1.txt0
-rw-r--r--tests/plugins/pack/assets/file2.txt0
-rw-r--r--tests/plugins/pack/src/assets/file1.txt1
-rw-r--r--tests/plugins/pack/src/assets/file2.txt1
-rw-r--r--tests/plugins/pack/src/assets/img1.png (renamed from tests/plugins/pack/assets/img1.png)0
-rw-r--r--tests/plugins/pack/src/assets/img2.png (renamed from tests/plugins/pack/assets/img2.png)0
-rw-r--r--tests/plugins/pack/xmake.lua4
-rw-r--r--xmake/plugins/pack/nsis/main.lua22
8 files changed, 21 insertions, 7 deletions
diff --git a/tests/plugins/pack/assets/file1.txt b/tests/plugins/pack/assets/file1.txt
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/plugins/pack/assets/file1.txt
+++ /dev/null
diff --git a/tests/plugins/pack/assets/file2.txt b/tests/plugins/pack/assets/file2.txt
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/plugins/pack/assets/file2.txt
+++ /dev/null
diff --git a/tests/plugins/pack/src/assets/file1.txt b/tests/plugins/pack/src/assets/file1.txt
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/tests/plugins/pack/src/assets/file1.txt
@@ -0,0 +1 @@
+hello
diff --git a/tests/plugins/pack/src/assets/file2.txt b/tests/plugins/pack/src/assets/file2.txt
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/tests/plugins/pack/src/assets/file2.txt
@@ -0,0 +1 @@
+hello
diff --git a/tests/plugins/pack/assets/img1.png b/tests/plugins/pack/src/assets/img1.png
index e69de29bb..e69de29bb 100644
--- a/tests/plugins/pack/assets/img1.png
+++ b/tests/plugins/pack/src/assets/img1.png
diff --git a/tests/plugins/pack/assets/img2.png b/tests/plugins/pack/src/assets/img2.png
index e69de29bb..e69de29bb 100644
--- a/tests/plugins/pack/assets/img2.png
+++ b/tests/plugins/pack/src/assets/img2.png
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua
index 666b98c54..46517107b 100644
--- a/tests/plugins/pack/xmake.lua
+++ b/tests/plugins/pack/xmake.lua
@@ -15,11 +15,11 @@ xpack("test")
add_installfiles("assets/*.png")
set_installdir("assets")
on_installcmd(function (package, batchcmds)
- batchcmds:cp("assets/*.txt", "assets")
+ batchcmds:cp("src/assets/*.txt", "resources/", {rootdir = "src"})
batchcmds:mkdir("stub")
end)
on_uninstallcmd(function (package, batchcmds)
- batchcmds:rm("assets")
+ batchcmds:rm("resources")
batchcmds:rm("stub")
end)
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index fc032efca..1aff5114d 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -53,26 +53,38 @@ function _get_makensis()
return makensis, oldenvs
end
+-- copy files or directories and we can reserve the source directory structure
+-- e.g. os.cp("src/**.h", "/tmp/", {rootdir = "src", symlink = true})
+
-- get command string
function _get_command_strings(package, cmd)
local result = {}
+ local opt = cmd.opt or {}
local kind = cmd.kind
if kind == "cp" then
-- https://nsis.sourceforge.io/Reference/File
local srcfiles = os.files(cmd.srcpath)
for _, srcfile in ipairs(srcfiles) do
- table.insert(result, string.format("File /oname=%s %s", cmd.dstpath, srcfile))
+ -- the destination is directory? append the filename
+ local dstfile = cmd.dstpath
+ if path.islastsep(dstfile) then
+ if opt.rootdir then
+ dstfile = path.join(dstfile, path.relative(srcfile, opt.rootdir))
+ else
+ dstfile = path.join(dstfile, path.filename(srcfile))
+ end
+ end
+ table.insert(result, string.format("SetOutPath \"$INSTDIR\\%s\"", path.directory(dstfile)))
+ table.insert(result, string.format("File /oname=%s \"%s\"", path.filename(dstfile), srcfile))
end
elseif kind == "rm" then
- -- TODO
+ table.insert(result, string.format("RMDir /r \"$INSTDIR\\%s\"", path.directory(cmd.filepath)))
elseif kind == "mv" then
-- TODO
elseif kind == "cd" then
-- TODO
elseif kind == "mkdir" then
- -- TODO
- elseif kind == "show" then
- -- TODO
+ table.insert(result, string.format("CreateDirectory \"$INSTDIR\\%s\"", path.directory(cmd.dir)))
end
return result
end