summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-04 09:01:53 +0800
committerruki <[email protected]>2015-06-04 09:01:53 +0800
commit282c12b8f7b9b01a85844326c28f6bc3529aa088 (patch)
tree2f7557c695789276022f8f8094ac17f3e90c2357 /xmake/scripts
parenta73db10e9b42c8b18bf5b95d78855481beb67f20 (diff)
adjust global and config directory
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/config.lua23
-rw-r--r--xmake/scripts/base/global.lua30
2 files changed, 33 insertions, 20 deletions
diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua
index 7b6ef01b9..05edfc555 100644
--- a/xmake/scripts/base/config.lua
+++ b/xmake/scripts/base/config.lua
@@ -177,12 +177,8 @@ end
-- get the configure file
function config._file()
- -- the options
- local options = xmake._OPTIONS
- assert(options and options.project)
-
- -- get the configure file
- return options.project .. "/.xmake.xconf"
+ -- get it
+ return config.directory() .. "/xmake.xconf"
end
-- get the current target scope
@@ -243,6 +239,21 @@ function config.set(name, value)
config._CURRENT[name] = value
end
+-- get the configure directory
+function config.directory()
+
+ -- the directory
+ local dir = xmake._PROJECT_DIR .. "/.xmake"
+
+ -- create it directly first if not exists
+ if not os.isdir(dir) then
+ assert(os.mkdir(dir))
+ end
+
+ -- get it
+ return dir
+end
+
-- save xmake.xconf
function config.savexconf()
diff --git a/xmake/scripts/base/global.lua b/xmake/scripts/base/global.lua
index d1faff4b9..9e43213ee 100644
--- a/xmake/scripts/base/global.lua
+++ b/xmake/scripts/base/global.lua
@@ -130,7 +130,7 @@ end
function global._file()
-- get it
- return path.translate("~/.xmake/xmake.xconf")
+ return global.directory() .. "/xmake.xconf"
end
-- get the given configure from the current
@@ -164,6 +164,21 @@ function global.set(name, value)
end
+-- get the global configure directory
+function global.directory()
+
+ -- the directory
+ local dir = path.translate("~/.xmake")
+
+ -- create it directly first if not exists
+ if not os.isdir(dir) then
+ assert(os.mkdir(dir))
+ end
+
+ -- get it
+ return dir
+end
+
-- save xmake.xconf
function global.savexconf()
@@ -171,11 +186,6 @@ function global.savexconf()
local configs = global._CONFIGS
assert(configs)
- -- create directly first if not exists
- if not os.isdir("~/.xmake") then
- assert(os.mkdir("~/.xmake"))
- end
-
-- open the configure file
local path = global._file()
local file = io.open(path, "w")
@@ -285,13 +295,5 @@ function global.dump()
end
--- clean the current configure
-function global.clean()
-
- -- remove the configure file
- os.rm(global._file())
-
-end
-
-- return module: global
return global