diff options
| author | ruki <waruqi@gmail.com> | 2019-06-26 22:21:31 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2019-06-26 08:09:36 +0800 |
| commit | d82d0f8b20be535c65d0087bd3abf7f2561853b2 (patch) | |
| tree | 05c7af744c79454ff1c606ba35a237da28621d81 | |
| parent | 850674db53832a131dbf8591158c8b1253883748 (diff) | |
| download | xmake-docs-d82d0f8b20be535c65d0087bd3abf7f2561853b2.tar.gz xmake-docs-d82d0f8b20be535c65d0087bd3abf7f2561853b2.zip | |
update package docs
| -rw-r--r-- | guide/package_management.md | 52 | ||||
| -rw-r--r-- | zh-cn/guide/package_management.md | 76 |
2 files changed, 86 insertions, 42 deletions
diff --git a/guide/package_management.md b/guide/package_management.md index 169b7aa5..e5f003eb 100644 --- a/guide/package_management.md +++ b/guide/package_management.md @@ -1,7 +1,7 @@ ## Local Package Mode -By including a dependency package directory and a binary package file in the project, it is convenient to integrate some third-party dependency libraries. This method is relatively simple and straightforward, but the disadvantages are also obvious and inconvenient to manage. +By including a dependency package directory and some binary library files in the project, it is convenient to integrate some third-party dependency libraries. This method is relatively simple and straightforward, but the disadvantages are also obvious and inconvenient to manage. Take the tbox project as an example. The dependency package is as follows: @@ -92,6 +92,12 @@ target("test") If third-party tools such as `homebrew`, `pkg-config` are installed on the system, then this interface will try to use them to improve the search results. +Another, we can also find packages from the given package manager. For example: + +```lua +find_packages("brew::pcre2/libpcre2-8", "vcpkg::zlib") +``` + For a more complete description of the usage, please refer to the [find_packages](/manual/builtin_modules?id=find_packages) interface documentation. ### Homebrew Integration Support @@ -144,7 +150,7 @@ For more information and progress on package dependency management see the relat ### Currently Supported Features * Semantic version support, for example: ">= 1.1.0 < 1.2", "~1.6", "1.2.x", "1.*" -* Provide multi-warehouse management support such as official package warehouse, self-built private warehouse, project built-in warehouse, etc. +* Provide multi-repository management support such as official package repository, self-built private repository, project built-in repository, etc. * Cross-platform package compilation integration support (packages of different platforms and different architectures can be installed at the same time, fast switching use) * Debug dependency package support, source code debugging @@ -236,9 +242,9 @@ Pass `--small=true` to the tbox package so that compiling the installed tbox pac ### Install third-party packages -After version 2.2.5, xmake supports support for dependency libraries in third-party package managers, such as: conan, brew, vcpkg, etc. +After version 2.2.5, xmake supports support for dependency libraries in third-party package managers, such as: conan, brew, vcpkg, clib and etc. -Add a homebrew dependency package: +#### Add a homebrew dependency package ```lua add_requires("brew::zlib", {alias = "zlib"}}) @@ -250,7 +256,7 @@ target("test") add_packages("pcre2", "zlib") ``` -Add a dependency package for vcpkg: +#### Add a vcpkg dependency package ```lua add_requires("vcpkg::zlib", "vcpkg::pcre2") @@ -261,7 +267,7 @@ target("test") add_packages("vcpkg::zlib", "vcpkg::pcre2") ``` -Add a conan dependency package: +#### Add a conan dependency package ```lua add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true}) @@ -293,7 +299,23 @@ please input: y (y/n) [100%]: linking.release test ``` -### Using self-built private package warehouse +#### Add a clib dependency package + +Clib is a source-based dependency package manager. The dependent package is downloaded directly to the corresponding library source code, integrated into the project to compile, rather than binary library dependencies. + +It is also very convenient to integrate in xmake. The only thing to note is that you need to add the source code of the corresponding library to xmake.lua, for example: + +```lua +add_requires("clib::clibs/bytes@0.0.4", {alias = "bytes"}) + +target("test") + set_kind("binary") + add_files("clib/bytes/*.c") + add_files("src/*.c") + add_packages("bytes") +``` + +### Using self-built private package repository If the required package is not in the official repository [xmake-repo](https://github.com/xmake-io/xmake-repo), we can submit the contribution code to the repository for support. But if some packages are only for personal or private projects, we can create a private repository repo. The repository organization structure can be found at: [xmake-repo](https://github.com/xmake-io/xmake-repo) @@ -369,7 +391,7 @@ target("test") add_packages("libjpeg") ``` -### Package Management Command Use +### Package Management Command The package management command `$ xmake require` can be used to manually display the download, install, uninstall, retrieve, and view package information. @@ -399,7 +421,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. -#### Uninstalling the specified package +#### Uninstall the specified package ```console $ xmake require --uninstall tbox @@ -407,13 +429,13 @@ $ xmake require --uninstall tbox This will completely uninstall the removal package file. -#### View package details +#### Show package information ```console $ xmake require --info tbox ``` -#### Search for packages in the current warehouse +#### Search for packages in the current repository ```console $ xmake require --search tbox @@ -433,7 +455,7 @@ Will also search for pcre, pcre2 and other packages. $ xmake require --list ``` -### Warehouse Management Command Use +### Repository Management Command As mentioned above, adding a private repository is available (supporting local path addition): @@ -447,19 +469,19 @@ We can also remove a repository that has already been installed: $ xmake repo --remove myrepo ``` -Or view all the added warehouses: +Or view all the added repositories: ```console $ xmake repo --list ``` -If the remote repository has updates, you can manually perform a warehouse update to get more and the latest packages: +If the remote repository has updates, you can manually perform a repository update to get more and the latest packages: ```console $ xmake repo -u ``` -### Submit the package to the official warehouse +### Submit package to the official repository If you need a package that is not supported by the current official repository, you can commit it to the official repository after local tuning: [xmake-repo](https://github.com/xmake-io/xmake-repo) diff --git a/zh-cn/guide/package_management.md b/zh-cn/guide/package_management.md index 02a8e280..0be1fdf1 100644 --- a/zh-cn/guide/package_management.md +++ b/zh-cn/guide/package_management.md @@ -1,5 +1,5 @@ -#### 本地内置模式 +## 本地内置模式 通过在项目中内置依赖包目录以及二进制包文件,可以方便的集成一些第三方的依赖库,这种方式比较简单直接,但是缺点也很明显,不方便管理。 @@ -46,7 +46,7 @@ $ xmake package -o ../test/packages 关于内置包的详细描述,还可以参考下相关文章,这里面有详细介绍:[依赖包的添加和自动检测机制](https://tboox.org/cn/2016/08/06/add-package-and-autocheck/) -#### 系统查找模式 +## 系统查找模式 如果觉得上述内置包的管理方式非常不方便,可以通过xmake提供的内置接口`find_packages`。 @@ -92,13 +92,19 @@ target("test") 如果系统上装有`homebrew`, `pkg-config`等第三方工具,那么此接口会尝试使用它们去改进查找结果。 +另外,我们也可以从指定的包管理器查找包: + +```lua +find_packages("brew::pcre2/libpcre2-8", "vcpkg::zlib") +``` + 更完整的使用描述,请参考:[find_packages](/zh-cn/manual/builtin_modules?id=find_packages)接口文档。 -##### homebrew集成支持 +### homebrew集成支持 由于homebrew一般都是把包直接装到的系统中去了,因此用户不需要做任何集成工作,`find_packages`就已经原生无缝支持。 -##### vcpkg集成支持 +### vcpkg集成支持 目前xmake v2.2.2版本已经支持了vcpkg,用户只需要装完vcpkg后,执行`$ vcpkg integrate install`,xmake就能自动从系统中检测到vcpkg的根路径,然后自动适配里面包。 @@ -114,7 +120,7 @@ $ xmake f --vcpkg=f:\vcpkg $ xmake g --vcpkg=f:\vcpkg ``` -#### 远程依赖模式 +## 远程依赖模式 这个在2.2.2版本后已经初步支持,用法上更加的简单,只需要设置对应的依赖包就行了,例如: @@ -141,14 +147,14 @@ xmake会去远程拉取相关源码包,然后自动编译安装,最后编译 关于包依赖管理的更多相关信息和进展见相关issues:[Remote package management](https://github.com/xmake-io/xmake/issues/69) -##### 目前支持的特性 +### 目前支持的特性 * 语义版本支持,例如:">= 1.1.0 < 1.2", "~1.6", "1.2.x", "1.*" * 提供官方包仓库、自建私有仓库、项目内置仓库等多仓库管理支持 * 跨平台包编译集成支持(不同平台、不同架构的包可同时安装,快速切换使用) * debug依赖包支持,实现源码调试 -##### 依赖包处理机制 +### 依赖包处理机制 这里我们简单介绍下整个依赖包的处理机制: @@ -158,7 +164,7 @@ xmake会去远程拉取相关源码包,然后自动编译安装,最后编译 2. 检索匹配对应版本的包,然后下载、编译、安装(注:安装在特定xmake目录,不会干扰系统库环境) 3. 编译项目,最后自动链接启用的依赖包 -##### 快速上手 +### 快速上手 新建一个依赖tbox库的空工程: @@ -187,7 +193,7 @@ $ xmake f -p android [--ndk=~/android-ndk-r16b] $ xmake ``` -##### 语义版本设置 +### 语义版本设置 xmake的依赖包管理是完全支持语义版本选择的,例如:"~1.6.1",对于语义版本的具体描述见:[https://semver.org/](https://semver.org/) @@ -213,9 +219,9 @@ add_requires("tbox master") add_requires("tbox dev") ``` -##### 额外的包信息设置 +### 额外的包信息设置 -###### 可选包设置 +#### 可选包设置 如果指定的依赖包当前平台不支持,或者编译安装失败了,那么xmake会编译报错,这对于有些必须要依赖某些包才能工作的项目,这是合理的。 但是如果有些包是可选的依赖,即使没有也可以正常编译使用的话,可以设置为可选包: @@ -224,7 +230,7 @@ add_requires("tbox dev") add_requires("tbox", {optional = true}) ``` -###### 禁用系统库 +#### 禁用系统库 默认的设置,xmake会去优先检测系统库是否存在(如果没设置版本要求),如果用户完全不想使用系统库以及第三方包管理提供的库,那么可以设置: @@ -232,7 +238,7 @@ add_requires("tbox", {optional = true}) add_requires("tbox", {system = false}) ``` -###### 使用调试版本的包 +#### 使用调试版本的包 如果我们想同时源码调试依赖包,那么可以设置为使用debug版本的包(当然前提是这个包支持debug编译): @@ -251,7 +257,7 @@ package("openssl") end) ``` -###### 传递额外的编译信息到包 +#### 传递额外的编译信息到包 某些包在编译时候有各种编译选项,我们也可以传递进来,当然包本身得支持: @@ -261,11 +267,11 @@ add_requires("tbox", {configs = {small=true}}) 传递`--small=true`给tbox包,使得编译安装的tbox包是启用此选项的。 -##### 第三方依赖包安装 +### 第三方依赖包安装 2.2.5版本之后,xmake支持对对第三方包管理器里面的依赖库安装支持,例如:conan,brew, vcpkg等 -添加homebrew的依赖包: +#### 添加homebrew的依赖包 ```lua add_requires("brew::zlib", {alias = "zlib"}}) @@ -277,7 +283,7 @@ target("test") add_packages("pcre2", "zlib") ``` -添加vcpkg的依赖包: +#### 添加vcpkg的依赖包 ```lua add_requires("vcpkg::zlib", "vcpkg::pcre2") @@ -288,7 +294,7 @@ target("test") add_packages("vcpkg::zlib", "vcpkg::pcre2") ``` -添加conan的依赖包: +#### 添加conan的依赖包 ```lua add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true}) @@ -320,7 +326,23 @@ please input: y (y/n) [100%]: linking.release test ``` -##### 使用自建私有包仓库 +#### 添加clib的依赖包 + +clib是一款基于源码的依赖包管理器,拉取的依赖包是直接下载对应的库源码,集成到项目中编译,而不是二进制库依赖。 + +其在xmake中集成也很方便,唯一需要注意的是,还需要自己添加上对应库的源码到xmake.lua,例如: + +```lua +add_requires("clib::clibs/bytes@0.0.4", {alias = "bytes"}) + +target("test") + set_kind("binary") + add_files("clib/bytes/*.c") + add_files("src/*.c") + add_packages("bytes") +``` + +### 使用自建私有包仓库 如果需要的包不在官方仓库[xmake-repo](https://github.com/xmake-io/xmake-repo)中,我们可以提交贡献代码到仓库进行支持。 但如果有些包仅用于个人或者私有项目,我们可以建立一个私有仓库repo,仓库组织结构可参考:[xmake-repo](https://github.com/xmake-io/xmake-repo) @@ -390,11 +412,11 @@ target("test") add_packages("libjpeg") ``` -##### 包管理命令使用 +### 包管理命令使用 包管理命令`$ xmake require` 可用于手动显示的下载编译安装、卸载、检索、查看包信息。 -###### 安装指定包 +#### 安装指定包 ```console $ xmake require tbox @@ -420,7 +442,7 @@ $ xmake require --extra="debug=true,config={small=true}" tbox 安装debug包,并且传递`small=true`的编译配置信息到包中去。 -###### 卸载指定包 +#### 卸载指定包 ```console $ xmake require --uninstall tbox @@ -428,13 +450,13 @@ $ xmake require --uninstall tbox 这会完全卸载删除包文件。 -###### 查看包详细信息 +#### 查看包详细信息 ```console $ xmake require --info tbox ``` -###### 在当前仓库中搜索包 +#### 在当前仓库中搜索包 ```console $ xmake require --search tbox @@ -448,13 +470,13 @@ $ xmake require --search pcr 会同时搜索到pcre, pcre2等包。 -###### 列举当前已安装的包 +#### 列举当前已安装的包 ```console $ xmake require --list ``` -##### 仓库管理命令使用 +### 仓库管理命令使用 上文已经简单讲过,添加私有仓库可以用(支持本地路径添加): @@ -486,7 +508,7 @@ $ xmake repo --list $ xmake repo -u ``` -##### 提交包到官方仓库 +### 提交包到官方仓库 目前这个特性刚完成不久,目前官方仓库的包还不是很多,有些包也许还不支持部分平台,不过这并不是太大问题,后期迭代几个版本后,我会不断扩充完善包仓库。 |
