├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── NOTICE.md ├── README.md ├── README_zh.md └── src ├── xrepo.bat └── xrepo.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.b 3 | *.o 4 | *.exe 5 | *.obj 6 | *.dll 7 | *.lib 8 | *.out 9 | *.suo 10 | *~ 11 | *.swp 12 | *.swo 13 | *.bak 14 | *.orig 15 | *.pdb 16 | *.idb 17 | *.ilk 18 | *.stackdump 19 | *.manifest 20 | .ccache 21 | .demo 22 | .svn 23 | .DS_Store 24 | .xmake 25 | cscope.* 26 | gmon.out 27 | other 28 | tags 29 | doc 30 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | If you discover issues or want to contribute a new package, please report them to the 4 | [issue tracker][1] of the repository or submit a pull request. Please, 5 | try to follow these guidelines when you do so. 6 | 7 | ## Issue reporting 8 | 9 | * Check that the issue has not already been reported. 10 | * Check that the issue has not already been fixed in the latest code 11 | (a.k.a. `master`). 12 | * Be clear, concise and precise in your description of the problem. 13 | * Open an issue with a descriptive title and a summary in grammatically correct, 14 | complete sentences. 15 | * Include any relevant code to the issue summary. 16 | 17 | ## Pull requests 18 | 19 | * Use a topic branch to easily amend a pull request later, if necessary. 20 | * Write good commit messages. 21 | * Use the same coding conventions as the rest of the project. 22 | * Ensure your edited codes with four spaces instead of TAB. 23 | * About how to make a package, please see [Create and Submit packages to the official repository](https://xmake.io/#/package/remote_package?id=submit-packages-to-the-official-repository) 24 | 25 | # 贡献代码 26 | 27 | 如果你发现一些问题或者想贡献一个新的包 28 | 那么你可以在[issues][1]上提交反馈,或者发起一个提交代码的请求(pull request). 29 | 30 | ## 问题反馈 31 | 32 | * 确认这个问题没有被反馈过 33 | * 确认这个问题最近还没有被修复,请先检查下 `master` 的最新提交 34 | * 请清晰详细地描述你的问题 35 | * 如果发现某些代码存在问题,请在issue上引用相关代码 36 | 37 | ## 提交代码 38 | 39 | * 请先更新你的本地分支到最新,再进行提交代码请求,确保没有合并冲突 40 | * 编写友好可读的提交信息 41 | * 请使用余工程代码相同的代码规范 42 | * 确保提交的代码缩进是四个空格,而不是tab 43 | * 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述 44 | * 关于如何制作包,请参看文档:[制作和提交到官方仓库](https://xmake.io/#/zh-cn/package/remote_package?id=%e6%b7%bb%e5%8a%a0%e5%8c%85%e5%88%b0%e4%bb%93%e5%ba%93) 45 | 46 | [1]: https://github.com/xmake-io/xrepo/issues 47 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2017-present TBOOX Open Source Group 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | A cross-platform C/C++ package manager based on Xmake 2 | Copyright 2017-present The TBOOX Open Source Group 3 | 4 | This product includes software developed by The TBOOX Open Source Group (http://www.tboox.org/). 5 | 6 | ------------------------------------------------------------------------------- 7 | 8 | This product depends on 'xmake', A cross-platform build utility based on Lua, 9 | which can be obtained at: 10 | 11 | * LICENSE: 12 | * https://github.com/xmake-io/xmake/blob/master/LICENSE.md (Apache License 2.0) 13 | * HOMEPAGE: 14 | * https://xmake-io 15 | 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 |

xrepo

7 | 8 |
9 | 10 | Reddit 11 | 12 | 13 | Gitter 14 | 15 | 16 | Telegram 17 | 18 | 19 | QQ 20 | 21 | 22 | license 23 | 24 | 25 | Donate 26 | 27 |
28 | 29 |

A cross-platform C/C++ package manager based on Xmake

