2
0

getting_started.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>xrepo</title>
  6. <link rel="icon" href="/assets/img/favicon.ico">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  8. <meta name="description" content="Description">
  9. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  10. <link href="//cdn.jsdelivr.net/npm/[email protected]/github-markdown.min.css" rel="stylesheet">
  11. <style>
  12. .markdown-body {
  13. box-sizing: border-box;
  14. min-width: 200px;
  15. max-width: 980px;
  16. margin: 0 auto;
  17. padding: 45px;
  18. }
  19. @media (max-width: 767px) {
  20. .markdown-body {
  21. padding: 15px;
  22. }
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <article class="markdown-body">
  28. <h4>This is a mirror page, please see the original page: </h4><a href="https://xrepo.xmake.io/#/getting_started">https://xrepo.xmake.io/#/getting_started</a>
  29. <div id="wwads-panel" class="wwads-cn wwads-vertical wwads-sticky" data-id="239" style="max-width:180px;bottom:20px;right:20px;width:200px;height:260px;background:#fff;position:fixed"></div>
  30. </br>
  31. <script type="text/javascript" charset="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
  32. <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CE7I52QU&placement=xmakeio" id="_carbonads_js"></script>
  33. <style>
  34. #carbonads {
  35. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
  36. Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
  37. }
  38. #carbonads {
  39. display: flex;
  40. max-width: 330px;
  41. background-color: hsl(0, 0%, 98%);
  42. box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, .1);
  43. }
  44. #carbonads a {
  45. color: inherit;
  46. text-decoration: none;
  47. }
  48. #carbonads a:hover {
  49. color: inherit;
  50. }
  51. #carbonads span {
  52. position: relative;
  53. display: block;
  54. overflow: hidden;
  55. }
  56. #carbonads .carbon-wrap {
  57. display: flex;
  58. }
  59. .carbon-img {
  60. display: block;
  61. margin: 0;
  62. line-height: 1;
  63. }
  64. .carbon-img img {
  65. display: block;
  66. }
  67. .carbon-text {
  68. font-size: 13px;
  69. padding: 10px;
  70. line-height: 1.5;
  71. text-align: left;
  72. }
  73. .carbon-poweredby {
  74. display: block;
  75. padding: 8px 10px;
  76. background: repeating-linear-gradient(-45deg, transparent, transparent 5px, hsla(0, 0%, 0%, .025) 5px, hsla(0, 0%, 0%, .025) 10px) hsla(203, 11%, 95%, .4);
  77. text-align: center;
  78. text-transform: uppercase;
  79. letter-spacing: .5px;
  80. font-weight: 600;
  81. font-size: 9px;
  82. line-height: 1;
  83. }
  84. </style>
  85. <h2 id="introduction">Introduction</h2>
  86. <p>xrepo is a cross-platform C/C++ package manager based on <a href="https://github.com/xmake-io/xmake">Xmake</a>.</p>
  87. <p>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.</p>
  88. <p>And it also supports multi-version semantic selection. In addition, it is also a decentralized distributed repository. It not only provides the official <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a> repository, It also supports users to build multiple private repositorys.</p>
  89. <p>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.</p>
  90. <p>If you want to know more, please refer to: <a href="https://xmake.io/#/home">Documents</a>, <a href="https://github.com/xmake-io/xrepo">Github</a> and <a href="https://gitee.com/tboox/xrepo">Gitee</a>. You can also <a href="https://xmake.microblock.cc">search packages here</a>.</p>
  91. <p><img src="https://github.com/xmake-io/xrepo-docs/raw/master/assets/img/xrepo.gif" alt=""></p>
  92. <h2 id="installation">Installation</h2>
  93. <p>We only need install xmake to use the xrepo command. About the installation of xmake, we can see: <a href="https://xmake.io/#/guide/installation">Xmake Installation Document</a>.</p>
  94. <h2 id="supportedplatforms">Supported platforms</h2>
  95. <ul>
  96. <li>Windows (x86, x64)</li>
  97. <li>macOS (i386, x86_64, arm64)</li>
  98. <li>Linux (i386, x86_64, cross-toolchains ..)</li>
  99. <li>*BSD (i386, x86_64)</li>
  100. <li>Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a)</li>
  101. <li>iOS (armv7, armv7s, arm64, i386, x86_64)</li>
  102. <li>MSYS (i386, x86_64)</li>
  103. <li>MinGW (i386, x86_64, arm, arm64)</li>
  104. <li>Cross Toolchains</li>
  105. </ul>
  106. <h2 id="supporydistributedrepository">Suppory distributed repository</h2>
  107. <p>In addition to directly retrieving the installation package from the official repository: <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a>.</p>
  108. <p>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&#39;s internal network.</p>
  109. <p>Just use the following command to add your own repository address:</p>
  110. <pre><code class="lang-console">$ xrepo add-repo myrepo https://github.com/mygroup/myrepo
  111. </code></pre>
  112. <h2 id="seamlessintegrationwithxmakeproject">Seamless integration with xmake project</h2>
  113. <pre><code class="lang-lua">add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8")
  114. add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true})
  115. target("test")
  116. set_kind("binary")
  117. add_files("src/*.c")
  118. add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl")
  119. </code></pre>
  120. <p>The following is the overall architecture and compilation process integrated with xmake.</p>
  121. <p><img src="https://xmake.io/assets/img/index/package_arch.png" width="650px" /></p>
  122. <h2 id="getstarted">Get started</h2>
  123. <h3 id="installationpackage">Installation package</h3>
  124. <h4 id="basicusage">Basic usage</h4>
  125. <pre><code class="lang-console">$ xrepo install zlib tbox
  126. </code></pre>
  127. <h4 id="installthespecifiedversionpackage">Install the specified version package</h4>
  128. <pre><code class="lang-console">$ xrepo install "zlib 1.2.x"
  129. $ xrepo install "zlib >=1.2.0"
  130. </code></pre>
  131. <h4 id="installthespecifiedplatformpackage">Install the specified platform package</h4>
  132. <pre><code class="lang-console">$ xrepo install -p iphoneos -a arm64 zlib
  133. $ xrepo install -p android [--ndk=/xxx] zlib
  134. $ xrepo install -p mingw [--mingw=/xxx] zlib
  135. $ xrepo install -p cross --sdk=/xxx/arm-linux-musleabi-cross zlib
  136. </code></pre>
  137. <h4 id="installthedebugpackage">Install the debug package</h4>
  138. <pre><code class="lang-console">$ xrepo install -m debug zlib
  139. </code></pre>
  140. <h4 id="installthepackagewithdynamiclibrary">Install the package with dynamic library</h4>
  141. <pre><code class="lang-console">$ xrepo install -k shared zlib
  142. </code></pre>
  143. <h4 id="installthespecifiedconfigurationpackage">Install the specified configuration package</h4>
  144. <pre><code class="lang-console">$ xrepo install -f "vs_runtime=&#39;MD&#39;" zlib
  145. $ xrepo install -f "regex=true,thread=true" boost
  146. </code></pre>
  147. <h4 id="installpackagesfromthirdpartypackagemanager">Install packages from third-party package manager</h4>
  148. <pre><code class="lang-console">$ xrepo install brew::zlib
  149. $ xrepo install vcpkg::zlib
  150. $ xrepo install conan::zlib/1.2.11
  151. </code></pre>
  152. <h3 id="findthelibraryinformationofthepackage">Find the library information of the package</h3>
  153. <pre><code class="lang-console">$ xrepo fetch pcre2
  154. {
  155. {
  156. linkdirs = {
  157. "/usr/local/Cellar/pcre2/10.33/lib"
  158. },
  159. links = {
  160. "pcre2-8"
  161. },
  162. defines = {
  163. "PCRE2_CODE_UNIT_WIDTH=8"
  164. },
  165. includedirs = "/usr/local/Cellar/pcre2/10.33/include"
  166. }
  167. }
  168. </code></pre>
  169. <pre><code class="lang-console">$ xrepo fetch --ldflags openssl
  170. -L/Users/ruki/.xmake/packages/o/openssl/1.1.1/d639b7d6e3244216b403b39df5101abf/lib -lcrypto -lssl
  171. </code></pre>
  172. <pre><code class="lang-console">$ xrepo fetch --cflags openssl
  173. -I/Users/ruki/.xmake/packages/o/openssl/1.1.1/d639b7d6e3244216b403b39df5101abf/include
  174. </code></pre>
  175. <pre><code class="lang-console">$ xrepo fetch -p [iphoneos|android] --cflags "zlib 1.2.x"
  176. -I/Users/ruki/.xmake/packages/z/zlib/1.2.11/df72d410e7e14391b1a4375d868a240c/include
  177. </code></pre>
  178. <pre><code class="lang-console">$ xrepo fetch --cflags --ldflags conan::zlib/1.2.11
  179. -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
  180. </code></pre>
  181. <h3 id="exporttheinstalledpackages">Export the installed packages</h3>
  182. <p>xrepo can quickly export installed packages, including corresponding library files, header files, etc.</p>
  183. <pre><code class="lang-console">$ xrepo export -o /tmp/output zlib
  184. </code></pre>
  185. <h3 id="searchsupportedpackages">Search supported packages</h3>
  186. <pre><code class="lang-console">$ xrepo search zlib "pcr*"
  187. zlib:
  188. -> zlib: A Massively Spiffy Yet Delicately Unobtrusive Compression Library (in xmake-repo)
  189. pcr*:
  190. -> pcre2: A Perl Compatible Regular Expressions Library (in xmake-repo)
  191. -> pcre: A Perl Compatible Regular Expressions Library (in xmake-repo)
  192. </code></pre>
  193. <h3 id="showpackageenvironmentinformation">Show package environment information</h3>
  194. <pre><code class="lang-console">$ xrepo env --show luajit
  195. {
  196. OLDPWD = "/mnt/tbox",
  197. HOME = "/home/ruki",
  198. 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",
  199. TERM = "xterm",
  200. PWD = "/mnt/xmake",
  201. XMAKE_PROGRAM_DIR = "/mnt/xmake/xmake",
  202. HOSTNAME = "e6edd61ff1ab",
  203. LD_LIBRARY_PATH = "/home/ruki/.xmake/packages/l/luajit/2.1.0-beta3/fbac76d823b844f0b91abf3df0a3bc61/lib",
  204. SHLVL = "1",
  205. _ = "/mnt/xmake/scripts/xrepo.sh"
  206. }
  207. </code></pre>
  208. <h3 id="packagevirtualenvironment">Package virtual environment</h3>
  209. <h4 id="enterthevirtualenvironment">Enter the virtual environment</h4>
  210. <p>We can customize some package configurations by adding the xmake.lua file in the current directory, and then enter the specific package virtual environment.</p>
  211. <pre><code class="lang-lua">add_requires("zlib 1.2.11")
  212. add_requires("python 3.x", "luajit")
  213. </code></pre>
  214. <pre><code class="lang-console">$ xrepo env shell
  215. > python --version
  216. > luajit --version
  217. </code></pre>
  218. <p>We can also configure and load the corresponding toolchain environment in xmake.lua, for example, load the VS compilation environment.</p>
  219. <pre><code class="lang-lua">set_toolchains("msvc")
  220. </code></pre>
  221. <h4 id="managevirtualenvironments">Manage virtual environments</h4>
  222. <p>We can use the following command to register the specified virtual environment configuration globally to the system for quick switching.</p>
  223. <pre><code class="lang-console">$ xrepo env --add /tmp/base.lua
  224. </code></pre>
  225. <p>At this time, we have saved a global virtual environment called base, and we can view it through the list command.</p>
  226. <pre><code class="lang-console">$ xrepo env --list
  227. /Users/ruki/.xmake/envs:
  228. -base
  229. envs(1) found!
  230. </code></pre>
  231. <p>We can also delete it.</p>
  232. <pre><code class="lang-console">$ xrepo env --remove base
  233. </code></pre>
  234. <h4 id="switchglobalvirtualenvironment">Switch global virtual environment</h4>
  235. <p>If we register multiple virtual environments, we can also switch them quickly.</p>
  236. <pre><code class="lang-console">$ xrepo env -b base shell
  237. > python --version
  238. </code></pre>
  239. <p>Or directly load the specified virtual environment to run specific commands</p>
  240. <pre><code class="lang-console">$ xrepo env -b base python --version
  241. </code></pre>
  242. <p><code>xrepo env -b/--bind</code> is to bind the specified virtual environment. For more details, see: <a href="https://github.com/xmake-io/xmake/issues/1762">#1762</a></p>
  243. <h4 id="quickswitchingoftemporaryvirtualenvironments">Quick switching of temporary virtual environments</h4>
  244. <p>Not only can we manage switching environments by configuring environment configuration files such as <code>myenv.lua</code>, but we can also specify a list of environment packages to bind to on the command line on an ad hoc basis, allowing for quick switching without any configuration.</p>
  245. <p>For example, if we want to enter an environment with python 3.0, luajit and cmake, all we need to do is to execute</p>
  246. <pre><code class="lang-console">$ xrepo env -b "python 3.x,luajit,cmake" shell
  247. [python,luajit,cmake] $ python --version
  248. Python 3.10.6
  249. [python,luajit,cmake] $ cmake --version
  250. cmake version 3.25.3
  251. `
  252. </code></pre>
  253. <p>Xmake will automatically install the dependencies and open a new shell environment, which will also have a prompt on the left side of the terminal.</p>
  254. <p>If we want to exit the current environment, we simply need to run</p>
  255. <pre><code class="lang-console">[python,luajit,cmake] $ xrepo env quit
  256. $
  257. </code></pre>
  258. <h3 id="showthegivenpackageinformation">Show the given package information</h3>
  259. <pre><code class="lang-console">$ xrepo info zlib
  260. The package info of project:
  261. require(zlib):
  262. -> description: A Massively Spiffy Yet Delicately Unobtrusive Compression Library
  263. -> version: 1.2.11
  264. -> urls:
  265. -> http://zlib.net/zlib-1.2.11.tar.gz
  266. -> c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
  267. -> https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
  268. -> c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
  269. -> repo: xmake-repo https://gitee.com/tboox/xmake-repo.git master
  270. -> cachedir: /Users/ruki/.xmake/cache/packages/2010/z/zlib/1.2.11
  271. -> installdir: /Users/ruki/.xmake/packages/z/zlib/1.2.11/d639b7d6e3244216b403b39df5101abf
  272. -> searchdirs:
  273. -> searchnames: zlib-1.2.11.tar.gz
  274. -> fetchinfo: 1.2.11, system
  275. -> version: 1.2.11
  276. -> links: z
  277. -> linkdirs: /usr/local/Cellar/zlib/1.2.11/lib
  278. -> includedirs: /usr/local/Cellar/zlib/1.2.11/include
  279. -> platforms: iphoneos, mingw@windows, macosx, mingw@linux,macosx, android@linux,macosx, windows, linux
  280. -> requires:
  281. -> plat: macosx
  282. -> arch: x86_64
  283. -> configs:
  284. -> debug: false
  285. -> vs_runtime: MT
  286. -> shared: false
  287. -> configs:
  288. -> configs (builtin):
  289. -> debug: Enable debug symbols. (default: false)
  290. -> shared: Enable shared library. (default: false)
  291. -> cflags: Set the C compiler flags.
  292. -> cxflags: Set the C/C++ compiler flags.
  293. -> cxxflags: Set the C++ compiler flags.
  294. -> asflags: Set the assembler flags.
  295. -> vs_runtime: Set vs compiler runtime. (default: MT)
  296. -> values: {"MT","MD"}
  297. </code></pre>
  298. <h3 id="downloadpackagesourcecode">Download package source code</h3>
  299. <p>We can use the <code>xrepo download</code> command to only download the source code of the specified package without installing it.</p>
  300. <pre><code class="lang-bash">$ xrepo download zlib
  301. $ xrepo download "zlib 2.x"
  302. </code></pre>
  303. <p>The default download directory is in the <code>packages</code> subdirectory of the current directory. We can also modify the download directory through the <code>-o outputdir</code> parameter.</p>
  304. <pre><code class="lang-bash">$ xrepo download -o /tmp zlib
  305. </code></pre>
  306. </article>
  307. </body>
  308. </html>