Преглед на файлове

improve package sidebar

ruki преди 6 месеца
родител
ревизия
d049bbee98

+ 11 - 5
docs/config.ts

@@ -98,16 +98,22 @@ function guideSidebar(): DefaultTheme.SidebarItem[] {
             { text: 'Using Official Packages', link: 'package-management/using-official-packages' },
             { text: 'Using Third-party Packages', link: 'package-management/using-third-party-packages' },
             { text: 'Using Packages in CMake', link: 'package-management/using-packages-in-cmake' },
-            { text: 'Using Official Packages', link: 'package-management/using-official-packages' },
             { text: 'Package Distribution', link: 'package-management/package-distribution' },
-            { text: 'Package Management Commands', link: 'package-management/package-management-commands' },
-            { text: 'Repository Management Commands', link: 'package-management/repository-management-commands' },
-            { text: 'Xrepo CLI', link: 'package-management/xrepo-cli' },
           ]
         },
         { text: 'Using Local Packages', link: 'package-management/using-local-packages' },
         { text: 'Using System Packages', link: 'package-management/using-system-packages' },
-        { text: 'Using Source code Packages', link: 'package-management/using-source-code-packages' },
+        { text: 'Using Sourcecode Packages', link: 'package-management/using-source-code-packages' },
+        { text: 'Network Optimization', link: 'package-management/network-optimization' },
+        {
+          text: 'CLI',
+          collapsed: true,
+          items: [
+            { text: 'Package Management in Project', link: 'package-management/package-management-in-project' },
+            { text: 'Repository Management', link: 'package-management/repository-management' },
+            { text: 'Xrepo CLI', link: 'package-management/xrepo-cli' },
+          ]
+        },
       ]
     },
     {

+ 110 - 0
docs/guide/package-management/network-optimization.md

@@ -0,0 +1,110 @@
+
+# Network Optimization
+
+If the download package is slow or fails due to an unstable network, we can use the following methods to resolve it.
+
+## Manual Download
+
+By default, xmake will call curl, wget and other tools to download, users can also manually download with their own downloader (you can also use an agent), put the downloaded package in their own directory, for example: `/download/packages/zlib -v1.0.tar.gz`
+
+Then use the following command to set the search directory for package download:
+
+```console
+$ xmake g --pkg_searchdirs="/download/packages"
+```
+
+Then re-execute xmake to compile, xmake will first look for the source package from `/download/packages`, and then use it directly, no longer download it yourself.
+
+As for the package name you are looking for, you can check it by the following command:
+
+```console
+$ xmake require --info zlib
+-> searchdirs: /download/packages
+-> searchnames: zlib-1.2.11.tar.gz
+```
+
+We can see the corresponding search directory and the searched package name.
+
+## Use Proxy
+
+If manual downloading is still troublesome, we can also let xmake go directly to the agent.
+
+```console
+$ xmake g --proxy="socks5://127.0.0.1:1086"
+$ xmake g --help
+    -x PROXY, --proxy=PROXY Use proxy on given port. [PROTOCOL://]HOST[:PORT]
+                                 e.g.
+                                 -xmake g --proxy='http://host:port'
+                                 -xmake g --proxy='https://host:port'
+                                 -xmake g --proxy='socks5://host:port'
+```
+
+The `--proxy` parameter specifies the proxy protocol and address. The specific syntax can refer to curl. Usually, it can support http, https, socks5 and other protocols, but the actual support depends on curl, wget and git. For example, wget does not support the socks5 protocol.
+
+We can use the following parameters to specify which hosts go to the proxy. If not set, the default is to go global.
+
+```console
+--proxy_hosts=PROXY_HOSTS Only enable proxy for the given hosts list, it will enable all if be unset,
+                             and we can pass match pattern to list:
+                                 e.g.
+                                 -xmake g --proxy_hosts='github.com,gitlab.*,*.xmake.io'
+```
+
+If the hosts list is set, then the matching hosts in this list will go to the proxy. .
+
+`--proxy_host` supports multiple hosts settings, separated by commas, and supports basic pattern matching *.github.com, and other lua pattern matching rules are also supported
+
+If we feel that the above hosts mode configuration is not flexible enough, we can also follow pac's automatic proxy configuration rules:
+
+```console
+--proxy_pac=PROXY_PAC Set the auto proxy configuration file. (default: pac.lua)
+                                     e.g.
+                                     -xmake g --proxy_pac=pac.lua (in /Users/ruki/.xmake or absolute path)
+                                     -function main(url, host)
+                                           if host =='github.com' then
+                                                return true
+                                           end
+                                       end
+```
+
+::: tip NOTE
+If there are proxy_hosts, the host configuration is preferred, otherwise, the pac configuration can be used.
+:::
+
+The default path of pac: ~/.xmake/pac.lua, if --proxy is set, and this file exists, it will automatically go to pac. If it does not exist, and there are no hosts, then the proxy will take effect globally.
+
+You can also manually specify the pac full path
+
+```console
+$ xmake g --proxy_pac=/xxxx/xxxxx_pac.lua
+```
+
+Configuration rule description:
+
+```lua
+function main(url, host)
+    if host:find("bintray.com") then
+        return true
+    end
+end
+```
+
+If it returns true, then the url and host are the proxy to go, not to return or return false, it is not to proxy.
+
+For specific details of this piece, see: https://github.com/xmake-io/xmake/issues/854
+
+## Configure Mirror Proxy
+
+After v2.5.4, mirroring proxy rules can also be configured in the pac.lua configuration. For example, access to all github.com domain names is switched to the hub.fastgit.org domain name to achieve accelerated downloading of packages.
+
+```lua
+function mirror(url)
+    return url:gsub("github.com", "hub.fastgit.org")
+end
+```
+
+```console
+$ xrepo install libpng
+> curl https://hub.fastgit.org/glennrp/libpng/archive/v1.6.37.zip -o v1.6.37.zip
+```
+

+ 6 - 11
docs/guide/package-management/package-management-commands.md → docs/guide/package-management/package-management-in-project.md

@@ -1,10 +1,5 @@
----
-outline: deep
----
 
-# Package Management Commands
-
-## xmake require
+# Package Management in Project
 
 The package management command `$ xmake require` can be used to manually display the download, install, uninstall, retrieve, and view package information.
 
@@ -12,7 +7,7 @@ The package management command `$ xmake require` can be used to manually display
 
 For detailed documentation, see: [Getting Started with Xrepo Commands](/guide/package-management/xrepo-cli)
 
-### Install the specified package
+## Install the specified package
 
 ```console
 $ xmake require tbox
@@ -38,7 +33,7 @@ $ xmake require --extra="{debug=true,config={small=true}}" tbox
 
 Install the debug package and pass the compilation configuration information of `small=true` to the package.
 
-### Uninstall the specified package
+## Uninstall the specified package
 
 ```console
 $ xmake require --uninstall tbox
@@ -46,13 +41,13 @@ $ xmake require --uninstall tbox
 
 This will completely uninstall the removal package file.
 
-### Show package information
+## Show package information
 
 ```console
 $ xmake require --info tbox
 ```
 
-### Search for packages in the current repository
+## Search for packages in the current repository
 
 ```console
 $ xmake require --search tbox
@@ -66,7 +61,7 @@ $ xmake require --search pcr
 
 Will also search for pcre, pcre2 and other packages.
 
-### List the currently installed packages
+## List the currently installed packages
 
 ```console
 $ xmake require --list

+ 3 - 3
docs/guide/package-management/repository-management-commands.md → docs/guide/package-management/repository-management.md

@@ -1,9 +1,9 @@
 
-# Repository Management Commands
+# Repository Management
 
-## xmake repo
+We can use `xmake repo` to manage repositories, and we also provide a more convenient independent `xrepo` package manager command to install, uninstall, find and manage packages globally.
 
-As mentioned above, adding a private repository is available (supporting local path addition):
+For detailed documentation, see: [Getting Started with Xrepo Commands](/guide/package-management/xrepo-cli)
 
 ```console
 $ xmake repo --add myrepo [email protected]:myrepo/xmake-repo.git

+ 0 - 110
docs/guide/package-management/using-official-packages.md

@@ -349,113 +349,3 @@ upgrading packages ..
 1 package is upgraded!
 ```
 
-
-## Remote package download optimization
-
-If the download package is slow or fails due to an unstable network, we can use the following methods to resolve it.
-
-### Manual download
-
-By default, xmake will call curl, wget and other tools to download, users can also manually download with their own downloader (you can also use an agent), put the downloaded package in their own directory, for example: `/download/packages/zlib -v1.0.tar.gz`
-
-Then use the following command to set the search directory for package download:
-
-```console
-$ xmake g --pkg_searchdirs="/download/packages"
-```
-
-Then re-execute xmake to compile, xmake will first look for the source package from `/download/packages`, and then use it directly, no longer download it yourself.
-
-As for the package name you are looking for, you can check it by the following command:
-
-```console
-$ xmake require --info zlib
--> searchdirs: /download/packages
--> searchnames: zlib-1.2.11.tar.gz
-```
-
-We can see the corresponding search directory and the searched package name.
-
-### Proxy download
-
-If manual downloading is still troublesome, we can also let xmake go directly to the agent.
-
-```console
-$ xmake g --proxy="socks5://127.0.0.1:1086"
-$ xmake g --help
-    -x PROXY, --proxy=PROXY Use proxy on given port. [PROTOCOL://]HOST[:PORT]
-                                 e.g.
-                                 -xmake g --proxy='http://host:port'
-                                 -xmake g --proxy='https://host:port'
-                                 -xmake g --proxy='socks5://host:port'
-```
-
-The `--proxy` parameter specifies the proxy protocol and address. The specific syntax can refer to curl. Usually, it can support http, https, socks5 and other protocols, but the actual support depends on curl, wget and git. For example, wget does not support the socks5 protocol.
-
-We can use the following parameters to specify which hosts go to the proxy. If not set, the default is to go global.
-
-```console
---proxy_hosts=PROXY_HOSTS Only enable proxy for the given hosts list, it will enable all if be unset,
-                             and we can pass match pattern to list:
-                                 e.g.
-                                 -xmake g --proxy_hosts='github.com,gitlab.*,*.xmake.io'
-```
-
-If the hosts list is set, then the matching hosts in this list will go to the proxy. .
-
-`--proxy_host` supports multiple hosts settings, separated by commas, and supports basic pattern matching *.github.com, and other lua pattern matching rules are also supported
-
-If we feel that the above hosts mode configuration is not flexible enough, we can also follow pac's automatic proxy configuration rules:
-
-```console
---proxy_pac=PROXY_PAC Set the auto proxy configuration file. (default: pac.lua)
-                                     e.g.
-                                     -xmake g --proxy_pac=pac.lua (in /Users/ruki/.xmake or absolute path)
-                                     -function main(url, host)
-                                           if host =='github.com' then
-                                                return true
-                                           end
-                                       end
-```
-
-::: tip NOTE
-If there are proxy_hosts, the host configuration is preferred, otherwise, the pac configuration can be used.
-:::
-
-The default path of pac: ~/.xmake/pac.lua, if --proxy is set, and this file exists, it will automatically go to pac. If it does not exist, and there are no hosts, then the proxy will take effect globally.
-
-You can also manually specify the pac full path
-
-```console
-$ xmake g --proxy_pac=/xxxx/xxxxx_pac.lua
-```
-
-Configuration rule description:
-
-```lua
-function main(url, host)
-    if host:find("bintray.com") then
-        return true
-    end
-end
-```
-
-If it returns true, then the url and host are the proxy to go, not to return or return false, it is not to proxy.
-
-For specific details of this piece, see: https://github.com/xmake-io/xmake/issues/854
-
-#### Mirror Agent
-
-After v2.5.4, mirroring proxy rules can also be configured in the pac.lua configuration. For example, access to all github.com domain names is switched to the hub.fastgit.org domain name to achieve accelerated downloading of packages.
-
-```lua
-function mirror(url)
-      return url:gsub("github.com", "hub.fastgit.org")
-end
-```
-
-```console
-$ xrepo install libpng
-> curl https://hub.fastgit.org/glennrp/libpng/archive/v1.6.37.zip -o v1.6.37.zip
-```
-

+ 11 - 4
docs/zh/config.ts

@@ -179,15 +179,22 @@ function guideSidebar(): DefaultTheme.SidebarItem[] {
             { text: '使用官方包', link: 'package-management/using-official-packages' },
             { text: '使用第三方包', link: 'package-management/using-third-party-packages' },
             { text: '在 CMake 中使用包', link: 'package-management/using-packages-in-cmake' },
-            { text: '分发包', link: 'package-management/package-distribution' },
-            { text: '包管理命令', link: 'package-management/package-management-commands' },
-            { text: '仓库管理命令', link: 'package-management/repository-management-commands' },
-            { text: 'Xrepo CLI', link: 'package-management/xrepo-cli' },
+            { text: '分发包到仓库', link: 'package-management/package-distribution' },
           ]
         },
         { text: '使用本地包', link: 'package-management/using-local-packages' },
         { text: '使用系统包', link: 'package-management/using-system-packages' },
         { text: '使用源码包', link: 'package-management/using-source-code-packages' },