30 |
31 | 32 | ## Supporting the project 33 | 34 | Support this project by becoming a sponsor. Your logo will show up here with a link to your website. 🙏 [[Become a sponsor](https://xmake.io/#/about/sponsor)] 35 | 36 | 37 | 38 | ## Introduction ([中文](/README_zh.md)) 39 | 40 | xrepo is a cross-platform C/C++ package manager based on [Xmake](https://github.com/xmake-io/xmake). 41 | 42 | It is based on the runtime provided by xmake, but it is a complete and independent package management program. Compared with package managers such as vcpkg/homebrew, xrepo can provide C/C++ packages for more platforms and architectures at the same time. 43 | 44 | And it also supports multi-version semantic selection. In addition, it is also a decentralized distributed repository. It not only provides the official [xmake-repo](https://github.com/xmake-io/xmake-repo) repository, It also supports users to build multiple private repositorys. 45 | 46 | At the same time, xrepo also supports installing packages from third-party package managers such as vcpkg/homebrew/conan, and provides unified and consistent library link information to facilitate integration and docking with third-party projects. 47 | 48 | If you want to know more, please refer to: [Documents](https://xrepo.xmake.io/#/getting_started), [Github](https://github.com/xmake-io/xrepo) and [Gitee](https://gitee.com/tboox/xrepo) 49 | 50 | ![](https://github.com/xmake-io/xrepo-docs/raw/master/assets/img/xrepo.gif) 51 | 52 | ## Installation 53 | 54 | We only need install xmake to use the xrepo command. About the installation of xmake, we can see: [Xmake Installation Document](https://xmake.io/#/guide/installation). 55 | 56 | ## Supported platforms 57 | 58 | * Windows (x86, x64) 59 | * macOS (i386, x86_64, arm64) 60 | * Linux (i386, x86_64, cross-toolchains ..) 61 | * *BSD (i386, x86_64) 62 | * Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a) 63 | * iOS (armv7, armv7s, arm64, i386, x86_64) 64 | * MSYS (i386, x86_64) 65 | * MinGW (i386, x86_64, arm, arm64) 66 | * Cross Toolchains 67 | 68 | ## Supported package repositories 69 | 70 | * Official package repository [xmake-repo](https://github.com/xmake-io/xmake-repo) (tbox >1.6.1) 71 | * [User-built repositories](https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository) 72 | * Conan (conan::openssl/1.1.1g) 73 | * Vcpkg (vcpkg:ffmpeg) 74 | * Homebrew/Linuxbrew (brew::pcre2/libpcre2-8) 75 | * Pacman on archlinux/msys2 (pacman::libcurl) 76 | * Clib (clib::clibs/bytes@0.0.4) 77 | * Dub (dub::log 0.4.3) 78 | 79 | ## Suppory distributed repository 80 | 81 | In addition to directly retrieving the installation package from the official repository: [xmake-repo](https://github.com/xmake-io/xmake-repo). 82 | 83 | We can also add any number of self-built repositories, and even completely isolate the external network, and only maintain the installation and integration of private packages on the company's internal network. 84 | 85 | Just use the following command to add your own repository address: 86 | 87 | ```console 88 | $ xrepo add-repo myrepo https://github.com/mygroup/myrepo 89 | ``` 90 | 91 | ## Seamless integration with xmake project 92 | 93 | ```lua 94 | add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8") 95 | add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true}) 96 | target("test") 97 | set_kind("binary") 98 | add_files("src/*.c") 99 | add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl") 100 | ``` 101 | 102 | The following is the overall architecture and compilation process integrated with xmake. 103 | 104 | 105 | 106 | ## Get started 107 | 108 | ### Installation package 109 | 110 | #### Basic usage 111 | 112 | ```console 113 | $ xrepo install zlib tbox 114 | ``` 115 | 116 | #### Install the specified version package 117 | 118 | ```console 119 | $ xrepo install "zlib 1.2.x" 120 | $ xrepo install "zlib >=1.2.0" 121 | ``` 122 | 123 | #### Install the specified platform package 124 | 125 | ```console 126 | $ xrepo install -p iphoneos -a arm64 zlib 127 | $ xrepo install -p android [--ndk=/xxx] zlib 128 | $ xrepo install -p mingw [--mingw=/xxx] zlib 129 | $ xrepo install -p cross --sdk=/xxx/arm-linux-musleabi-cross zlib 130 | ``` 131 | 132 | #### Install the debug package 133 | 134 | ```console 135 | $ xrepo install -m debug zlib 136 | ``` 137 | 138 | #### Install the package with dynamic library 139 | 140 | ```console 141 | $ xrepo install -k shared zlib 142 | ``` 143 | 144 | #### Install the specified configuration package 145 | 146 | ```console 147 | $ xrepo install -f "vs_runtime='MD'" zlib 148 | $ xrepo install -f "regex=true,thread=true" boost 149 | ``` 150 | 151 | #### Install packages from third-party package manager 152 | 153 | ```console 154 | $ xrepo install brew::zlib 155 | $ xrepo install vcpkg::zlib 156 | $ xrepo install conan::zlib/1.2.11 157 | $ xrepo install pacman:libpng 158 | $ xrepo install dub:log 159 | ``` 160 | 161 | ### Find the library information of the package 162 | 163 | ```console 164 | $ xrepo fetch pcre2 165 | { 166 | { 167 | linkdirs = { 168 | "/usr/local/Cellar/pcre2/10.33/lib" 169 | }, 170 | links = { 171 | "pcre2-8" 172 | }, 173 | defines = { 174 | "PCRE2_CODE_UNIT_WIDTH=8" 175 | }, 176 | includedirs = "/usr/local/Cellar/pcre2/10.33/include" 177 | } 178 | } 179 | ``` 180 | 181 | ```console 182 | $ xrepo fetch --ldflags openssl 183 | -L/Users/ruki/.xmake/packages/o/openssl/1.1.1/d639b7d6e3244216b403b39df5101abf/lib -lcrypto -lssl 184 | ``` 185 | 186 | ```console 187 | $ xrepo fetch --cflags openssl 188 | -I/Users/ruki/.xmake/packages/o/openssl/1.1.1/d639b7d6e3244216b403b39df5101abf/include 189 | ``` 190 | 191 | ```console 192 | $ xrepo fetch -p [iphoneos|android] --cflags "zlib 1.2.x" 193 | -I/Users/ruki/.xmake/packages/z/zlib/1.2.11/df72d410e7e14391b1a4375d868a240c/include 194 | ``` 195 | 196 | ```console 197 | $ xrepo fetch --cflags --ldflags conan::zlib/1.2.11 198 | -I/Users/ruki/.conan/data/zlib/1.2.11/_/_/package/f74366f76f700cc6e991285892ad7a23c30e6d47/include -L/Users/ruki/.conan/data/zlib/1.2.11/_/_/package/f74366f76f700cc6e991285892ad7a23c30e6d47/lib -lz 199 | ``` 200 | 201 | ### Import and export packages 202 | 203 | xrepo can quickly export the installed packages, including the corresponding library files, header files, and so on. 204 | 205 | ```console 206 | $ xrepo export -o /tmp/output zlib 207 | ``` 208 | 209 | You can also import the previously exported installation package on other machines to implement package migration. 210 | 211 | ```console 212 | $ xrepo import -i /xxx/packagedir zlib 213 | ``` 214 | 215 | ### Search supported packages 216 | 217 | ```console 218 | $ xrepo search zlib "pcr*" 219 | zlib: 220 | -> zlib: A Massively Spiffy Yet Delicately Unobtrusive Compression Library (in xmake-repo) 221 | pcr*: 222 | -> pcre2: A Perl Compatible Regular Expressions Library (in xmake-repo) 223 | -> pcre: A Perl Compatible Regular Expressions Library (in xmake-repo) 224 | ``` 225 | 226 | In addition, you can now search for their packages from third-party package managers such as vcpkg, conan, conda, and apt. You only need to add the corresponding package namespace, for example: 227 | 228 | ```console 229 | $ xrepo search vcpkg::pcre 230 | The package names: 231 | vcpkg::pcre: 232 | -> vcpkg::pcre-8.44#8: Perl Compatible Regular Expressions 233 | -> vcpkg::pcre2-10.35#2: PCRE2 is a re-working of the original Perl Compatible Regular Expressions library 234 | ``` 235 | 236 | ```console 237 | $ xrepo search conan::openssl 238 | The package names: 239 | conan::openssl: 240 | -> conan::openssl/1.1.1g: 241 | -> conan::openssl/1.1.1h: 242 | ``` 243 | 244 | ### Show package environment information 245 | 246 | ```console 247 | $ xrepo env --show luajit 248 | { 249 | OLDPWD = "/mnt/tbox", 250 | HOME = "/home/ruki", 251 | PATH = "/home/ruki/.xmake/packages/l/luajit/2.1.0-beta3/fbac76d823b844f0b91abf3df0a3bc61/bin:/tmp:/tmp/arm-linux-musleabi-cross/bin:~/.local/bin: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 252 | TERM = "xterm", 253 | PWD = "/mnt/xmake", 254 | XMAKE_PROGRAM_DIR = "/mnt/xmake/xmake", 255 | HOSTNAME = "e6edd61ff1ab", 256 | LD_LIBRARY_PATH = "/home/ruki/.xmake/packages/l/luajit/2.1.0-beta3/fbac76d823b844f0b91abf3df0a3bc61/lib", 257 | SHLVL = "1", 258 | _ = "/mnt/xmake/scripts/xrepo.sh" 259 | } 260 | ``` 261 | 262 | ### Load package environment and run commands 263 | 264 | ```console 265 | $ xrepo env luajit 266 | LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/ 267 | JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse 268 | > 269 | ``` 270 | 271 | ```console 272 | $ xrepo env -b "luajit 2.x" luajit 273 | $ xrepo env -p iphoneos -b "zlib,libpng,luajit 2.x" cmake .. 274 | ``` 275 | 276 | ### Package virtual environment 277 | 278 | #### Enter the virtual environment 279 | 280 | We can customize some package configurations by adding the xmake.lua file in the current directory, and then enter the specific package virtual environment. 281 | 282 | ```lua 283 | add_requires("zlib 1.2.11") 284 | add_requires("python 3.x", "luajit") 285 | ``` 286 | 287 | ```console 288 | $ xrepo env shell 289 | > python --version 290 | > luajit --version 291 | ``` 292 | 293 | We can also configure and load the corresponding toolchain environment in xmake.lua, for example, load the VS compilation environment. 294 | 295 | ```lua 296 | set_toolchains("msvc") 297 | ``` 298 | 299 | #### Manage virtual environments 300 | 301 | We can use the following command to register the specified virtual environment configuration globally to the system for quick switching. 302 | 303 | ```console 304 | $ xrepo env --add /tmp/base.lua 305 | ``` 306 | 307 | At this time, we have saved a global virtual environment called base, and we can view it through the list command. 308 | 309 | ```console 310 | $ xrepo env --list 311 | /Users/ruki/.xmake/envs: 312 | -base 313 | envs(1) found! 314 | ``` 315 | 316 | We can also delete it. 317 | 318 | ```console 319 | $ xrepo env --remove base 320 | ``` 321 | 322 | #### Switch global virtual environment 323 | 324 | If we register multiple virtual environments, we can also switch them quickly. 325 | 326 | ```console 327 | $ xrepo env -b base shell 328 | > python --version 329 | ``` 330 | 331 | Or directly load the specified virtual environment to run specific commands 332 | 333 | ```console 334 | $ xrepo env -b base python --version 335 | ``` 336 | 337 | `xrepo env -b/--bind` is to bind the specified virtual environment. For more details, see: [#1762](https://github.com/xmake-io/xmake/issues/1762) 338 | 339 | ### Show the given package information 340 | 341 | ```console 342 | $ xrepo info zlib 343 | The package info of project: 344 | require(zlib): 345 | -> description: A Massively Spiffy Yet Delicately Unobtrusive Compression Library 346 | -> version: 1.2.11 347 | -> urls: 348 | -> http://zlib.net/zlib-1.2.11.tar.gz 349 | -> c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 350 | -> https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz 351 | -> c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 352 | -> repo: xmake-repo https://gitee.com/tboox/xmake-repo.git master 353 | -> cachedir: /Users/ruki/.xmake/cache/packages/2010/z/zlib/1.2.11 354 | -> installdir: /Users/ruki/.xmake/packages/z/zlib/1.2.11/d639b7d6e3244216b403b39df5101abf 355 | -> searchdirs: 356 | -> searchnames: zlib-1.2.11.tar.gz 357 | -> fetchinfo: 1.2.11, system 358 | -> version: 1.2.11 359 | -> links: z 360 | -> linkdirs: /usr/local/Cellar/zlib/1.2.11/lib 361 | -> includedirs: /usr/local/Cellar/zlib/1.2.11/include 362 | -> platforms: iphoneos, mingw@windows, macosx, mingw@linux,macosx, android@linux,macosx, windows, linux 363 | -> requires: 364 | -> plat: macosx 365 | -> arch: x86_64 366 | -> configs: 367 | -> debug: false 368 | -> vs_runtime: MT 369 | -> shared: false 370 | -> configs: 371 | -> configs (builtin): 372 | -> debug: Enable debug symbols. (default: false) 373 | -> shared: Enable shared library. (default: false) 374 | -> cflags: Set the C compiler flags. 375 | -> cxflags: Set the C/C++ compiler flags. 376 | -> cxxflags: Set the C++ compiler flags. 377 | -> asflags: Set the assembler flags. 378 | -> vs_runtime: Set vs compiler runtime. (default: MT) 379 | -> values: {"MT","MD"} 380 | ``` 381 | 382 | ### Uninstall all packages 383 | 384 | We can use the following command to batch uninstall and delete the installed packages, supporting pattern matching: 385 | 386 | ```bash 387 | $ xrepo remove --all 388 | $ xrepo remove --all zlib pcr* 389 | ``` 390 | 391 | ## Contacts 392 | 393 | * Email:[waruqi@gmail.com](mailto:waruqi@gmail.com) 394 | * Homepage:[tboox.org](https://tboox.org) 395 | * Community:[/r/xmake on reddit](https://www.reddit.com/r/xmake/) 396 | * ChatRoom:[Char on telegram](https://t.me/tbooxorg), [Chat on gitter](https://gitter.im/xmake-io/xmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 397 | * Source Code:[Github](https://github.com/xmake-io/xmake), [Gitee](https://gitee.com/tboox/xmake) 398 | * QQ Group: 343118190(Technical Support), 662147501 399 | * Wechat Public: tboox-os 400 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 |

