diff options
| author | ruki <[email protected]> | 2021-07-20 22:47:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-07-20 22:47:58 +0800 |
| commit | 801cc4d75f3aee6f845f69e9be7c55d70614071c (patch) | |
| tree | 2d99f35493aa1f63e5335fa6ca5dae31dbf7b2fb /xmake/actions/config/main.lua | |
| parent | 4451461655f1f725aa1667a9287fb9a0367c291b (diff) | |
set allowed modes and archs
Diffstat (limited to 'xmake/actions/config/main.lua')
| -rw-r--r-- | xmake/actions/config/main.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 68f8ab531..d96f32a9e 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -191,6 +191,47 @@ function _config_targets(targetname) end end +-- find default mode +function _find_default_mode() + local mode = config.mode() + if not mode then + local allowedmodes = table.wrap(project.get("allowedmodes")) + if #allowedmodes > 0 then + mode = allowedmodes[1] + end + if not mode then + mode = "release" + end + config.set("mode", mode) + end + return mode +end + +-- check configs +function _check_configs() + -- check allowed modes + local mode = config.mode() + local allowedmodes = table.wrap(project.get("allowedmodes")) + if #allowedmodes > 0 then + local allowedmodes_set = hashset.from(allowedmodes) + if not allowedmodes_set:has(mode) then + local allowedmodes_str = table.concat(allowedmodes, ", ") + raise("`%s` is not a valid complation mode for this project, please use one of %s", mode, allowedmodes_str) + end + end + + -- check allowed archs + local arch = config.arch() + local allowedarchs = table.wrap(project.get("allowedarchs")) + if #allowedarchs > 0 then + local allowedarchs_set = hashset.from(allowedarchs) + if not allowedarchs_set:has(arch) then + local allowedarchs_str = table.concat(allowedarchs, ", ") + raise("`%s` is not a valid complation arch for this project, please use one of %s", arch, allowedarchs_str) + end + end +end + -- export configs function _export_configs() local exportfile = option.get("export") @@ -309,6 +350,10 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end end + -- find default mode + local mode = _find_default_mode() + assert(mode == config.mode()) + -- find default platform and save to configuration local plat, arch = find_platform({global = true}) assert(plat == config.plat()) @@ -382,6 +427,9 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) config.dump() end + -- check configs + _check_configs() + -- export configs if option.get("export") then _export_configs() |
