summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-26 22:21:58 +0800
committerruki <[email protected]>2019-07-26 08:11:51 +0800
commitc16826e5756f35aecac2323bf7c210fdbf9ba537 (patch)
treee22f6437e02a35ed04a8884907e34101503d80d5
parent6ef33a04fafe3a4b2ec757abcffb46ce5e7488ec (diff)
add lock tips
-rw-r--r--xmake/actions/build/main.lua4
-rw-r--r--xmake/actions/clean/main.lua6
-rw-r--r--xmake/actions/config/main.lua4
-rw-r--r--xmake/actions/package/main.lua4
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua22
5 files changed, 31 insertions, 9 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 977b1a304..07d134cba 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -39,7 +39,7 @@ function main()
end
-- lock the whole project
- project.filelock():lock()
+ project.lock()
-- get the target name
local targetname = option.get("target")
@@ -83,7 +83,7 @@ function main()
}
-- unlock the whole project
- project.filelock():unlock()
+ project.unlock()
-- leave project directory
os.cd(oldir)
diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua
index 80fa2d4a6..d2c9b5969 100644
--- a/xmake/actions/clean/main.lua
+++ b/xmake/actions/clean/main.lua
@@ -207,7 +207,7 @@ end
function main()
-- lock the whole project
- project.filelock():lock()
+ project.lock()
-- get the target name
local targetname = option.get("target")
@@ -224,8 +224,8 @@ function main()
-- clean the current target
_clean(targetname)
- -- lock the whole project
- project.filelock():unlock()
+ -- unlock the whole project
+ project.unlock()
-- leave project directory
os.cd(oldir)
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 86979ad5e..1f185fe42 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -166,7 +166,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
end
-- lock the whole project
- project.filelock():lock()
+ project.lock()
-- enter menu config
if option.get("menu") then
@@ -302,5 +302,5 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
configcache:flush()
-- unlock the whole project
- project.filelock():unlock()
+ project.unlock()
end
diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua
index 83a1fb9b3..1c38ffa59 100644
--- a/xmake/actions/package/main.lua
+++ b/xmake/actions/package/main.lua
@@ -218,7 +218,7 @@ function main()
end
-- lock the whole project
- project.filelock():lock()
+ project.lock()
-- get the target name
local targetname = option.get("target")
@@ -243,5 +243,5 @@ function main()
end
-- unlock the whole project
- project.filelock():lock()
+ project.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 cdd8562a3..e6ff9c1de 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -24,6 +24,8 @@ local sandbox_core_project = sandbox_core_project or {}
-- load modules
local table = require("base/table")
local deprecated = require("base/deprecated")
+local utils = require("base/utils")
+local baseoption = require("base/option")
local config = require("project/config")
local option = require("project/option")
local project = require("project/project")
@@ -161,6 +163,26 @@ function sandbox_core_project.filelock()
return filelock
end
+-- lock the whole project
+function sandbox_core_project.lock(opt)
+ if sandbox_core_project.trylock(opt) then
+ return true
+ elseif baseoption.get("diagnosis") then
+ utils.warning("the current project is being accessed by other processes, please waiting!")
+ end
+ return sandbox_core_project.filelock():lock(opt)
+end
+
+-- trylock the whole project
+function sandbox_core_project.trylock(opt)
+ return sandbox_core_project.filelock():trylock(opt)
+end
+
+-- unlock the whole project
+function sandbox_core_project.unlock()
+ return sandbox_core_project.filelock():unlock()
+end
+
-- get the project mtimes
function sandbox_core_project.mtimes()
return project.mtimes()