xrepo

7 | 8 |
9 | 10 | Reddit 11 | 12 | 13 | Gitter 14 | 15 | 16 | Telegram 17 | 18 | 19 | QQ 20 | 21 | 22 | license 23 | 24 | 25 | Donate 26 | 27 |
28 | 29 |

一个基于 Xmake 的跨平台 C/C++ 包管理器

30 |
31 | 32 | ## 项目支持 33 | 34 | 通过成为赞助者来支持该项目。您的logo将显示在此处,并带有指向您网站的链接。🙏 [[成为赞助商](https://xmake.io/#/zh-cn/about/sponsor)] 35 | 36 | 37 | 38 | ## 简介 39 | 40 | xrepo 是一个基于 [Xmake](https://github.com/xmake-io/xmake) 的跨平台 C/C++ 包管理器。 41 | 42 | 它基于 xmake 提供的运行时,但却是一个完整独立的包管理程序,相比 vcpkg/homebrew 此类包管理器,xrepo 能够同时提供更多平台和架构的 C/C++ 包。 43 | 44 | 并且还支持多版本语义选择,另外它还是一个去中心化的分布式仓库,不仅仅提供了官方的 [xmake-repo](https://github.com/xmake-io/xmake-repo) 仓库,还支持用户自建多个私有仓库。 45 | 46 | 同时,xrepo 也支持从 vcpkg/homebrew/conan 等第三方包管理器中安装包,并提供统一一致的库链接信息,方便与第三方项目的集成对接。 47 | 48 | 如果你想要了解更多,请参考:[在线文档](https://xrepo.xmake.io/#/zh-cn/getting_started), [Github](https://github.com/xmake-io/xrepo) 以及 [Gitee](https://gitee.com/tboox/xrepo) 49 | 50 | ![](https://github.com/xmake-io/xrepo-docs/raw/master/assets/img/xrepo.gif) 51 | 52 | ## 安装 53 | 54 | 我们只需要安装上 xmake 就可以使用 xrepo 命令,关于 xmake 的安装,我们可以看下:[xmake 安装文档](https://xmake.io/#/zh-cn/guide/installation)。 55 | 56 | ## 支持平台 57 | 58 | * Windows (x86, x64) 59 | * macOS (i386, x86_64, arm64) 60 | * Linux (i386, x86_64, cross-toolchains ..) 61 | * *BSD (i386, x86_64) 62 | * Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a) 63 | * iOS (armv7, armv7s, arm64, i386, x86_64) 64 | * MSYS (i386, x86_64) 65 | * MinGW (i386, x86_64, arm, arm64) 66 | * Cross Toolchains 67 | 68 | ## 支持的包管理仓库 69 | 70 | * 官方自建仓库 [xmake-repo](https://github.com/xmake-io/xmake-repo) (tbox >1.6.1) 71 | * [用户自建仓库](https://xmake.io/#/zh-cn/package/remote_package?id=%e4%bd%bf%e7%94%a8%e8%87%aa%e5%bb%ba%e7%a7%81%e6%9c%89%e5%8c%85%e4%bb%93%e5%ba%93) 72 | * Conan (conan::openssl/1.1.1g) 73 | * Vcpkg (vcpkg:ffmpeg) 74 | * Homebrew/Linuxbrew (brew::pcre2/libpcre2-8) 75 | * Pacman on archlinux/msys2 (pacman::libcurl) 76 | * Clib (clib::clibs/bytes@0.0.4) 77 | * Dub (dub::log 0.4.3) 78 | 79 | ## 分布式仓库支持 80 | 81 | 除了可以直接从官方仓库:[xmake-repo](https://github.com/xmake-io/xmake-repo) 检索安装包之外, 82 | 我们还可以添加任意多个自建的仓库,甚至可以完全隔离外网,仅仅在公司内部网络维护私有包的安装集成。 83 | 84 | 只需要通过下面的命令,添加上自己的仓库地址: 85 | 86 | ```console 87 | $ xrepo add-repo myrepo https://github.com/mygroup/myrepo 88 | ``` 89 | 90 | ## 与 xmake 的工程无缝集成 91 | 92 | ```lua 93 | add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8") 94 | add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true}) 95 | target("test") 96 | set_kind("binary") 97 | add_files("src/*.c") 98 | add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl") 99 | ``` 100 | 101 | 下面是与 xmake 集成的整体架构和编译流程。 102 | 103 | 104 | 105 | ## 快速上手 106 | 107 | ### 安装包 108 | 109 | #### 基本使用 110 | 111 | ```console 112 | $ xrepo install zlib tbox 113 | ``` 114 | 115 | #### 安装指定版本包 116 | 117 | 完整支持 Semantic Versioning (语义版本)。 118 | 119 | ```console 120 | $ xrepo install "zlib 1.2.x" 121 | $ xrepo install "zlib >=1.2.0" 122 | ``` 123 | 124 | #### 安装指定平台包 125 | 126 | ```console 127 | $ xrepo install -p iphoneos -a arm64 zlib 128 | $ xrepo install -p android [--ndk=/xxx] zlib 129 | $ xrepo install -p mingw [--mingw=/xxx] zlib 130 | $ xrepo install -p cross --sdk=/xxx/arm-linux-musleabi-cross zlib 131 | ``` 132 | 133 | #### 安装调试版本包 134 | 135 | ```console 136 | $ xrepo install -m debug zlib 137 | ``` 138 | 139 | #### 安装动态库版本包 140 | 141 | ```console 142 | $ xrepo install -k shared zlib 143 | ``` 144 | 145 | #### 安装指定配置包 146 | 147 | ```console 148 | $ xrepo install -f "vs_runtime='MD'" zlib 149 | $ xrepo install -f "regex=true,thread=true" boost 150 | ``` 151 | 152 | #### 安装第三方包管理器的包 153 | 154 | ```console 155 | $ xrepo install brew::zlib 156 | $ xrepo install vcpkg::zlib 157 | $ xrepo install conan::zlib/1.2.11 158 | $ xrepo install pacman:libpng 159 | $ xrepo install dub:log 160 | ``` 161 | 162 | ### 查找包的库使用信息 163 | 164 | ```console 165 | $ xrepo fetch pcre2 166 | { 167 | { 168 | linkdirs = { 169 | "/usr/local/Cellar/pcre2/10.33/lib" 170 | }, 171 | links = { 172 | "pcre2-8" 173 | }, 174 | defines = { 175 | "PCRE2_CODE_UNIT_WIDTH=8" 176 | }, 177 | includedirs = "/usr/local/Cellar/pcre2/10.33/include" 178 | } 179 | } 180 | ``` 181 | 182 | ```console 183 | $ xrepo fetch --ldflags openssl 184 | -L/Users/ruki/.xmake/packages/o/openssl/1.1.1/d639b7d6e3244216b403b39df5101abf/lib -lcrypto -lssl 185 | ``` 186 | 187 | ```console 188 | $ xrepo fetch --cflags openssl 189 | -I/Users/ruki/.xmake/packages/o/openssl/1.1.1/d639b7d6e3244216b403b39df5101abf/include 190 | ``` 191 | 192 | ```console 193 | $ xrepo fetch -p [iphoneos|android] --cflags "zlib 1.2.x" 194 | -I/Users/ruki/.xmake/packages/z/zlib/1.2.11/df72d410e7e14391b1a4375d868a240c/include 195 | ``` 196 | 197 | ```console 198 | $ xrepo fetch --cflags --ldflags conan::zlib/1.2.11 199 | -I/Users/ruki/.conan/data/zlib/1.2.11/_/_/package/f74366f76f700cc6e991285892ad7a23c30e6d47/include -L/Users/ruki/.conan/data/zlib/1.2.11/_/_/package/f74366f76f700cc6e991285892ad7a23c30e6d47/lib -lz 200 | ``` 201 | 202 | ### 导入导出安装后的包 203 | 204 | xrepo 可以快速导出已经安装后的包,包括对应的库文件,头文件等等。 205 | 206 | ```console 207 | $ xrepo export -o /tmp/output zlib 208 | ``` 209 | 210 | 也可以在其他机器上导入之前导出的安装包,实现包的迁移。 211 | 212 | ```console 213 | $ xrepo import -i /xxx/packagedir zlib 214 | ``` 215 | 216 | ### 搜索支持的包 217 | 218 | ```console 219 | $ xrepo search zlib "pcr*" 220 | zlib: 221 | -> zlib: A Massively Spiffy Yet Delicately Unobtrusive Compression Library (in xmake-repo) 222 | pcr*: 223 | -> pcre2: A Perl Compatible Regular Expressions Library (in xmake-repo) 224 | -> pcre: A Perl Compatible Regular Expressions Library (in xmake-repo) 225 | ``` 226 | 227 | 另外,现在还可以从 vcpkg, conan, conda 以及 apt 等第三方包管理器中搜索它们的包,只需要加上对应的包命名空间就行,例如: 228 | 229 | ```console 230 | $ xrepo search vcpkg::pcre 231 | The package names: 232 | vcpkg::pcre: 233 | -> vcpkg::pcre-8.44#8: Perl Compatible Regular Expressions 234 | -> vcpkg::pcre2-10.35#2: PCRE2 is a re-working of the original Perl Compatible Regular Expressions library 235 | ``` 236 | 237 | ```console 238 | $ xrepo search conan::openssl 239 | The package names: 240 | conan::openssl: 241 | -> conan::openssl/1.1.1g: 242 | -> conan::openssl/1.1.1h: 243 | ``` 244 | 245 | ### 查看包环境信息 246 | 247 | ```console 248 | $ xrepo env --show luajit 249 | { 250 | OLDPWD = "/mnt/tbox", 251 | HOME = "/home/ruki", 252 | PATH = "/home/ruki/.xmake/packages/l/luajit/2.1.0-beta3/fbac76d823b844f0b91abf3df0a3bc61/bin:/tmp:/tmp/arm-linux-musleabi-cross/bin:~/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 253 | TERM = "xterm", 254 | PWD = "/mnt/xmake", 255 | XMAKE_PROGRAM_DIR = "/mnt/xmake/xmake", 256 | HOSTNAME = "e6edd61ff1ab", 257 | LD_LIBRARY_PATH = "/home/ruki/.xmake/packages/l/luajit/2.1.0-beta3/fbac76d823b844f0b91abf3df0a3bc61/lib", 258 | SHLVL = "1", 259 | _ = "/mnt/xmake/scripts/xrepo.sh" 260 | } 261 | ``` 262 | 263 | ### 加载执行包环境并运行命令 264 | 265 | ```console 266 | $ xrepo env luajit 267 | LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/ 268 | JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse 269 | > 270 | ``` 271 | 272 | ```console 273 | $ xrepo env -b "luajit 2.x" luajit 274 | $ xrepo env -p iphoneos -b "zlib,libpng,luajit 2.x" cmake .. 275 | ``` 276 | 277 | ### 包虚拟环境 278 | 279 | #### 进入虚拟环境 280 | 281 | 我们可以通过在当前目录下,添加 xmake.lua 文件,定制化一些包配置,然后进入特定的包虚拟环境。 282 | 283 | ```lua 284 | add_requires("zlib 1.2.11") 285 | add_requires("python 3.x", "luajit") 286 | ``` 287 | 288 | ```console 289 | $ xrepo env shell 290 | > python --version 291 | > luajit --version 292 | ``` 293 | 294 | 我们也可以在 xmake.lua 配置加载对应的工具链环境,比如加载 vs 的编译环境。 295 | 296 | ```lua 297 | set_toolchains("msvc") 298 | ``` 299 | 300 | #### 管理虚拟环境 301 | 302 | 我们可以使用下面的命令,把指定的虚拟环境配置全局注册到系统中,方便快速切换。 303 | 304 | ```console 305 | $ xrepo env --add /tmp/base.lua 306 | ``` 307 | 308 | 这个时候,我们就保存了一个名叫 base 的全局虚拟环境,我们可以通过 list 命令去查看它。 309 | 310 | ```console 311 | $ xrepo env --list 312 | /Users/ruki/.xmake/envs: 313 | - base 314 | envs(1) found! 315 | ``` 316 | 317 | 我们也可以删除它。 318 | 319 | ```console 320 | $ xrepo env --remove base 321 | ``` 322 | 323 | #### 切换全局虚拟环境 324 | 325 | 如果我们注册了多个虚拟环境,我们也可以快速切换它们。 326 | 327 | ```console 328 | $ xrepo env -b base shell 329 | > python --version 330 | ``` 331 | 332 | 或者直接加载指定虚拟环境运行特定命令 333 | 334 | ```console 335 | $ xrepo env -b base python --version 336 | ``` 337 | 338 | `xrepo env -b/--bind` 就是绑定指定的虚拟环境,更多详情见:[#1762](https://github.com/xmake-io/xmake/issues/1762) 339 | 340 | ### 查看包信息 341 | 342 | ```console 343 | $ xrepo info zlib 344 | The package info of project: 345 | require(zlib): 346 | -> description: A Massively Spiffy Yet Delicately Unobtrusive Compression Library 347 | -> version: 1.2.11 348 | -> urls: 349 | -> http://zlib.net/zlib-1.2.11.tar.gz 350 | -> c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 351 | -> https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz 352 | -> c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 353 | -> repo: xmake-repo https://gitee.com/tboox/xmake-repo.git master 354 | -> cachedir: /Users/ruki/.xmake/cache/packages/2010/z/zlib/1.2.11 355 | -> installdir: /Users/ruki/.xmake/packages/z/zlib/1.2.11/d639b7d6e3244216b403b39df5101abf 356 | -> searchdirs: 357 | -> searchnames: zlib-1.2.11.tar.gz 358 | -> fetchinfo: 1.2.11, system 359 | -> version: 1.2.11 360 | -> links: z 361 | -> linkdirs: /usr/local/Cellar/zlib/1.2.11/lib 362 | -> includedirs: /usr/local/Cellar/zlib/1.2.11/include 363 | -> platforms: iphoneos, mingw@windows, macosx, mingw@linux,macosx, android@linux,macosx, windows, linux 364 | -> requires: 365 | -> plat: macosx 366 | -> arch: x86_64 367 | -> configs: 368 | -> debug: false 369 | -> vs_runtime: MT 370 | -> shared: false 371 | -> configs: 372 | -> configs (builtin): 373 | -> debug: Enable debug symbols. (default: false) 374 | -> shared: Enable shared library. (default: false) 375 | -> cflags: Set the C compiler flags. 376 | -> cxflags: Set the C/C++ compiler flags. 377 | -> cxxflags: Set the C++ compiler flags. 378 | -> asflags: Set the assembler flags. 379 | -> vs_runtime: Set vs compiler runtime. (default: MT) 380 | -> values: {"MT","MD"} 381 | ``` 382 | 383 | ### 卸载所有的包 384 | 385 | 我们可以通过下面的命令,批量卸载删除已经安装的包,支持模式匹配: 386 | 387 | ```bash 388 | $ xrepo remove --all 389 | $ xrepo remove --all zlib pcr* 390 | ``` 391 | 392 | ## 联系方式 393 | 394 | * 邮箱:[waruqi@gmail.com](mailto:waruqi@gmail.com) 395 | * 主页:[xmake.io](https://xmake.io/#/zh-cn/) 396 | * 社区:[Reddit论坛](https://www.reddit.com/r/xmake/) 397 | * 聊天:[Telegram群组](https://t.me/tbooxorg), [Gitter聊天室](https://gitter.im/xmake-io/xmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 398 | * 源码:[Github](https://github.com/xmake-io/xmake), [Gitee](https://gitee.com/tboox/xmake) 399 | * QQ群:343118190(技术支持), 662147501 400 | * 微信公众号:tboox-os 401 | 402 | -------------------------------------------------------------------------------- /src/xrepo.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | xmake lua private.xrepo %* 3 | -------------------------------------------------------------------------------- /src/xrepo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | if [ -f "$BASEDIR/xmake" ]; then 4 | $BASEDIR/xmake lua private.xrepo "$@" 5 | else 6 | xmake lua private.xrepo "$@" 7 | fi 8 | --------------------------------------------------------------------------------