Răsfoiți Sursa

add splitenv & utils.dump

OpportunityLiu 6 ani în urmă
părinte
comite
e09145ba19
4 a modificat fișierele cu 74 adăugiri și 34 ștergeri
  1. 1 1
      README.md
  2. 36 16
      old/manual.md
  3. 36 16
      old/zh/manual.md
  4. 1 1
      zh-cn/README.md

+ 1 - 1
README.md

@@ -431,7 +431,7 @@ target("cuda_console")
 ```
 
 <p class="tip">
-Starting with v2.2.7, the default build will enable device-link, @see https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/
+Starting with v2.2.7, the default build will enable device-link. (see [Separate Compilation and Linking of CUDA C++ Device Code](https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/))
 If you want to disable device-link, you can set it with `add_values("cuda.devlink", false)`.
 </p>
 

+ 36 - 16
old/manual.md

@@ -5315,7 +5315,7 @@ import("core.platform.platform", {alias = "p"})
 function main()
 
     -- So we can use p to call the plats interface of the platform module to get a list of all the platforms supported by xmake.
-    table.dump(p.plats())
+    utils.dump(p.plats())
 end
 ```
 
@@ -6263,7 +6263,7 @@ local data = io.load("xxx.txt")
 if data then
 
     -- Dump prints the contents of the entire table in the terminal, formatting the output
-    table.dump(data)
+    utils.dump(data)
 end
 ```
 
@@ -6374,6 +6374,7 @@ The path operation module implements cross-platform path operations, which is a
 | [path.relative](#path-relative) | Convert to relative path | >= 2.0.1 |
 | [path.absolute](#path-absolute) | Convert to Absolute Path | >= 2.0.1 |
 | [path.is_absolute](#path-is_absolute) | Determine if it is an absolute path | >= 2.0.1 |
+| [path.splitenv](#path-splitenv) | Split a envienment variable value of an array of pathes | >= 2.2.7 |
 
 ###### path.join
 
@@ -6489,6 +6490,24 @@ if path.is_absolute("/tmp/file.txt") then
 end
 ```
 
+###### path.splitenv
+
+- Split a envienment variable value of an array of pathes
+
+```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" }
+```
+
+The result is an array of strings, each item is a path in the input string.
+
 ##### table
 
 Table belongs to the module provided by Lua native. For the native interface, you can refer to: [lua official document](https://www.lua.org/manual/5.1/manual.html#5.5)
@@ -6499,7 +6518,6 @@ It has been extended in xmake to add some extension interfaces:
 | ----------------------------------------------- | -------------------------------------------- | -------- |
 | [table.join](#table-join) | Merge multiple tables and return | >= 2.0.1 |
 | [table.join2](#table-join2) | Merge multiple tables into the first table | >= 2.0.1 |
-| [table.dump](#table-dump) | Output all contents of table | >= 2.0.1 |
 | [table.unique](#table-unique) | Deduplicate the contents of the table | >= 2.0.1 |
 | [table.slice](#table-slice) | Get the slice of the table | >= 2.0.1 |
 
@@ -6536,18 +6554,6 @@ table.join2(t, {1, 2, 3})
 
 The result is: `t = {0, 9, 1, 2, 3}`
 
-###### table.dump
-
-- Output all contents of the table
-
-Recursively format all the contents of the printed table, generally used for debugging, for example:
-
-```lua
-table.dump({1, 2, 3})
-```
-
-The result is: `{1, 2, 3}`
-
 ###### table.unique
 
 - Deduplicate the contents of the table
@@ -6745,6 +6751,20 @@ for _, procinfo in ipairs(process.waitlist(procs, -1)) do
 end
 ```
 
+##### utils
+
+###### utils.dump
+
+- Output all contents of the value
+
+Recursively format all the contents of the printed value, generally used for debugging, for example:
+
+```lua
+utils.dump({1, 2, 3})
+```
+
+The result is: `{1, 2, 3}`
+
 ##### coroutine
 
 The coroutine module is a native module of lua. For use, see: [lua official manual](https://www.lua.org/manual/5.1/manual.html#5.2)
@@ -7660,7 +7680,7 @@ print(platform.get("archs"))
 
 -- Get the target file format information of the specified iphoneos platform
 local formats = platform.get("formats", "iphoneos")
-table.dump(formats)
+utils.dump(formats)
 ```
 
 For specific readable platform configuration information, please refer to: [platform](#platform)

+ 36 - 16
old/zh/manual.md

@@ -5389,7 +5389,7 @@ import("core.platform.platform", {alias = "p"})
 function main()
  
     -- 这样我们就可以使用p来调用platform模块的plats接口,获取所有xmake支持的平台列表了
-    table.dump(p.plats())
+    utils.dump(p.plats())
 end
 ```
 
@@ -6337,7 +6337,7 @@ local data = io.load("xxx.txt")
 if data then
 
     -- 在终端中dump打印整个table中内容,格式化输出
-    table.dump(data)
+    utils.dump(data)
 end
 ```
 
@@ -6448,6 +6448,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
 
@@ -6565,6 +6566,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)
@@ -6575,7 +6594,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 |
 
@@ -6612,18 +6630,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中的内容进行去重
@@ -6825,6 +6831,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)
@@ -7746,7 +7766,7 @@ print(platform.get("archs"))
 
 -- 获取指定iphoneos平台的目标文件格式信息
 local formats = platform.get("formats", "iphoneos")
-table.dump(formats)
+utils.dump(formats)
 ```
 
 具体有哪些可读的平台配置信息,可参考:[platform](#platform)

+ 1 - 1
zh-cn/README.md

@@ -460,7 +460,7 @@ target("cuda_console")
 ```
 
 <p class="tip">
-从v2.2.7版本开始,默认构建会启用device-link,@see https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/
+从v2.2.7版本开始,默认构建会启用device-link。(参见 [Separate Compilation and Linking of CUDA C++ Device Code](https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/))
 如果要显示禁用device-link,可以通过`add_values("cuda.devlink", false)` 来设置。
 </p>