summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-17 21:24:15 +0800
committerruki <[email protected]>2017-07-17 21:24:15 +0800
commit33144e73eae59ee7d934fd77673aac5a5a5cb0d1 (patch)
treeb8aa2925c9c7e44184c5288d5e7fffab715a5f36
parent90c118045794457feb9c5e7a36c9625a25841cb1 (diff)
move global to base module
-rw-r--r--xmake/actions/clean/main.lua2
-rw-r--r--xmake/actions/config/main.lua2
-rw-r--r--xmake/actions/global/main.lua2
-rw-r--r--xmake/actions/package/main.lua2
-rw-r--r--xmake/actions/run/main.lua2
-rw-r--r--xmake/core/base/global.lua (renamed from xmake/core/project/global.lua)5
-rw-r--r--xmake/core/language/language.lua6
-rw-r--r--xmake/core/platform/platform.lua12
-rw-r--r--xmake/core/project/cache.lua2
-rw-r--r--xmake/core/project/config.lua11
-rw-r--r--xmake/core/project/project.lua44
-rw-r--r--xmake/core/project/task.lua4
-rw-r--r--xmake/core/sandbox/modules/import.lua22
-rw-r--r--xmake/core/sandbox/modules/import/core/base/global.lua (renamed from xmake/core/sandbox/modules/import/core/project/global.lua)34
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua6
-rw-r--r--xmake/platforms/windows/environment.lua2
16 files changed, 56 insertions, 102 deletions
diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua
index 3d439e008..07a10d72e 100644
--- a/xmake/actions/clean/main.lua
+++ b/xmake/actions/clean/main.lua
@@ -26,7 +26,7 @@
import("core.base.option")
import("core.project.task")
import("core.project.config")
-import("core.project.global")
+import("core.base.global")
import("core.project.project")
import("core.platform.platform")
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 07588378c..36a5c50c2 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -25,7 +25,7 @@
-- imports
import("core.base.option")
import("core.project.config")
-import("core.project.global")
+import("core.base.global")
import("core.project.project")
import("core.platform.platform")
import("core.project.cache", {nocache = true})
diff --git a/xmake/actions/global/main.lua b/xmake/actions/global/main.lua
index 14b98fc07..13bf19354 100644
--- a/xmake/actions/global/main.lua
+++ b/xmake/actions/global/main.lua
@@ -24,7 +24,7 @@
-- imports
import("core.base.option")
-import("core.project.global")
+import("core.base.global")
-- main
function main()
diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua
index e9255635b..80d6ac70c 100644
--- a/xmake/actions/package/main.lua
+++ b/xmake/actions/package/main.lua
@@ -26,7 +26,7 @@
import("core.base.option")
import("core.project.task")
import("core.project.config")
-import("core.project.global")
+import("core.base.global")
import("core.project.project")
import("core.platform.platform")
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua
index c87c12b70..571c5d10e 100644
--- a/xmake/actions/run/main.lua
+++ b/xmake/actions/run/main.lua
@@ -26,7 +26,7 @@
import("core.base.option")
import("core.project.task")
import("core.project.config")
-import("core.project.global")
+import("core.base.global")
import("core.project.project")
import("core.platform.platform")
import("devel.debugger")
diff --git a/xmake/core/project/global.lua b/xmake/core/base/global.lua
index 788afd1f3..daa6a6e54 100644
--- a/xmake/core/project/global.lua
+++ b/xmake/core/base/global.lua
@@ -34,8 +34,6 @@ local option = require("base/option")
-- get the configure file
function global._file()
-
- -- get it
return path.join(global.directory(), "xmake.conf")
end
@@ -64,7 +62,6 @@ function global.set(name, value)
-- set it
configs[name] = value
-
end
-- get all options
@@ -84,8 +81,6 @@ end
-- get the global configure directory
function global.directory()
-
- -- get it
return path.translate("~/.xmake")
end
diff --git a/xmake/core/language/language.lua b/xmake/core/language/language.lua
index a1f2015f8..8bf9395ae 100644
--- a/xmake/core/language/language.lua
+++ b/xmake/core/language/language.lua
@@ -34,7 +34,7 @@ local table = require("base/table")
local interpreter = require("base/interpreter")
local sandbox = require("sandbox/sandbox")
local config = require("project/config")
-local global = require("project/global")
+local global = require("base/global")
-- new an instance
function _instance.new(name, info, rootdir)
@@ -213,9 +213,7 @@ end
-- the directory of language
function language._directory()
-
- -- the directory
- return path.join(xmake._PROGRAM_DIR, "languages")
+ return path.join(os.programdir(), "languages")
end
-- the interpreter
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index 26852b60e..9e66824d0 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -34,7 +34,7 @@ local table = require("base/table")
local interpreter = require("base/interpreter")
local sandbox = require("sandbox/sandbox")
local config = require("project/config")
-local global = require("project/global")
+local global = require("base/global")
-- new an instance
function _instance.new(name, info, rootdir)
@@ -82,29 +82,21 @@ end
-- get the platform os
function _instance:os()
-
- -- get it
return self._INFO.os
end
-- get the platform menu
function _instance:menu()
-
- -- get it
return self._INFO.menu
end
-- get the platform hosts
function _instance:hosts()
-
- -- get it
return self._INFO.hosts
end
-- get the platform archs
function _instance:archs()
-
- -- get it
return self._INFO.archs
end
@@ -114,7 +106,7 @@ function platform._directories()
-- the directories
return { path.join(config.directory(), "platforms")
, path.join(global.directory(), "platforms")
- , path.join(xmake._PROGRAM_DIR, "platforms")
+ , path.join(os.programdir(), "platforms")
}
end
diff --git a/xmake/core/project/cache.lua b/xmake/core/project/cache.lua
index d96f12e00..7dfbd9956 100644
--- a/xmake/core/project/cache.lua
+++ b/xmake/core/project/cache.lua
@@ -32,7 +32,7 @@ local path = require("base/path")
local table = require("base/table")
local utils = require("base/utils")
local config = require("project/config")
-local global = require("project/global")
+local global = require("base/global")
-- the cache instance
--
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index 8fb1c160d..6d5925c42 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -32,12 +32,9 @@ local path = require("base/path")
local table = require("base/table")
local utils = require("base/utils")
local option = require("base/option")
-local global = require("project/global")
-- get the configure file
function config._file()
-
- -- get it
return path.join(config.directory(), "xmake.conf")
end
@@ -95,7 +92,6 @@ function config.set(name, value)
-- set it
configs[name] = value
-
end
-- get all options
@@ -138,9 +134,7 @@ end
-- get the configure directory
function config.directory()
-
- -- get it
- return path.join(xmake._PROJECT_DIR, ".xmake")
+ return path.join(os.projectdir(), ".xmake")
end
-- load the project configure
@@ -218,10 +212,7 @@ end
-- init the config
function config.init()
-
- -- clear it
config._CONFIGS = {}
-
end
-- dump the configure
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index aca63f67e..692d504b3 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -36,7 +36,7 @@ local deprecated = require("base/deprecated")
local interpreter = require("base/interpreter")
local target = require("project/target")
local config = require("project/config")
-local global = require("project/global")
+local global = require("base/global")
local option = require("project/option")
local package = require("project/package")
local deprecated_project = require("project/deprecated/project")
@@ -146,32 +146,32 @@ function project._api_is_option(interp, ...)
end
end
--- load all packages from the given directories
-function project._api_add_pkgdirs(interp, ...)
+-- load all plugins from the given directories
+function project._api_add_plugindirs(interp, ...)
-- get all directories
- local pkgdirs = {}
+ local plugindirs = {}
local dirs = table.join(...)
for _, dir in ipairs(dirs) do
- table.insert(pkgdirs, dir .. "/*.pkg")
+ table.insert(plugindirs, dir .. "/*")
end
- -- add all packages
- interp:api_builtin_add_subdirs(pkgdirs)
+ -- add all plugins
+ interp:api_builtin_add_subdirs(plugindirs)
end
--- load all plugins from the given directories
-function project._api_add_plugindirs(interp, ...)
+-- load all packages from the given directories
+function project._api_add_packagedirs(interp, ...)
-- get all directories
- local plugindirs = {}
+ local pkgdirs = {}
local dirs = table.join(...)
for _, dir in ipairs(dirs) do
- table.insert(plugindirs, dir .. "/*")
+ table.insert(pkgdirs, dir .. "/*.pkg")
end
- -- add all plugins
- interp:api_builtin_add_subdirs(plugindirs)
+ -- add all packages
+ interp:api_builtin_add_subdirs(pkgdirs)
end
-- get interpreter
@@ -279,16 +279,16 @@ function project._interpreter()
, custom =
{
-- is_xxx
- {"is_os", project._api_is_os }
- , {"is_kind", project._api_is_kind }
- , {"is_host", project._api_is_host }
- , {"is_mode", project._api_is_mode }
- , {"is_plat", project._api_is_plat }
- , {"is_arch", project._api_is_arch }
- , {"is_option", project._api_is_option }
+ {"is_os", project._api_is_os }
+ , {"is_kind", project._api_is_kind }
+ , {"is_host", project._api_is_host }
+ , {"is_mode", project._api_is_mode }
+ , {"is_plat", project._api_is_plat }
+ , {"is_arch", project._api_is_arch }
+ , {"is_option", project._api_is_option }
-- add_xxx
- , {"add_packagedirs", project._api_add_pkgdirs }
- , {"add_plugindirs", project._api_add_plugindirs }
+ , {"add_plugindirs", project._api_add_plugindirs }
+ , {"add_packagedirs", project._api_add_packagedirs }
}
}
diff --git a/xmake/core/project/task.lua b/xmake/core/project/task.lua
index f1aad65a0..1f7770881 100644
--- a/xmake/core/project/task.lua
+++ b/xmake/core/project/task.lua
@@ -32,7 +32,7 @@ local utils = require("base/utils")
local string = require("base/string")
local interpreter = require("base/interpreter")
local sandbox = require("sandbox/sandbox")
-local global = require("project/global")
+local global = require("base/global")
local config = require("project/config")
local project = require("project/project")
local package = require("project/package")
@@ -201,7 +201,7 @@ function task._interpreter()
, scriptdir = function () return sandbox_os.scriptdir() end
, globaldir = global.directory()
, configdir = config.directory()
- , projectdir = xmake._PROJECT_DIR
+ , projectdir = os.projectdir()
, packagedir = package.directory()
, programdir = os.programdir()
}
diff --git a/xmake/core/sandbox/modules/import.lua b/xmake/core/sandbox/modules/import.lua
index 5317efa6e..7f19159df 100644
--- a/xmake/core/sandbox/modules/import.lua
+++ b/xmake/core/sandbox/modules/import.lua
@@ -31,7 +31,7 @@ local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
-local global = require("project/global")
+local global = require("base/global")
local sandbox = require("sandbox/sandbox")
local raise = require("sandbox/modules/raise")
@@ -299,23 +299,17 @@ function sandbox_import.import(name, args)
local rootdir = args.rootdir or instance:rootdir()
assert(rootdir)
- -- the sandbox modules directory
- local modules_sandbox_dir = path.join(os.programdir(), "core/sandbox/modules/import")
+ -- the global modules directory of users
+ local modules_global_dir = path.join(global.directory(), "modules")
- -- the extension modules directory
- local modules_extension_dir = path.join(os.programdir(), "modules")
+ -- the program modules directory
+ local modules_program_dir = path.join(os.programdir(), "modules")
- -- the global modules directory for users
- local modules_global_dir = path.join(global.directory(), "modules")
+ -- the sandbox modules directory
+ local modules_sandbox_dir = path.join(os.programdir(), "core/sandbox/modules/import")
-- init module directories
- local modules_directories =
- {
- rootdir -- load module from the given root directory first
- , path.join(global.directory(), "modules") -- load module from the user global modules directory
- , path.join(os.programdir(), "modules") -- load module from the extension modules directory
- , path.join(os.programdir(), "core/sandbox/modules/import") -- load module from the sandbox core modules directory
- }
+ local modules_directories = table.join(rootdir, modules_global_dir, modules_program_dir, modules_sandbox_dir)
-- load module
local errors = nil
diff --git a/xmake/core/sandbox/modules/import/core/project/global.lua b/xmake/core/sandbox/modules/import/core/base/global.lua
index 6cd890d63..925fcbf78 100644
--- a/xmake/core/sandbox/modules/import/core/project/global.lua
+++ b/xmake/core/sandbox/modules/import/core/base/global.lua
@@ -23,37 +23,31 @@
--
-- define module
-local sandbox_core_project_global = sandbox_core_project_global or {}
+local sandbox_core_base_global = sandbox_core_base_global or {}
-- load modules
local table = require("base/table")
-local global = require("project/global")
+local global = require("base/global")
local platform = require("platform/platform")
local raise = require("sandbox/modules/raise")
-- get the configure
-function sandbox_core_project_global.get(name)
-
- -- get it
+function sandbox_core_base_global.get(name)
return global.get(name)
end
-- set the configure
-function sandbox_core_project_global.set(name, value)
-
- -- set it
+function sandbox_core_base_global.set(name, value)
global.set(name, value)
end
-- dump the configure
-function sandbox_core_project_global.dump()
-
- -- dump it
+function sandbox_core_base_global.dump()
global.dump()
end
-- load the configure
-function sandbox_core_project_global.load()
+function sandbox_core_base_global.load()
-- load it
local ok, errors = global.load()
@@ -63,7 +57,7 @@ function sandbox_core_project_global.load()
end
-- save the configure
-function sandbox_core_project_global.save()
+function sandbox_core_base_global.save()
-- save it
local ok, errors = global.save()
@@ -73,14 +67,12 @@ function sandbox_core_project_global.save()
end
-- init the configure
-function sandbox_core_project_global.init()
-
- -- init it
+function sandbox_core_base_global.init()
global.init()
end
-- check the configure
-function sandbox_core_project_global.check()
+function sandbox_core_base_global.check()
-- check all platforms with the current host
for _, plat in ipairs(table.wrap(platform.plats())) do
@@ -111,14 +103,12 @@ function sandbox_core_project_global.check()
end
-- get all options
-function sandbox_core_project_global.options()
-
- -- get it
+function sandbox_core_base_global.options()
return global.options()
end
-- get the configure directory
-function sandbox_core_project_global.directory()
+function sandbox_core_base_global.directory()
-- get it
local dir = global.directory()
@@ -130,4 +120,4 @@ end
-- return module
-return sandbox_core_project_global
+return sandbox_core_base_global
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua
index 164d79fe0..c78185a5a 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -101,22 +101,16 @@ end
-- get the project file
function sandbox_core_project.file()
-
- -- get it
return project.file()
end
-- get the project directory
function sandbox_core_project.directory()
-
- -- get it
return project.directory()
end
-- get the project mtimes
function sandbox_core_project.mtimes()
-
- -- get it
return project.mtimes()
end
diff --git a/xmake/platforms/windows/environment.lua b/xmake/platforms/windows/environment.lua
index 11c9a6534..961be68b8 100644
--- a/xmake/platforms/windows/environment.lua
+++ b/xmake/platforms/windows/environment.lua
@@ -24,7 +24,7 @@
-- imports
import("core.project.config")
-import("core.project.global")
+import("core.base.global")
-- enter the given environment
function _enter(name)