summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/actions/config/main.lua10
-rw-r--r--xmake/core/project/project.lua38
2 files changed, 39 insertions, 9 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 21994603f..625526e51 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -148,11 +148,6 @@ function main()
if _g.configured then return end
_g.configured = true
- -- enter menu config
- if option.get("menu") then
- menuconf_show()
- end
-
-- scan project and generate it if xmake.lua not exists
if not os.isfile(project.file()) then
@@ -180,6 +175,11 @@ function main()
scangen()
end
+ -- enter menu config
+ if option.get("menu") then
+ menuconf_show()
+ end
+
-- the target name
local targetname = option.get("target") or "all"
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index de22b200f..4d5c67dab 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -316,7 +316,12 @@ function project.get(name)
end
-- load the project file
-function project._load()
+function project._load(force)
+
+ -- has already been loaded?
+ if project._INFO and not force then
+ return true
+ end
-- enter the project directory
local oldir, errors = os.cd(os.projectdir())
@@ -403,7 +408,7 @@ function project._load_tasks()
end
-- load the project file first
- local ok, errors = project._load()
+ local ok, errors = project._load(true)
if not ok then
return nil, errors
end
@@ -430,6 +435,12 @@ end
-- load rules
function project._load_rules()
+
+ -- load the project file first if has not been loaded?
+ local ok, errors = project._load()
+ if not ok then
+ return nil, errors
+ end
-- load the rules from the the project file
local results, errors = project._load_scope("rule", true, true)
@@ -458,7 +469,7 @@ function project._load_targets()
-- load all requires first and reload the project file to ensure has_package() works for targets
local requires = project.requires()
- local ok, errors = project._load()
+ local ok, errors = project._load(true)
if not ok then
return nil, errors
end
@@ -549,6 +560,17 @@ end
-- load options
function project._load_options(disable_filter)
+ -- the project file is not found?
+ if not os.isfile(project.file()) then
+ return {}, nil
+ end
+
+ -- load the project file first if has not been loaded?
+ local ok, errors = project._load()
+ if not ok then
+ return nil, errors
+ end
+
-- load the options from the the project file
local results, errors = project._load_scope("option", true, not disable_filter)
if not results then
@@ -646,6 +668,14 @@ end
-- load the packages from the the project file and disable filter, we will process filter after a while
function project._load_packages()
+
+ -- load the project file first if has not been loaded?
+ local ok, errors = project._load()
+ if not ok then
+ return nil, errors
+ end
+
+ -- load packages
return project._load_scope("package", true, false)
end
@@ -728,7 +758,7 @@ function project.requires_str()
if not project._REQUIRES_STR then
-- reload the project file to handle `has_config()`
- local ok, errors = project._load()
+ local ok, errors = project._load(true)
if not ok then
os.raise(errors)
end