summaryrefslogtreecommitdiff
path: root/xmake/rules/plugin
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-12 23:59:45 +0800
committerruki <[email protected]>2020-12-12 23:59:45 +0800
commitfe38b39cd90b8cd866121b3e443aeba277f4d3c6 (patch)
tree9d4534d5d7d67697a61234654a228efa7f1e3ce4 /xmake/rules/plugin
parentcba3c243091aef9ed81bdc429ee4958a81a31122 (diff)
improve autoupdate for vsxmake
Diffstat (limited to 'xmake/rules/plugin')
-rw-r--r--xmake/rules/plugin/vsxmake/xmake.lua26
1 files changed, 16 insertions, 10 deletions
diff --git a/xmake/rules/plugin/vsxmake/xmake.lua b/xmake/rules/plugin/vsxmake/xmake.lua
index f981e7071..ea357ba64 100644
--- a/xmake/rules/plugin/vsxmake/xmake.lua
+++ b/xmake/rules/plugin/vsxmake/xmake.lua
@@ -29,19 +29,25 @@
--
rule("plugin.vsxmake.autoupdate")
before_build(function (target)
- if not _g.autoupdate then
- import("core.project.depend")
- import("core.project.project")
+
+ -- imports
+ import("core.project.depend")
+ import("core.project.project")
+ import("core.base.task")
+
+ -- run only once for all xmake process in vs
+ local tmpfile = os.tmpfile(path.join(os.projectdir(), "plugin.vsxmake.autoupdate"))
+ local lockfile = io.openlock(tmpfile .. ".lock")
+ if lockfile:trylock() then
if os.getenv("XMAKE_IN_VSTUDIO") then
depend.on_changed(function ()
- print("autoupdate vsxmake project ..")
- project.unlock()
- os.execv("xmake", {"project", "-k", "vsxmake"})
- project.lock()
- print("autoupdate vsxmake project ok")
- end, {files = project.allfiles()})
+ -- we use task instead of os.exec("xmake") to avoid the project lock
+ print("update vsxmake project ..")
+ task.run("project", {kind = "vsxmake"})
+ print("update vsxmake project ok")
+ end, {dependfile = tmpfile .. ".d", files = project.allfiles()})
end
- _g.autoupdate = true
+ lockfile:close()
end
end)