summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-10-12 22:33:34 +0800
committerruki <[email protected]>2018-10-12 09:21:29 +0800
commit0cc1abf8bb6bfb42b206b5e0f3330dc38cb36b1d (patch)
treeddc5d9d04c9b82f40bde0ac317ee2b90720fdf19
parent93e2e7a6d2aec177bb9be54df708d3c5b26cf0a3 (diff)
add set_config
-rw-r--r--CHANGELOG.md6
-rw-r--r--xmake/core/project/project.lua11
2 files changed, 15 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ab5fad9a..0c0ab6f4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,8 @@
### New features
* Support fasm assembler
-* Add `has_config`, `get_config` and `is_config` apis
+* Add `has_config`, `get_config`, and `is_config` apis
+* Add `set_config` to set the default configuration
* Add `$ xmake --try` to try building project using third-party buildsystem
* Add `set_enabled(false)` to disable target
* [#69](https://github.com/tboox/xmake/issues/69): Add remote package management, `add_requires("tbox ~1.6.1")`
@@ -487,7 +488,8 @@
### 新特性
* 新增fasm汇编器支持
-* 添加`has_config`, `get_config`和`is_config`接口去快速判断option和配置值
+* 添加`has_config`, `get_config`, ``和`is_config`接口去快速判断option和配置值
+* 添加`set_config`接口去设置默认配置
* 添加`$ xmake --try`去尝试构建工程
* 添加`set_enabled(false)`去显示的禁用target
* [#69](https://github.com/tboox/xmake/issues/69): 添加远程依赖包管理, `add_requires("tbox ~1.6.1")`
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index e63c25149..1386ebc26 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -108,6 +108,13 @@ function project._api_has_config(interp, ...)
return config.has(...)
end
+-- set config from the given name
+function project._api_set_config(interp, name, value)
+ if not config.readonly(name) then
+ config.set(name, value)
+ end
+end
+
-- get config from the given name
function project._api_get_config(interp, name)
return config.get(name)
@@ -205,7 +212,11 @@ function project.interpreter()
, {"is_plat", project._api_is_plat }
, {"is_arch", project._api_is_arch }
, {"is_config", project._api_is_config }
+ -- set_xxx
+ , {"set_config", project._api_set_config }
+ -- get_xxx
, {"get_config", project._api_get_config }
+ -- has_xxx
, {"has_config", project._api_has_config }
-- add_xxx
, {"add_moduledirs", project._api_add_moduledirs }