+        { text: '网络优化', link: 'package-management/network-optimization' },
+        {
+          text: 'CLI',
+          collapsed: true,
+          items: [
+            { text: '工程内包管理', link: 'package-management/package-management-in-project' },
+            { text: '仓库管理', link: 'package-management/repository-management' },
+            { text: 'Xrepo CLI', link: 'package-management/xrepo-cli' },
+          ]
+        },
       ]
     },
     {

+ 113 - 0
docs/zh/guide/package-management/network-optimization.md

@@ -0,0 +1,113 @@
+# 网络优化 {#network-optimization}
+
+如果由于网络不稳定,导致下载包速度很慢或者下载失败,我们可以通过的下面的一些方式来解决。
+
+## 手动下载 {#manual-download}
+
+默认xmake会调用curl, wget等工具来下载,用户也可以手动用自己的下载器下载(也可以使用代理),把下载后的包放到自己的目录下,比如: `/download/packages/zlib-v1.0.tar.gz`
+
+然后使用下面的命令,设置包下载的搜索目录:
+
+```console
+$ xmake g --pkg_searchdirs="/download/packages"
+```
+
+然后重新执行xmake编译时候,xmake会优先从`/download/packages`找寻源码包,然后直接使用,不再自己下载了。
+
+至于找寻的包名是怎样的呢,可以通过下面的命令查看:
+
+```console
+$ xmake require --info zlib
+-> searchdirs: /download/packages
+-> searchnames: zlib-1.2.11.tar.gz
+```
+
+我们可以看到对应的搜索目录以及搜索的包名。
+
+## 设置代理 {#proxy-setting}
+
+如果觉得手动下载还是麻烦,我们也可以让xmake直接走代理。
+
+```console
+$ xmake g --proxy="socks5://127.0.0.1:1086"
+$ xmake g --help
+    -x PROXY, --proxy=PROXY  Use proxy on given port. [PROTOCOL://]HOST[:PORT]
+                                 e.g.
+                                 - xmake g --proxy='http://host:port'
+                                 - xmake g --proxy='https://host:port'
+                                 - xmake g --proxy='socks5://host:port'
+```
+
+`--proxy`参数指定代理协议和地址,具体语法可以参考curl的,通常可以支持http, https, socks5等协议,但实际支持力度依赖curl, wget和git,比如wget就不支持socks5协议。
+
+我们可以通过下面的参数指定哪些host走代理,如果没设置,默认全局走代理。
+
+```console
+--proxy_hosts=PROXY_HOSTS    Only enable proxy for the given hosts list, it will enable all if be unset,
+                             and we can pass match pattern to list:
+                                 e.g.
+                                 - xmake g --proxy_hosts='github.com,gitlab.*,*.xmake.io'
+```
+
+如果设置了hosts列表,那么之后这个列表里面匹配的host才走代理。。
+
+`--proxy_host`支持多个hosts设置,逗号分隔,并且支持基础的模式匹配 *.github.com, 以及其他lua模式匹配规则也支持
+
+如果觉得上面的hosts模式配置还不够灵活,我们也可以走pac的自动代理配置规则:
+
+```console
+--proxy_pac=PROXY_PAC    Set the auto proxy configuration file. (default: pac.lua)
+                                     e.g.
+                                     - xmake g --proxy_pac=pac.lua (in /Users/ruki/.xmake or absolute path)
+                                     - function main(url, host)
+                                           if host == 'github.com' then
+                                                return true
+                                           end
+                                       end
+```
+
+::: tip 注意
+如果有proxy_hosts优先走hosts配置,没有的话才走pac配置。
+:::
+
+pac的默认路径:~/.xmake/pac.lua,如果--proxy被设置,并且这个文件存在,就会自动走pac,如果不存在,也没hosts,那就全局生效代理。
+
+也可以手动指定pac全路径
+
+```console
+$ xmake g --proxy_pac=/xxxx/xxxxx_pac.lua
+```
+
+配置规则描述:
+
+```lua
+function main(url, host)
+    if host:find("bintray.com") then
+        return true
+    end
+end
+```
+
+如果返回true,那么这个url和host就是走的代理,不返回或者返回false,就是不走代理。
+
+这块的具体详情见:https://github.com/xmake-io/xmake/issues/854
+
+::: tip 注意
+另外,除了依赖包下载,其他涉及网络下载的命令也都支持代理,比如:`xmake update`
+:::
+
+## 镜像代理 {#mirror-proxy}
+
+v2.5.4 之后,pac.lua 配置里面还可以配置镜像代理规则,比如对所有 github.com 域名的访问切到 hub.fastgit.org 域名,实现加速下载包。
+
+```lua
+function mirror(url)
+     return url:gsub("github.com", "hub.fastgit.org")
+end
+```
+
+```console
+$ xrepo install libpng
+> curl https://hub.fastgit.org/glennrp/libpng/archive/v1.6.37.zip -o v1.6.37.zip
+```
+

+ 6 - 8
docs/zh/guide/package-management/package-management-commands.md → docs/zh/guide/package-management/package-management-in-project.md

@@ -1,7 +1,5 @@
 
-# 包管理命令 {#package-management-commands}
-
-## xmake require
+# 工程内包管理命令 {#package-management-in-project}
 
 包管理命令`$ xmake require` 可用于手动显示的下载编译安装、卸载、检索、查看包信息。
 
@@ -9,7 +7,7 @@
 
 详细文档见:[Xrepo 命令使用入门](/zh/guide/package-management/xrepo-cli)。
 
-### 安装指定包
+## 安装指定包
 
 ```console
 $ xmake require tbox
@@ -35,7 +33,7 @@ $ xmake require --extra="{debug=true,config={small=true}}" tbox
 
 安装debug包,并且传递`small=true`的编译配置信息到包中去。
 
-### 卸载指定包
+## 卸载指定包
 
 ```console
 $ xmake require --uninstall tbox
@@ -43,13 +41,13 @@ $ xmake require --uninstall tbox
 
 这会完全卸载删除包文件。
 
-### 查看包详细信息
+## 查看包详细信息
 
 ```console
 $ xmake require --info tbox
 ```
 
-### 在当前仓库中搜索包
+## 在当前仓库中搜索包
 
 ```console
 $ xmake require --search tbox
@@ -63,7 +61,7 @@ $ xmake require --search pcr
 
 会同时搜索到pcre, pcre2等包。
 
-### 列举当前已安装的包
+## 列举当前已安装的包
 
 ```console
 $ xmake require --list

+ 3 - 3
docs/zh/guide/package-management/repository-management-commands.md → docs/zh/guide/package-management/repository-management.md

@@ -1,9 +1,9 @@
 
-# 仓库管理命令 {#repository-management-commands}
+# 仓库管理命令 {#repository-management}
 
-## xmake repo
+我们可以使用 `xmake repo` 去管理仓库,并且我们也提供了更加方便的独立 `xrepo` 包管理器命令,来全局对包进行安装,卸载和查找管理。
 
-上文已经简单讲过,添加私有仓库可以用(支持本地路径添加):
+详细文档见:[Xrepo 命令使用入门](/zh/guide/package-management/xrepo-cli)。
 
 ```console
 $ xmake repo --add myrepo [email protected]:myrepo/xmake-repo.git

+ 0 - 114
docs/zh/guide/package-management/using-official-packages.md

@@ -381,117 +381,3 @@ upgrading packages ..
 1 package is upgraded!
 ```
 
-
-## 远程包下载优化 {#optimize-package-download}
-
-如果由于网络不稳定,导致下载包速度很慢或者下载失败,我们可以通过的下面的一些方式来解决。
-
-### 手动下载
-
-默认xmake会调用curl, wget等工具来下载,用户也可以手动用自己的下载器下载(也可以使用代理),把下载后的包放到自己的目录下,比如: `/download/packages/zlib-v1.0.tar.gz`
-
-然后使用下面的命令,设置包下载的搜索目录:
-
-```console
-$ xmake g --pkg_searchdirs="/download/packages"
-```
-
-然后重新执行xmake编译时候,xmake会优先从`/download/packages`找寻源码包,然后直接使用,不再自己下载了。
-
-至于找寻的包名是怎样的呢,可以通过下面的命令查看:
-
-```console
-$ xmake require --info zlib
--> searchdirs: /download/packages
--> searchnames: zlib-1.2.11.tar.gz
-```
-
-我们可以看到对应的搜索目录以及搜索的包名。
-
-### 设置代理 {#proxy-setting}
-
-如果觉得手动下载还是麻烦,我们也可以让xmake直接走代理。
-
-```console
-$ xmake g --proxy="socks5://127.0.0.1:1086"
-$ xmake g --help
-    -x PROXY, --proxy=PROXY  Use proxy on given port. [PROTOCOL://]HOST[:PORT]
-                                 e.g.
-                                 - xmake g --proxy='http://host:port'
-                                 - xmake g --proxy='https://host:port'
-                                 - xmake g --proxy='socks5://host:port'
-```
-
-`--proxy`参数指定代理协议和地址,具体语法可以参考curl的,通常可以支持http, https, socks5等协议,但实际支持力度依赖curl, wget和git,比如wget就不支持socks5协议。
-
-我们可以通过下面的参数指定哪些host走代理,如果没设置,默认全局走代理。
-
-```console
---proxy_hosts=PROXY_HOSTS    Only enable proxy for the given hosts list, it will enable all if be unset,
-                             and we can pass match pattern to list:
-                                 e.g.
-                                 - xmake g --proxy_hosts='github.com,gitlab.*,*.xmake.io'
-```
-
-如果设置了hosts列表,那么之后这个列表里面匹配的host才走代理。。
-
-`--proxy_host`支持多个hosts设置,逗号分隔,并且支持基础的模式匹配 *.github.com, 以及其他lua模式匹配规则也支持
-
-如果觉得上面的hosts模式配置还不够灵活,我们也可以走pac的自动代理配置规则:
-
-```console
---proxy_pac=PROXY_PAC    Set the auto proxy configuration file. (default: pac.lua)
-                                     e.g.
-                                     - xmake g --proxy_pac=pac.lua (in /Users/ruki/.xmake or absolute path)
-                                     - function main(url, host)
-                                           if host == 'github.com' then
-                                                return true
-                                           end
-                                       end
-```
-
-::: tip 注意
-如果有proxy_hosts优先走hosts配置,没有的话才走pac配置。
-:::
-
-pac的默认路径:~/.xmake/pac.lua,如果--proxy被设置,并且这个文件存在,就会自动走pac,如果不存在,也没hosts,那就全局生效代理。
-
-也可以手动指定pac全路径
-
-```console
-$ xmake g --proxy_pac=/xxxx/xxxxx_pac.lua
-```
-
-配置规则描述:
-
-```lua
-function main(url, host)
-    if host:find("bintray.com") then
-        return true
-    end
-end
-```
-
-如果返回true,那么这个url和host就是走的代理,不返回或者返回false,就是不走代理。
-
-这块的具体详情见:https://github.com/xmake-io/xmake/issues/854
-
-::: tip 注意
-另外,除了依赖包下载,其他涉及网络下载的命令也都支持代理,比如:`xmake update`
-:::
-
-#### 镜像代理
-
-v2.5.4 之后,pac.lua 配置里面还可以配置镜像代理规则,比如对所有 github.com 域名的访问切到 hub.fastgit.org 域名,实现加速下载包。
-
-```lua
-function mirror(url)
-     return url:gsub("github.com", "hub.fastgit.org")
-end
-```
-
-```console
-$ xrepo install libpng
-> curl https://hub.fastgit.org/glennrp/libpng/archive/v1.6.37.zip -o v1.6.37.zip
-```
-