diff options
| author | ruki <[email protected]> | 2021-01-19 22:38:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-01-19 22:38:57 +0800 |
| commit | 74908578f6f35f3a9a917e0256cbe55a2bdacbc8 (patch) | |
| tree | 2a0e2480ac14e21816f1881de36ff6dc3d8cb884 | |
| parent | d9189f7cd7843a39346a288a58a884ea9dcdf792 (diff) | |
improve autoupdate rule
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 21 | ||||
| -rw-r--r-- | xmake/plugins/project/vsxmake/vsxmake.lua | 20 | ||||
| -rw-r--r-- | xmake/rules/plugin/vsxmake/xmake.lua | 13 |
3 files changed, 35 insertions, 19 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index e02fd5dec..28454ba6e 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -35,6 +35,18 @@ import("actions.require.install", {alias = "install_requires", rootdir = os.prog import("actions.config.configfiles", {alias = "generate_configfiles", rootdir = os.programdir()}) import("actions.config.configheader", {alias = "generate_configheader", rootdir = os.programdir()}) +-- clear cache configuration +function _clear_cacheconf() + config.clear() + config.save() + localcache.clear("config") + localcache.clear("detect") + localcache.clear("option") + localcache.clear("package") + localcache.clear("toolchain") + localcache.save() +end + -- make target info function _make_targetinfo(mode, arch, target) @@ -309,14 +321,7 @@ function make(outputdir, vsinfo) end -- clear config and local cache - config.clear() - config.save() - localcache.clear("config") - localcache.clear("detect") - localcache.clear("option") - localcache.clear("package") - localcache.clear("toolchain") - localcache.save() + _clear_cacheconf() -- leave project directory os.cd(oldir) diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 3f3617a38..3594cf7e2 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -167,6 +167,17 @@ function _writefileifneeded(file, content) io.writefile(file, content) end +function _clear_cacheconf() + config.clear() + config.save() + localcache.clear("config") + localcache.clear("detect") + localcache.clear("option") + localcache.clear("package") + localcache.clear("toolchain") + localcache.save() +end + -- make function make(version) @@ -218,13 +229,6 @@ function make(version) end -- clear config and local cache - config.clear() - config.save() - localcache.clear("config") - localcache.clear("detect") - localcache.clear("option") - localcache.clear("package") - localcache.clear("toolchain") - localcache.save() + _clear_cacheconf() end end diff --git a/xmake/rules/plugin/vsxmake/xmake.lua b/xmake/rules/plugin/vsxmake/xmake.lua index c37c38101..c1e9506ce 100644 --- a/xmake/rules/plugin/vsxmake/xmake.lua +++ b/xmake/rules/plugin/vsxmake/xmake.lua @@ -28,7 +28,8 @@ -- @endcode -- rule("plugin.vsxmake.autoupdate") - after_build(function (target) + set_kind("project") + after_build(function (opt) -- imports import("core.project.depend") @@ -37,17 +38,23 @@ rule("plugin.vsxmake.autoupdate") -- run only once for all xmake process in vs local tmpfile = os.tmpfile(path.join(os.projectdir(), "plugin.vsxmake.autoupdate")) + local dependfile = tmpfile .. ".d" local lockfile = io.openlock(tmpfile .. ".lock") if lockfile:trylock() then if os.getenv("XMAKE_IN_VSTUDIO") then + local sourcefiles = {} + for _, target in pairs(project.targets()) do + table.join2(sourcefiles, (target:sourcefiles())) + end + table.sort(sourcefiles) depend.on_changed(function () -- 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", + end, {dependfile = dependfile, files = project.allfiles(), - values = target:sourcefiles()}) + values = sourcefiles}) end lockfile:close() end |
