diff options
| author | ruki <[email protected]> | 2019-07-26 22:19:02 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-07-26 07:54:17 +0800 |
| commit | 6ef33a04fafe3a4b2ec757abcffb46ce5e7488ec (patch) | |
| tree | 68a36f17ca80972fa33e7d90322510fd18067a9e /xmake | |
| parent | dd488ffd6dc1ec44b3d0c38a9dfd5f0ca99d6d2f (diff) | |
lock the whole project for some actions
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/actions/build/main.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/clean/main.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/config/main.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/package/main.lua | 6 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 13 |
5 files changed, 37 insertions, 0 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index f9446db68..977b1a304 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -38,6 +38,9 @@ function main() return trybuild() end + -- lock the whole project + project.filelock():lock() + -- get the target name local targetname = option.get("target") @@ -79,6 +82,9 @@ function main() } } + -- unlock the whole project + project.filelock():unlock() + -- leave project directory os.cd(oldir) diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua index dcdd26a13..80fa2d4a6 100644 --- a/xmake/actions/clean/main.lua +++ b/xmake/actions/clean/main.lua @@ -206,6 +206,9 @@ end -- main function main() + -- lock the whole project + project.filelock():lock() + -- get the target name local targetname = option.get("target") @@ -221,6 +224,9 @@ function main() -- clean the current target _clean(targetname) + -- lock the whole project + project.filelock():unlock() + -- leave project directory os.cd(oldir) end diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index fe81929dd..86979ad5e 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -165,6 +165,9 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end end + -- lock the whole project + project.filelock():lock() + -- enter menu config if option.get("menu") then menuconf_show() @@ -297,4 +300,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- flush config cache configcache:flush() + + -- unlock the whole project + project.filelock():unlock() end diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua index 76289e238..83a1fb9b3 100644 --- a/xmake/actions/package/main.lua +++ b/xmake/actions/package/main.lua @@ -217,6 +217,9 @@ function main() raise("please run \"xmake m package %s\" instead of \"xmake p --archs=%s\"", config.get("plat"), option.get("archs")) end + -- lock the whole project + project.filelock():lock() + -- get the target name local targetname = option.get("target") @@ -238,4 +241,7 @@ function main() end end end + + -- unlock the whole project + project.filelock():lock() end diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index a825f139a..cdd8562a3 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -148,6 +148,19 @@ function sandbox_core_project.directory() return project.directory() end +-- get the filelock of the whole project directory +function sandbox_core_project.filelock() + local filelock = sandbox_core_project._FILELOCK + if filelock == nil then + filelock = io.openlock(path.join(config.directory(), "project.lock")) + if not filelock then + raise("cannot create the project lock!") + end + sandbox_core_project._FILELOCK = filelock + end + return filelock +end + -- get the project mtimes function sandbox_core_project.mtimes() return project.mtimes() |
