summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/_xmake_main.lua5
-rw-r--r--xmake/core/base/interpreter.lua2
-rw-r--r--xmake/core/base/string.lua7
-rw-r--r--xmake/core/project/template.lua8
-rw-r--r--xmake/core/sandbox/modules/import.lua6
-rw-r--r--xmake/core/sandbox/modules/os.lua7
-rw-r--r--xmake/core/sandbox/sandbox.lua2
7 files changed, 10 insertions, 27 deletions
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua
index 39bb5f225..58af78d66 100644
--- a/xmake/core/_xmake_main.lua
+++ b/xmake/core/_xmake_main.lua
@@ -33,13 +33,10 @@ xmake._VERSION_SHORT = _VERSION_SHORT
xmake._PROGRAM_DIR = _PROGRAM_DIR
xmake._PROGRAM_FILE = _PROGRAM_FILE
xmake._PROJECT_DIR = _PROJECT_DIR
-xmake._CORE_DIR = _PROGRAM_DIR .. "/core"
-xmake._TOOLS_DIR = _PROGRAM_DIR .. "/tools"
-xmake._TEMPLATES_DIR = _PROGRAM_DIR .. "/templates"
xmake._PROJECT_FILE = "xmake.lua"
-- init package path
-package.path = xmake._CORE_DIR .. "/?.lua;" .. package.path
+package.path = xmake._PROGRAM_DIR .. "/core/?.lua;" .. package.path
-- load modules
local main = require("main")
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 5c51b35e4..c23fa8457 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -700,7 +700,7 @@ function interpreter.new()
instance:api_register(nil, "set_xmakever", interpreter.api_builtin_set_xmakever)
-- load builtin module files
- local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/modules/interpreter/*.lua"))
+ local builtin_module_files = os.match(path.join(os.programdir(), "core/sandbox/modules/interpreter/*.lua"))
if builtin_module_files then
for _, builtin_module_file in ipairs(builtin_module_files) do
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua
index f54f7b1a3..97945851e 100644
--- a/xmake/core/base/string.lua
+++ b/xmake/core/base/string.lua
@@ -131,13 +131,6 @@ function string.join(items, sep)
return str
end
--- less than
-function string:less(other)
-
- -- < ?
- return string.strcmp(self, other) < 0
-end
-
-- try to format
function string.tryformat(format, ...)
diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua
index a306bf622..cbc1551a8 100644
--- a/xmake/core/project/template.lua
+++ b/xmake/core/project/template.lua
@@ -90,7 +90,7 @@ function template._replace(macros, macrofiles)
-- make all files
local files = {}
for _, macrofile in ipairs(table.wrap(macrofiles)) do
- local matchfiles = os.match(macrofile)
+ local matchfiles = os.files(macrofile)
if matchfiles then
table.join2(files, matchfiles)
end
@@ -114,7 +114,7 @@ function template.languages()
local list = {}
-- get the language list
- local languages = os.match(xmake._TEMPLATES_DIR .. "/*", true)
+ local languages = os.dirs(path.join(os.programdir(), "templates", "*"))
if languages then
for _, v in ipairs(languages) do
table.insert(list, path.basename(v))
@@ -137,7 +137,7 @@ function template.templates(language)
-- load all templates
local templates = {}
- local templatefiles = os.match(string.format("%s/%s/**/template.lua", xmake._TEMPLATES_DIR, language))
+ local templatefiles = os.files(path.join(os.programdir(), "templates", language, "**", "template.lua"))
if templatefiles then
-- load template
@@ -159,7 +159,7 @@ function template.templates(language)
end
-- sort templates
- table.sort(templates, function(a, b) return a.description:less(b.description) end)
+ table.sort(templates, function(a, b) return a.description < b.description end)
-- ok?
return templates
diff --git a/xmake/core/sandbox/modules/import.lua b/xmake/core/sandbox/modules/import.lua
index 885378750..a18a5231b 100644
--- a/xmake/core/sandbox/modules/import.lua
+++ b/xmake/core/sandbox/modules/import.lua
@@ -300,7 +300,7 @@ function sandbox_import.import(name, args)
assert(rootdir)
-- the sandbox modules directory
- local modules_sandbox_dir = path.join(xmake._CORE_DIR, "sandbox/modules/import")
+ local modules_sandbox_dir = path.join(os.programdir(), "core/sandbox/modules/import")
-- the extension modules directory
local modules_extension_dir = path.join(os.programdir(), "modules")
@@ -313,8 +313,8 @@ function sandbox_import.import(name, args)
{
rootdir -- load module from the given root directory first
, path.join(global.directory(), "modules") -- load module from the user global modules directory
- , path.join(xmake._PROGRAM_DIR, "modules") -- load module from the extension modules directory
- , path.join(xmake._CORE_DIR, "sandbox/modules/import") -- load module from the sandbox core 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
}
-- load module
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 657364cb2..089f42d7e 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -224,13 +224,6 @@ function sandbox_os.tmpfile()
return tmpfile
end
--- get the tools directory
-function sandbox_os.toolsdir()
-
- -- get it
- return xmake._TOOLS_DIR
-end
-
-- get the script directory
function sandbox_os.scriptdir()
diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua
index 77b7003e2..222312b1c 100644
--- a/xmake/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/sandbox.lua
@@ -107,7 +107,7 @@ function sandbox._new()
table.inherit2(instance, sandbox)
-- load builtin module files
- local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/modules/*.lua"))
+ local builtin_module_files = os.match(path.join(os.programdir(), "core/sandbox/modules/*.lua"))
if builtin_module_files then
for _, builtin_module_file in ipairs(builtin_module_files) do