diff options
| author | ruki <[email protected]> | 2020-10-26 22:47:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-26 22:47:51 +0800 |
| commit | fa86786f0680ca5c5c49a8160163fe41fd9fbec5 (patch) | |
| tree | 81c9fe89938a3d1142070eb63089ddf8a8c59004 | |
| parent | 627995a780821397db57702b6028f624b5aa3b58 (diff) | |
fix menuconf bug
| -rw-r--r-- | xmake/actions/config/main.lua | 5 | ||||
| -rw-r--r-- | xmake/actions/config/menuconf.lua | 7 | ||||
| -rw-r--r-- | xmake/actions/config/xmake.lua | 13 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 1 |
5 files changed, 26 insertions, 10 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index b45539061..0488d3882 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -123,6 +123,7 @@ end -- check target function _check_target(targetname) assert(targetname) + assert(not project.is_loaded(), "project and targets may have been loaded early!") if targetname == "all" then for _, target in pairs(project.targets()) do _check_target_deps(target) @@ -165,8 +166,9 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) project.lock() -- enter menu config + local options_changed = false if option.get("menu") then - menuconf_show() + options_changed = menuconf_show() end -- the target name @@ -190,7 +192,6 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end -- override configure from the options or cache - local options_changed = false local options_history = {} if not option.get("clean") and not autogen then options_history = configcache:get("options") or {} diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua index c4ef20328..9dd931d56 100644 --- a/xmake/actions/config/menuconf.lua +++ b/xmake/actions/config/menuconf.lua @@ -337,6 +337,11 @@ function app:_save_configs(configs) end end +-- configs have been changed? +function app:_configs_changed() + return self._CONFIGS_CHANGED +end + -- load configs from options function app:load(cache) @@ -365,9 +370,11 @@ end function app:save() self:_save_configs(self:_basic_configs()) self:_save_configs(self:_project_configs()) + self._CONFIGS_CHANGED = true end -- main entry function main(...) app:run(...) + return app:_configs_changed() end diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index f8d784d18..871070821 100644 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -106,15 +106,12 @@ task("config") end } , {'m', "mode", "kv", "release" , "Compile for the given mode." , values = function (complete) - - local modes = (try { function() - return import("core.project.project").modes() - end }) or {"debug", "release"} - table.sort(modes) - if not complete then - table.insert(modes, "... (custom)") + if complete then + local modes = (try { function() + return import("core.project.project").modes() + end }) or {"debug", "release"} + return modes end - return modes end } , {'k', "kind", "kv", "static" , "Compile for the given target kind." , values = {"static", "shared", "binary"} } diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 33d8d4233..b7f76300f 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -346,6 +346,11 @@ end -- load targets function project._load_targets() + -- mark targets have been loaded even if it may fail to load. + -- because once loaded, there will be some cached state, such as options, + -- so if we load it a second time, there will be some hidden state inconsistencies. + project._TARGETS_LOADED = true + -- 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(true) @@ -886,6 +891,11 @@ function project.clear() project._OPTIONS = nil end +-- project has been loaded? +function project.is_loaded() + return project._TARGETS_LOADED +end + -- get the given target function project.target(name) return project.targets()[name] diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 775e6115a..a6753ef09 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -61,6 +61,7 @@ sandbox_core_project.requires_str = project.requires_str sandbox_core_project.policy = project.policy sandbox_core_project.tmpdir = project.tmpdir sandbox_core_project.tmpfile = project.tmpfile +sandbox_core_project.is_loaded = project.is_loaded -- load project function sandbox_core_project.load() |
