diff options
| author | ruki <waruqi@gmail.com> | 2019-06-19 16:14:43 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-19 16:14:43 +0800 |
| commit | ea389f3a7e36cf38bc24bb9a7b18de6984b6a05f (patch) | |
| tree | 4d8850964274961c23008e0854b678272ffdf060 /zh/manual.md | |
| parent | 1e3bf498456a76a11592c30d8952d11277def5ac (diff) | |
| parent | 12861845da4bd86278b049f026e6698ffeb336d1 (diff) | |
| download | xmake-docs-docute.tar.gz xmake-docs-docute.zip | |
Merge pull request #9 from OpportunityLiu/masterdocute
add splitenv & utils.dump
Diffstat (limited to 'zh/manual.md')
| -rw-r--r-- | zh/manual.md | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/zh/manual.md b/zh/manual.md index 38c718e4..5aa6bb15 100644 --- a/zh/manual.md +++ b/zh/manual.md @@ -5393,7 +5393,7 @@ import("core.platform.platform", {alias = "p"}) function main() -- 这样我们就可以使用p来调用platform模块的plats接口,获取所有xmake支持的平台列表了 - table.dump(p.plats()) + utils.dump(p.plats()) end ``` @@ -6341,7 +6341,7 @@ local data = io.load("xxx.txt") if data then -- 在终端中dump打印整个table中内容,格式化输出 - table.dump(data) + utils.dump(data) end ``` @@ -6452,6 +6452,7 @@ io.printf("xxx.txt", "hello %s!\n", "xmake") | [path.relative](#path-relative) | 转换成相对路径 | >= 2.0.1 | | [path.absolute](#path-absolute) | 转换成绝对路径 | >= 2.0.1 | | [path.is_absolute](#path-is_absolute) | 判断是否为绝对路径 | >= 2.0.1 | +| [path.splitenv](#path-splitenv) | 分割环境变量中的路径 | >= 2.2.7 | ###### path.join @@ -6569,6 +6570,24 @@ if path.is_absolute("/tmp/file.txt") then end ``` +###### path.splitenv + +- 分割环境变量中的路径 + +```lua +local pathes = path.splitenv(vformat("$(env PATH)")) + +-- for windows +local pathes = path.splitenv("C:\\Windows;C:\\Windows\\System32") +-- got { "C:\\Windows", "C:\\Windows\\System32" } + +-- for *nix +local pathes = path.splitenv("/usr/bin:/usr/local/bin") +-- got { "/usr/bin", "/usr/local/bin" } +``` + +结果为一个包含了输入字符串中路径的数组。 + ##### table table属于lua原生提供的模块,对于原生接口使用可以参考:[lua官方文档](https://www.lua.org/manual/5.1/manual.html#5.5) @@ -6579,7 +6598,6 @@ xmake中对其进行了扩展,增加了一些扩展接口: | ----------------------------------------------- | -------------------------------------------- | -------- | | [table.join](#table-join) | 合并多个table并返回 | >= 2.0.1 | | [table.join2](#table-join2) | 合并多个table到第一个table | >= 2.0.1 | -| [table.dump](#table-dump) | 输出table的所有内容 | >= 2.0.1 | | [table.unique](#table-unique) | 对table中的内容进行去重 | >= 2.0.1 | | [table.slice](#table-slice) | 获取table的切片 | >= 2.0.1 | @@ -6616,18 +6634,6 @@ table.join2(t, {1, 2, 3}) 结果为:`t = {0, 9, 1, 2, 3}` -###### table.dump - -- 输出table的所有内容 - -递归格式化打印table中的所有内容,一般用于调试, 例如: - -```lua -table.dump({1, 2, 3}) -``` - -结果为:`{1, 2, 3}` - ###### table.unique - 对table中的内容进行去重 @@ -6829,6 +6835,20 @@ for _, procinfo in ipairs(process.waitlist(procs, -1)) do end ``` +##### utils + +###### utils.dump + +- 输出所有内容 + +递归格式化打印输入参数中的所有内容,一般用于调试,例如: + +```lua +utils.dump({1, 2, 3}) +``` + +结果为:`{1, 2, 3}` + ##### coroutine 协程模块是lua原生自带的模块,具使用见:[lua官方手册](https://www.lua.org/manual/5.1/manual.html#5.2) @@ -7750,7 +7770,7 @@ print(platform.get("archs")) -- 获取指定iphoneos平台的目标文件格式信息 local formats = platform.get("formats", "iphoneos") -table.dump(formats) +utils.dump(formats) ``` 具体有哪些可读的平台配置信息,可参考:[platform](#platform) |
