From 96e0ba81e20fa68d973ac84c01ead139118c072a Mon Sep 17 00:00:00 2001
From: ruki
+This interface is not only able to determine the custom options defined through the [option](#option),
+but also to determine the built-in global and local configuration.
+
-This interface is not only able to determine the custom options defined through the [option](#option), -but also to determine the built-in global and local configuration. -
- #### Global Interfaces The global interface affects the whole project description scope and all sub-project files. diff --git a/zh/manual.md b/zh/manual.md index ba5ab285..3236b4f3 100644 --- a/zh/manual.md +++ b/zh/manual.md @@ -258,44 +258,6 @@ if is_option("demo") then end ``` -##### has_config - -###### 判断配置是否启用或者存在 - -此接口从2.2.2版本开始引入,用于检测自定义或者内置的编译配置是否存在或启用。 - -例如以下配置情况,都会返回true: - -```console -# 启用某个配置选项(如果是boolean类型配置) -$ xmake f --test1=y -$ xmake f --test1=yes -$ xmake f --test1=true - -# 设置某个配置选项的值 -$ xmake f --test2=value -``` - -```lua --- 如果test1或者test2被设置或者启用 -if has_config("test1", "test2") then - add_defines("TEST") -end -``` - -而下面的情况则会禁用配置,返回false: - -```console -# 禁用配置(如果是boolean类型配置) -$ xmake f --test1=n -$ xmake f --test1=no -$ xmake f --test1=false -``` - --此接口不仅能够判断内置的全局配置、本地配置,同时还可以判断通过[option](#option)定义的自定义配置选项。 -
- ##### is_config ###### 判断指定配置是否为给定的值 @@ -334,6 +296,44 @@ end 此接口不仅能够判断通过[option](#option)定义的自定义配置选项,同时还能判断内置的全局配置、本地配置。 +##### has_config + +###### 判断配置是否启用或者存在 + +此接口从2.2.2版本开始引入,用于检测自定义或者内置的编译配置是否存在或启用。 + +例如以下配置情况,都会返回true: + +```console +# 启用某个配置选项(如果是boolean类型配置) +$ xmake f --test1=y +$ xmake f --test1=yes +$ xmake f --test1=true + +# 设置某个配置选项的值 +$ xmake f --test2=value +``` + +```lua +-- 如果test1或者test2被设置或者启用 +if has_config("test1", "test2") then + add_defines("TEST") +end +``` + +而下面的情况则会禁用配置,返回false: + +```console +# 禁用配置(如果是boolean类型配置) +$ xmake f --test1=n +$ xmake f --test1=no +$ xmake f --test1=false +``` + ++此接口不仅能够判断内置的全局配置、本地配置,同时还可以判断通过[option](#option)定义的自定义配置选项。 +
+ #### 全局接口 全局接口影响整个工程描述,被调用后,后面被包含进来的所有子`xmake.lua`都会受影响。 -- cgit v1.2.3