summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-23 11:19:33 +0800
committerruki <[email protected]>2020-02-23 11:54:26 +0800
commit9d34862fe5c82c7ac7e8d6dd8a1d951b3f1ed46c (patch)
tree3f34a71e6b7a72ca8750f05acfa5a7a6f6739fdc /xmake/core
parentabffcefe13ed5867a9c340214baa431795e4857f (diff)
regenerate build.ninja
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/base/interpreter.lua25
-rw-r--r--xmake/core/project/project.lua22
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua11
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/cache.lua2
4 files changed, 34 insertions, 26 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index c7f1d42ba..579ffec46 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -639,6 +639,7 @@ function interpreter.new()
local instance = { _PUBLIC = {}
, _PRIVATE = { _SCOPES = {}
, _MTIMES = {}
+ , _SCRIPT_FILES = {}
, _FILTER = require("base/filter").new()}}
-- inherit the interfaces of interpreter
@@ -711,6 +712,7 @@ function interpreter:load(file, opt)
-- init the current file
self._PRIVATE._CURFILE = file
+ self._PRIVATE._SCRIPT_FILES = {file}
-- init the root directory
self._PRIVATE._ROOTDIR = path.directory(file)
@@ -737,43 +739,33 @@ function interpreter:make(scope_kind, remove_repeat, enable_filter)
return results
end
+-- get all loaded script files (xmake.lua)
+function interpreter:scriptfiles()
+ assert(self and self._PRIVATE)
+ return self._PRIVATE._SCRIPT_FILES
+end
+
-- get mtimes
function interpreter:mtimes()
-
- -- check
assert(self and self._PRIVATE)
-
- -- get mtimes
return self._PRIVATE._MTIMES
end
-- get filter
function interpreter:filter()
-
- -- check
assert(self and self._PRIVATE)
-
- -- get it
return self._PRIVATE._FILTER
end
-- get root directory
function interpreter:rootdir()
-
- -- check
assert(self and self._PRIVATE)
-
- -- get it
return self._PRIVATE._ROOTDIR
end
-- set root directory
function interpreter:rootdir_set(rootdir)
-
- -- check
assert(self and self._PRIVATE and rootdir)
-
- -- set it
self._PRIVATE._ROOTDIR = rootdir
end
@@ -1545,6 +1537,7 @@ function interpreter:api_builtin_includes(...)
-- update the current file
self._PRIVATE._CURFILE = file
+ table.insert(self._PRIVATE._SCRIPT_FILES, file)
-- load the file script
local script, errors = loadfile(file)
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 2511e3554..bc73dc55b 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -293,11 +293,21 @@ function project.interpreter()
return interp
end
--- get the project file
-function project.file()
+-- get the root project file
+function project.rootfile()
return os.projectfile()
end
+-- get all loaded project files with subfiles (xmake.lua)
+function project.allfiles()
+ local rcfile = project.rcfile()
+ if rcfile and os.isfile(rcfile) then
+ return table.join(project.interpreter():scriptfiles(), rcfile)
+ else
+ return project.interpreter():scriptfiles()
+ end
+end
+
-- get the global rcfile: ~/.xmakerc.lua
function project.rcfile()
local xmakerc = project._XMAKE_RCFILE
@@ -352,7 +362,7 @@ function project._load(force, disable_filter)
local interp = project.interpreter()
-- load script
- local ok, errors = interp:load(project.file(), {on_load_data = function (data)
+ local ok, errors = interp:load(project.rootfile(), {on_load_data = function (data)
local xmakerc_file = project.rcfile()
if xmakerc_file and os.isfile(xmakerc_file) then
local rcdata = io.readfile(xmakerc_file)
@@ -446,7 +456,7 @@ end
function project._load_tasks()
-- the project file is not found?
- if not os.isfile(project.file()) then
+ if not os.isfile(project.rootfile()) then
return {}, nil
end
@@ -620,7 +630,7 @@ end
function project._load_options(disable_filter)
-- the project file is not found?
- if not os.isfile(project.file()) then
+ if not os.isfile(project.rootfile()) then
return {}, nil
end
@@ -932,7 +942,7 @@ function project.menu()
-- attempt to load options from the project file
local options = nil
local errors = nil
- if os.isfile(project.file()) then
+ if os.isfile(project.rootfile()) then
options, errors = project._load_options(true)
end
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua
index 3f197f3b3..67119ec98 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -138,9 +138,14 @@ function sandbox_core_project.options()
return project.options()
end
--- get the project file
-function sandbox_core_project.file()
- return project.file()
+-- get the root project file
+function sandbox_core_project.rootfile()
+ return project.rootfile()
+end
+
+-- get the all loaded project files
+function sandbox_core_project.allfiles()
+ return project.allfiles()
end
-- get the project rcfile
diff --git a/xmake/core/sandbox/modules/import/lib/detect/cache.lua b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
index 2cf1460e3..cf8a78192 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/cache.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
@@ -36,7 +36,7 @@ local raise = require("sandbox/modules/raise")
function sandbox_lib_detect_cache._instance()
-- get it
- local detectcache = sandbox_lib_detect_cache._INSTANCE or cache(utils.ifelse(os.isfile(project.file()), "local.detect", "memory.detect"))
+ local detectcache = sandbox_lib_detect_cache._INSTANCE or cache(utils.ifelse(os.isfile(project.rootfile()), "local.detect", "memory.detect"))
sandbox_lib_detect_cache._INSTANCE = detectcache
return detectcache
end