summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorruki <[email protected]>2017-03-06 10:03:23 +0800
committerruki <[email protected]>2017-03-06 10:03:23 +0800
commit922adbe45795c0d19ef6465bfeddaa972fddbc5a (patch)
tree14183406a655c0c1e840aaa808a2074934e48d34 /docs
parentf2dffdccfc7f3a8ec92af1f0951953e0e5d22452 (diff)
write config and global api docs
Diffstat (limited to 'docs')
-rw-r--r--docs/manual.md124
-rwxr-xr-xdocs/zh/manual.md124
2 files changed, 248 insertions, 0 deletions
diff --git a/docs/manual.md b/docs/manual.md
index 69933c310..12aea7b08 100644
--- a/docs/manual.md
+++ b/docs/manual.md
@@ -4439,14 +4439,111 @@ print(compiler.compflags(sourcefile, target))
| [config.dump](#config-dump) | 打印输出当前工程的所有配置信息 | >= 2.0.1 |
###### config.get
+
+- 获取指定配置值
+
+用于获取`xmake f|config --xxx=val`的配置值,例如:
+
+```lua
+target("test")
+ on_run(function (target)
+
+ -- 导入配置模块
+ import("core.project.config")
+
+ -- 获取配置值
+ print(config.get("xxx"))
+ end)
+```
+
###### config.load
+
+- 加载配置
+
+一般用于插件开发中,插件任务中不像工程的自定义脚本,环境需要自己初始化加载,默认工程配置是没有被加载的,如果要用[config.get](#config-get)接口获取工程配置,那么需要先:
+
+```lua
+
+-- 导入配置模块
+import("core.project.config")
+
+function main(...)
+
+ -- 先加载工程配置
+ config.load()
+
+ -- 获取配置值
+ print(config.get("xxx"))
+end
+```
+
###### config.arch
+
+- 获取当前工程的架构配置
+
+也就是获取`xmake f|config --arch=armv7`的平台配置,相当于`config.get("arch")`。
+
###### config.plat
+
+- 获取当前工程的平台配置
+
+也就是获取`xmake f|config --plat=iphoneos`的平台配置,相当于`config.get("plat")`。
+
###### config.mode
+
+- 获取当前工程的编译模式配置
+
+也就是获取`xmake f|config --mode=debug`的平台配置,相当于`config.get("mode")`。
+
###### config.buildir
+
+- 获取当前工程的输出目录配置
+
+也就是获取`xmake f|config -o /tmp/output`的平台配置,相当于`config.get("buildir")`。
+
###### config.directory
+
+- 获取当前工程的配置信息目录
+
+获取工程配置的存储目录,默认为:`projectdir/.config`
+
###### config.dump
+- 打印输出当前工程的所有配置信息
+
+输出结果例如:
+
+```lua
+{
+ sh = "xcrun -sdk macosx clang++"
+, xcode_dir = "/Applications/Xcode.app"
+, ar = "xcrun -sdk macosx ar"
+, small = true
+, object = false
+, arch = "x86_64"
+, xcode_sdkver = "10.12"
+, ex = "xcrun -sdk macosx ar"
+, cc = "xcrun -sdk macosx clang"
+, rc = "rustc"
+, plat = "macosx"
+, micro = false
+, host = "macosx"
+, as = "xcrun -sdk macosx clang"
+, dc = "dmd"
+, gc = "go"
+, openssl = false
+, ccache = "ccache"
+, cxx = "xcrun -sdk macosx clang"
+, sc = "xcrun -sdk macosx swiftc"
+, mm = "xcrun -sdk macosx clang"
+, buildir = "build"
+, mxx = "xcrun -sdk macosx clang++"
+, ld = "xcrun -sdk macosx clang++"
+, mode = "release"
+, kind = "static"
+}
+```
+
##### core.project.global
用于获取xmake全局的配置信息,也就是`xmake g|global --xxx=val` 传入的参数选项值。
@@ -4459,10 +4556,37 @@ print(compiler.compflags(sourcefile, target))
| [global.dump](#global-dump) | 打印输出所有全局配置信息 | >= 2.0.1 |
###### global.get
+
+- 获取指定配置值
+
+类似[config.get](#config-get),唯一的区别就是这个是从全局配置中获取。
+
###### global.load
+
+- 加载配置
+
+类似[global.get](#global-get),唯一的区别就是这个是从全局配置中加载。
+
###### global.directory
+
+- 获取全局配置信息目录
+
+默认为`~/.config`目录。
+
###### global.dump
+- 打印输出所有全局配置信息
+
+输出结果如下:
+
+```lua
+{
+ clean = true
+, ccache = "ccache"
+, xcode_dir = "/Applications/Xcode.app"
+}
+```
+
##### core.project.task
用于任务操作,一般用于在自定义脚本中、插件任务中,调用运行其他task任务。
diff --git a/docs/zh/manual.md b/docs/zh/manual.md
index cf74722fc..fa24f81a8 100755
--- a/docs/zh/manual.md
+++ b/docs/zh/manual.md
@@ -4439,14 +4439,111 @@ print(compiler.compflags(sourcefile, target))
| [config.dump](#config-dump) | 打印输出当前工程的所有配置信息 | >= 2.0.1 |
###### config.get
+
+- 获取指定配置值
+
+用于获取`xmake f|config --xxx=val`的配置值,例如:
+
+```lua
+target("test")
+ on_run(function (target)
+
+ -- 导入配置模块
+ import("core.project.config")
+
+ -- 获取配置值
+ print(config.get("xxx"))
+ end)
+```
+
###### config.load
+
+- 加载配置
+
+一般用于插件开发中,插件任务中不像工程的自定义脚本,环境需要自己初始化加载,默认工程配置是没有被加载的,如果要用[config.get](#config-get)接口获取工程配置,那么需要先:
+
+```lua
+
+-- 导入配置模块
+import("core.project.config")
+
+function main(...)
+
+ -- 先加载工程配置
+ config.load()
+
+ -- 获取配置值
+ print(config.get("xxx"))
+end
+```
+
###### config.arch
+
+- 获取当前工程的架构配置
+
+也就是获取`xmake f|config --arch=armv7`的平台配置,相当于`config.get("arch")`。
+
###### config.plat
+
+- 获取当前工程的平台配置
+
+也就是获取`xmake f|config --plat=iphoneos`的平台配置,相当于`config.get("plat")`。
+
###### config.mode
+
+- 获取当前工程的编译模式配置
+
+也就是获取`xmake f|config --mode=debug`的平台配置,相当于`config.get("mode")`。
+
###### config.buildir
+
+- 获取当前工程的输出目录配置
+
+也就是获取`xmake f|config -o /tmp/output`的平台配置,相当于`config.get("buildir")`。
+
###### config.directory
+
+- 获取当前工程的配置信息目录
+
+获取工程配置的存储目录,默认为:`projectdir/.config`
+
###### config.dump
+- 打印输出当前工程的所有配置信息
+
+输出结果例如:
+
+```lua
+{
+ sh = "xcrun -sdk macosx clang++"
+, xcode_dir = "/Applications/Xcode.app"
+, ar = "xcrun -sdk macosx ar"
+, small = true
+, object = false
+, arch = "x86_64"
+, xcode_sdkver = "10.12"
+, ex = "xcrun -sdk macosx ar"
+, cc = "xcrun -sdk macosx clang"
+, rc = "rustc"
+, plat = "macosx"
+, micro = false
+, host = "macosx"
+, as = "xcrun -sdk macosx clang"
+, dc = "dmd"
+, gc = "go"
+, openssl = false
+, ccache = "ccache"
+, cxx = "xcrun -sdk macosx clang"
+, sc = "xcrun -sdk macosx swiftc"
+, mm = "xcrun -sdk macosx clang"
+, buildir = "build"
+, mxx = "xcrun -sdk macosx clang++"
+, ld = "xcrun -sdk macosx clang++"
+, mode = "release"
+, kind = "static"
+}
+```
+
##### core.project.global
用于获取xmake全局的配置信息,也就是`xmake g|global --xxx=val` 传入的参数选项值。
@@ -4459,10 +4556,37 @@ print(compiler.compflags(sourcefile, target))
| [global.dump](#global-dump) | 打印输出所有全局配置信息 | >= 2.0.1 |
###### global.get
+
+- 获取指定配置值
+
+类似[config.get](#config-get),唯一的区别就是这个是从全局配置中获取。
+
###### global.load
+
+- 加载配置
+
+类似[global.get](#global-get),唯一的区别就是这个是从全局配置中加载。
+
###### global.directory
+
+- 获取全局配置信息目录
+
+默认为`~/.config`目录。
+
###### global.dump
+- 打印输出所有全局配置信息
+
+输出结果如下:
+
+```lua
+{
+ clean = true
+, ccache = "ccache"
+, xcode_dir = "/Applications/Xcode.app"
+}
+```
+
##### core.project.task
用于任务操作,一般用于在自定义脚本中、插件任务中,调用运行其他task任务。