index.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>xmake</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="/assets/npm/github-markdown/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://xmake.io/#/">https://xmake.io/#/</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="supportthisproject">Support this project</h2>
  86. <p>Support this project by <a href="https://xmake.io/#/about/sponsor">becoming a sponsor</a>. Your logo will show up here with a link to your website. 🙏</p>
  87. <p><a href="https://opencollective.com/xmake#sponsors" target="_blank"><img src="https://opencollective.com/xmake/sponsors.svg?width=890"></a><br><a href="https://opencollective.com/xmake#backers" target="_blank"><img src="https://opencollective.com/xmake/backers.svg?width=890"></a></p>
  88. <h2 id="technicalsupport">Technical support</h2>
  89. <p>You can also consider sponsoring us to get extra technical support services via the <a href="https://github.com/sponsors/waruqi">Github sponsor program</a>. If you do, you can get access to the <a href="https://github.com/xmake-io/technical-support">xmake-io/technical-support</a> repository, which has the following bennefits:</p>
  90. <ul>
  91. <li>[X] Handling Issues with higher priority</li>
  92. <li>[X] One-to-one technical consulting service</li>
  93. <li>[X] Review your xmake.lua and provide suggestions for improvement</li>
  94. </ul>
  95. <h2 id="introduction">Introduction</h2>
  96. <p>What is Xmake?</p>
  97. <ol>
  98. <li>Xmake is a cross-platform build utility based on the Lua scripting language.</li>
  99. <li>Xmake is very lightweight and has no dependencies outside of the standard library.</li>
  100. <li>Uses the <code>xmake.lua</code> file to maintain project builds with a simple and readable syntax.</li>
  101. </ol>
  102. <p>Xmake can be used to directly build source code (like with Make or Ninja), or it can generate project source files like CMake or Meson. It also has a <em>built-in</em> package management system to help users integrate C/C++ dependencies.</p>
  103. <pre><code>Xmake = Build backend + Project Generator + Package Manager + [Remote|Distributed] Build + Cache
  104. </code></pre><p>Although less precise, one can still understand Xmake in the following way:</p>
  105. <pre><code>Xmake ≈ Make/Ninja + CMake/Meson + Vcpkg/Conan + distcc + ccache/sccache
  106. </code></pre><p>If you want to know more, please refer to: the <a href="https://xmake.io/#/getting_started">Documentation</a>, <a href="https://github.com/xmake-io/xmake">GitHub</a> or <a href="https://gitee.com/tboox/xmake">Gitee</a>. You are also welcome to join our <a href="https://xmake.io/#/about/contact">community</a>.</p>
  107. <p>The official Xmake repository can be found at <a href="https://github.com/xmake-io/xmake-repo">xmake-io/xmake-repo</a>.</p>
  108. <h2 id="installation">Installation</h2>
  109. <h3 id="withcurl">With cURL</h3>
  110. <pre><code class="lang-bash">curl -fsSL https://xmake.io/shget.text | bash
  111. </code></pre>
  112. <h3 id="withwget">With Wget</h3>
  113. <pre><code class="lang-bash">wget https://xmake.io/shget.text -O - | bash
  114. </code></pre>
  115. <h3 id="withpowershell">With PowerShell</h3>
  116. <pre><code class="lang-sh">Invoke-Expression (Invoke-Webrequest &#39;https://xmake.io/psget.text&#39; -UseBasicParsing).Content
  117. </code></pre>
  118. <h3 id="otherinstallationmethods">Other installation methods</h3>
  119. <p>If you don&#39;t want to use the above scripts to install Xmake, visit the <a href="https://xmake.io/#/guide/installation">Installation Guide</a> for other installation methods (building from source, package managers, etc.).</p>
  120. <h2 id="simpleprojectdescription">Simple Project Description</h2>
  121. <pre><code class="lang-lua">target("console")
  122. set_kind("binary")
  123. add_files("src/*.c")
  124. </code></pre>
  125. <p>Creates a new target <code>console</code> of kind <code>binary</code>, and adds all the files ending in <code>.c</code> in the <code>src</code> directory.</p>
  126. <h2 id="packagedependences">Package dependences</h2>
  127. <pre><code class="lang-lua">add_requires("tbox 1.6.*", "zlib", "libpng ~1.6")
  128. </code></pre>
  129. <p>Adds a requirement of tbox v1.6, zlib (any version), and libpng v1.6.</p>
  130. <p>The official xmake package repository exists at: <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a></p>
  131. <p><p align="center"><br><img src="https://github.com/xmake-io/xmake-docs/raw/master/assets/img/index/package.gif" width="650px" /><br></p>
  132. </p>
  133. <h2 id="commandlineinterfacereference">Commandline interface reference</h2>
  134. <p>The below assumes you are currently in the project&#39;s root directory.</p>
  135. <h3 id="buildaproject">Build a project</h3>
  136. <pre><code class="lang-bash">$ xmake
  137. </code></pre>
  138. <h3 id="runtarget">Run target</h3>
  139. <pre><code class="lang-bash">$ xmake run console
  140. </code></pre>
  141. <h3 id="debugtarget">Debug target</h3>
  142. <pre><code class="lang-bash">$ xmake run -d console
  143. </code></pre>
  144. <h3 id="configureplatform">Configure platform</h3>
  145. <pre><code class="lang-bash">$ xmake f -p [windows|linux|macosx|android|iphoneos ..] -a [x86|arm64 ..] -m [debug|release]
  146. $ xmake
  147. </code></pre>
  148. <h3 id="menuconfiguration">Menu configuration</h3>
  149. <pre><code class="lang-bash">$ xmake f --menu
  150. </code></pre>
  151. <p><p align="center"><br><img src="https://xmake.io/assets/img/index/menuconf.png" width="650px"/><br></p>
  152. </p>
  153. <h2 id="supportedplatforms">Supported platforms</h2>
  154. <ul>
  155. <li>Windows (x86, x64)</li>
  156. <li>macOS (i386, x86_64, arm64)</li>
  157. <li>Linux (i386, x86_64, cross-toolchains ..)</li>
  158. <li>*BSD (i386, x86_64)</li>
  159. <li>Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a)</li>
  160. <li>iOS (armv7, armv7s, arm64, i386, x86_64)</li>
  161. <li>WatchOS (armv7k, i386)</li>
  162. <li>AppleTVOS (armv7, arm64, i386, x86_64)</li>
  163. <li>MSYS (i386, x86_64)</li>
  164. <li>MinGW (i386, x86_64, arm, arm64)</li>
  165. <li>Cygwin (i386, x86_64)</li>
  166. <li>Wasm (wasm32)</li>
  167. <li>Cross (cross-toolchains ..)</li>
  168. </ul>
  169. <h2 id="supportedtoolchains">Supported toolchains</h2>
  170. <h3 id="idetied">IDE-Tied</h3>
  171. <ul>
  172. <li>Xcode</li>
  173. <li>MSVC (Microsoft Visual C compiler)</li>
  174. <li>Android NDK</li>
  175. </ul>
  176. <h3 id="languages">Languages</h3>
  177. <ul>
  178. <li>Zig</li>
  179. <li>Go(lang)</li>
  180. <li>Swift</li>
  181. <li>Nim</li>
  182. <li>Rust</li>
  183. <li>GCC (GNU Compiler Collection)</li>
  184. <li>Clang</li>
  185. <li>TinyCC</li>
  186. <li>icc (Intel C Compiler)</li>
  187. <li>icpc (Intel C++ Compiler)</li>
  188. <li>icx (Intel LLVM C/C++ Compiler)</li>
  189. <li>Clang-CL (Clang Compatability with MSVC)</li>
  190. <li>DPC++ (Intel LLVM C++ Compiler using SYCL)</li>
  191. <li>MinGW (GNU for Windows)</li>
  192. <li>C51 (Keil C Compiler for the 8051)</li>
  193. <li>GNU-RM (GNU Arm Embedded Toolchain)</li>
  194. <li>ArmCC (Keil C Compiler for Keil MKD Version 5)</li>
  195. <li>Circle (New C++20 compiler)</li>
  196. <li>WASI (C/C++ WebAssembly Toolchain)</li>
  197. <li>ArmClang (Version 6 of the Keil MDK)</li>
  198. <li>SDCC (Small Device C Compiler)</li>
  199. <li>GDC (GNU D Compiler)</li>
  200. <li>LDC (LLVM D Compiler)</li>
  201. <li>DMD (Dlang)</li>
  202. <li>FPC (Free Pascal Programming Language Compiler)</li>
  203. <li>GFortran (GNU Fortran Compiler)</li>
  204. <li>Ifort (Intel Fortran Compiler)</li>
  205. <li>CUDA (nvcc, nvc, nvc++, nvfortran)</li>
  206. <li>Emscripten</li>
  207. <li>LLVM</li>
  208. <li>Icarus Verilog</li>
  209. <li>Verilator (SystemVerilog simulator and lint system)</li>
  210. </ul>
  211. <h3 id="assemblers">Assemblers</h3>
  212. <ul>
  213. <li>FASM</li>
  214. <li>NASM</li>
  215. <li>YASM</li>
  216. <li>MASM32 (Microsoft Macro Assembler 32-bit SDK)</li>
  217. </ul>
  218. <h2 id="supportedlanguages">Supported languages</h2>
  219. <ul>
  220. <li>C, C++ (including cpp2)</li>
  221. <li>Objective-C and Objective-C++</li>
  222. <li>Swift</li>
  223. <li>Assembly</li>
  224. <li>Golang</li>
  225. <li>Rust</li>
  226. <li>Dlang</li>
  227. <li>Fortran</li>
  228. <li>Cuda</li>
  229. <li>Zig</li>
  230. <li>Vala</li>
  231. <li>Pascal</li>
  232. <li>Nim</li>
  233. <li>Verilog</li>
  234. <li>FASM</li>
  235. <li>NASM</li>
  236. <li>YASM</li>
  237. <li>MASM32</li>
  238. </ul>
  239. <h2 id="features">Features</h2>
  240. <p>Xmake exhibits:</p>
  241. <ul>
  242. <li>Simple yet flexible configuration grammar.</li>
  243. <li>Quick, dependency-free installation.</li>
  244. <li>Easy compilation for most all supported platforms.</li>
  245. <li>Supports cross-compilation with intelligent analysis of cross toolchain information.</li>
  246. <li>Extremely fast parallel compilation support.</li>
  247. <li>Supports C++ modules (new in C++20).</li>
  248. <li>Supports cross-platform C/C++ dependencies with built-in package manager.</li>
  249. <li>Multi-language compilation support including mixed-language projects.</li>
  250. <li>Rich plug-in support with various project generators (ex. Visual Studio/Makefiles/CMake/<code>compile_commands.json</code>)</li>
  251. <li>REPL interactive execution support</li>
  252. <li>Incremental compilation support with automatic analysis of header files</li>
  253. <li>Built-in toolchain management</li>
  254. <li>A large number of expansion modules</li>
  255. <li>Remote compilation support</li>
  256. <li>Distributed compilation support</li>
  257. <li>Local and remote build cache support</li>
  258. </ul>
  259. <h2 id="supportedprojecttypes">Supported Project Types</h2>
  260. <p>Xmake supports the below types of projects:</p>
  261. <ul>
  262. <li>Static libraries</li>
  263. <li>Shared libraries</li>
  264. <li>Console/CLI applications</li>
  265. <li>CUDA programs</li>
  266. <li>Qt applications</li>
  267. <li>WDK drivers (umdf/kmdf/wdm)</li>
  268. <li>WinSDK applications</li>
  269. <li>MFC applications</li>
  270. <li>Darwin applications (with metal support)</li>
  271. <li>Frameworks and bundles (in Darwin)</li>
  272. <li>SWIG modules (Lua, Python, ...)</li>
  273. <li>LuaRocks modules</li>
  274. <li>Protobuf programs</li>
  275. <li>Lex/Yacc programs</li>
  276. <li>Linux kernel modules</li>
  277. </ul>
  278. <h2 id="packagemanagement">Package management</h2>
  279. <h3 id="downloadandbuild">Download and build</h3>
  280. <p>Xmake can automatically fetch and install dependencies!</p>
  281. <p><p align="center"><br><img src="https://xmake.io/assets/img/index/package_manage.png" width="650px" /><br></p>
  282. </p>
  283. <h3 id="supportedpackagerepositories">Supported package repositories</h3>
  284. <ul>
  285. <li>Official package repository <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a> (tbox >1.6.1)</li>
  286. <li>Official package manager <a href="https://github.com/xmake-io/xrepo">Xrepo</a></li>
  287. <li><a href="https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository">User-built repositories</a></li>
  288. <li>Conan (conan::openssl/1.1.1g)</li>
  289. <li>Conda (conda::libpng 1.3.67)</li>
  290. <li>Vcpkg (vcpkg::ffmpeg)</li>
  291. <li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
  292. <li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
  293. <li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
  294. <li>Clib (clib::<a href="mailto:clibs/[email protected]">clibs/[email protected]</a>)</li>
  295. <li>Dub (dub::log 0.4.3)</li>
  296. <li>Portage on Gentoo/Linux (portage::libhandy)</li>
  297. <li>Nimble for nimlang (nimble::zip >1.3)</li>
  298. <li>Cargo for rust (cargo::base64 0.13.0)</li>
  299. </ul>
  300. <h3 id="packagemanagementfeatures">Package management features</h3>
  301. <ul>
  302. <li>The official repository provides nearly 500+ packages with simple compilation on all supported platforms</li>
  303. <li>Full platform package support, support for cross-compiled dependent packages</li>
  304. <li>Support package virtual environment using <code>xrepo env shell</code></li>
  305. <li>Precompiled package acceleration for Windows (NT)</li>
  306. <li>Support self-built package repositories and private repository deployment</li>
  307. <li>Third-party package repository support for repositories such as: vcpkg, conan, conda, etc.</li>
  308. <li>Supports automatic pulling of remote toolchains</li>
  309. <li>Supports dependency version locking</li>
  310. </ul>
  311. <h2 id="processingarchitecture">Processing architecture</h2>
  312. <p>Below is a diagram showing roughly the architecture of Xmake, and thus how it functions.</p>
  313. <p><p align="center"><br><img src="https://xmake.io/assets/img/index/package_arch.png" width="650px" /><br></p>
  314. </p>
  315. <h2 id="distributedcompilation">Distributed Compilation</h2>
  316. <ul>
  317. <li>[X] Cross-platform support.</li>
  318. <li>[X] Support for MSVC, Clang, GCC and other cross-compilation toolchains.</li>
  319. <li>[X] Support for building for Android, Linux, Windows NT, and Darwin hosts.</li>
  320. <li>[X] No dependencies other than the compilation toolchain.</li>
  321. <li>[X] Support for build server load balancing scheduling.</li>
  322. <li>[X] Support for real time compressed transfer of large files (lz4).</li>
  323. <li>[X] Almost zero configuration cost, no shared filesystem required, for convenience and security.</li>
  324. </ul>
  325. <p>For more details see: <a href="https://github.com/xmake-io/xmake/issues/274">#274</a></p>
  326. <h2 id="remotecompilation">Remote Compilation</h2>
  327. <p>For more details see: <a href="https://github.com/xmake-io/xmake/issues/622">#622</a></p>
  328. <h2 id="localremotebuildcache">Local/Remote Build Cache</h2>
  329. <p>For more details see: <a href="https://github.com/xmake-io/xmake/issues/2371">#622</a></p>
  330. <h2 id="benchmark">Benchmark</h2>
  331. <p>Xmake&#39;s speed on is par with Ninja! The test project: <a href="https://github.com/xmake-io/xmake/tree/master/core">xmake-core</a></p>
  332. <h3 id="multitaskparallelcompilation">Multi-task parallel compilation</h3>
  333. <table>
  334. <thead>
  335. <tr>
  336. <th>buildsystem</th>
  337. <th>Termux (8core/-j12)</th>
  338. <th>buildsystem</th>
  339. <th>MacOS (8core/-j12)</th>
  340. </tr>
  341. </thead>
  342. <tbody>
  343. <tr>
  344. <td>xmake</td>
  345. <td>24.890s</td>
  346. <td>xmake</td>
  347. <td>12.264s</td>
  348. </tr>
  349. <tr>
  350. <td>ninja</td>
  351. <td>25.682s</td>
  352. <td>ninja</td>
  353. <td>11.327s</td>
  354. </tr>
  355. <tr>
  356. <td>cmake(gen+make)</td>
  357. <td>5.416s+28.473s</td>
  358. <td>cmake(gen+make)</td>
  359. <td>1.203s+14.030s</td>
  360. </tr>
  361. <tr>
  362. <td>cmake(gen+ninja)</td>
  363. <td>4.458s+24.842s</td>
  364. <td>cmake(gen+ninja)</td>
  365. <td>0.988s+11.644s</td>
  366. </tr>
  367. </tbody>
  368. </table>
  369. <h2 id="singletaskcompilation">Single task compilation</h2>
  370. <table>
  371. <thead>
  372. <tr>
  373. <th>buildsystem</th>
  374. <th>Termux (-j1)</th>
  375. <th>buildsystem</th>
  376. <th>MacOS (-j1)</th>
  377. </tr>
  378. </thead>
  379. <tbody>
  380. <tr>
  381. <td>xmake</td>
  382. <td>1m57.707s</td>
  383. <td>xmake</td>
  384. <td>39.937s</td>
  385. </tr>
  386. <tr>
  387. <td>ninja</td>
  388. <td>1m52.845s</td>
  389. <td>ninja</td>
  390. <td>38.995s</td>
  391. </tr>
  392. <tr>
  393. <td>cmake(gen+make)</td>
  394. <td>5.416s+2m10.539s</td>
  395. <td>cmake(gen+make)</td>
  396. <td>1.203s+41.737s</td>
  397. </tr>
  398. <tr>
  399. <td>cmake(gen+ninja)</td>
  400. <td>4.458s+1m54.868s</td>
  401. <td>cmake(gen+ninja)</td>
  402. <td>0.988s+38.022s</td>
  403. </tr>
  404. </tbody>
  405. </table>
  406. <h2 id="moreexamples">More Examples</h2>
  407. <h3 id="debugandreleaseprofiles">Debug and release profiles</h3>
  408. <pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
  409. target("console")
  410. set_kind("binary")
  411. add_files("src/*.c")
  412. if is_mode("debug") then
  413. add_defines("DEBUG")
  414. end
  415. </code></pre>
  416. <h3 id="customscripts">Custom scripts</h3>
  417. <pre><code class="lang-lua">target("test")
  418. set_kind("binary")
  419. add_files("src/*.c")
  420. after_build(function (target)
  421. print("hello: %s", target:name())
  422. os.exec("echo %s", target:targetfile())
  423. end)
  424. </code></pre>
  425. <h3 id="automaticintegrationofdependentpackages">Automatic integration of dependent packages</h3>
  426. <p>Download and use packages in <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a> or third-party repositories:</p>
  427. <pre><code class="lang-lua">add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8")
  428. add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true})
  429. target("test")
  430. set_kind("binary")
  431. add_files("src/*.c")
  432. add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl")
  433. </code></pre>
  434. <p>In addition, we can also use the <a href="https://github.com/xmake-io/xrepo">xrepo</a> command to quickly install dependencies.</p>
  435. <h3 id="qtquickappprogram">Qt QuickApp Program</h3>
  436. <pre><code class="lang-lua">target("test")
  437. add_rules("qt.quickapp")
  438. add_files("src/*.cpp")
  439. add_files("src/qml.qrc")
  440. </code></pre>
  441. <h3 id="cudaprogram">Cuda Program</h3>
  442. <pre><code class="lang-lua">target("test")
  443. set_kind("binary")
  444. add_files("src/*.cu")
  445. add_cugencodes("native")
  446. add_cugencodes("compute_35")
  447. </code></pre>
  448. <h3 id="wdkumdfdriverprogram">WDK/UMDF Driver Program</h3>
  449. <pre><code class="lang-lua">target("echo")
  450. add_rules("wdk.driver", "wdk.env.umdf")
  451. add_files("driver/*.c")
  452. add_files("driver/*.inx")
  453. add_includedirs("exe")
  454. target("app")
  455. add_rules("wdk.binary", "wdk.env.umdf")
  456. add_files("exe/*.cpp")
  457. </code></pre>
  458. <p>For more WDK driver examples (UMDF/KMDF/WDM), please visit <a href="https://xmake.io/#/guide/project_examples?id=wdk-driver-program">WDK Program Examples</a></p>
  459. <h3 id="darwinapplications">Darwin Applications</h3>
  460. <pre><code class="lang-lua">target("test")
  461. add_rules("xcode.application")
  462. add_files("src/*.m", "src/**.storyboard", "src/*.xcassets")
  463. add_files("src/Info.plist")
  464. </code></pre>
  465. <h3 id="frameworkandbundleprogramdarwin">Framework and Bundle Program (Darwin)</h3>
  466. <pre><code class="lang-lua">target("test")
  467. add_rules("xcode.framework") -- or xcode.bundle
  468. add_files("src/*.m")
  469. add_files("src/Info.plist")
  470. </code></pre>
  471. <h3 id="openmpprogram">OpenMP Program</h3>
  472. <pre><code class="lang-lua">add_requires("libomp", {optional = true})
  473. target("loop")
  474. set_kind("binary")
  475. add_files("src/*.cpp")
  476. add_rules("c++.openmp")
  477. add_packages("libomp")
  478. </code></pre>
  479. <h3 id="zigprogram">Zig Program</h3>
  480. <pre><code class="lang-lua">target("test")
  481. set_kind("binary")
  482. add_files("src/main.zig")
  483. </code></pre>
  484. <h3 id="automaticallyfetchremotetoolchain">Automatically fetch remote toolchain</h3>
  485. <h4 id="fetchaspecialversionofllvm">fetch a special version of LLVM</h4>
  486. <p>Require the Clang version packaged with LLM-10 to compile a project.</p>
  487. <pre><code class="lang-lua">add_requires("llvm 10.x", {alias = "llvm-10"})
  488. target("test")
  489. set_kind("binary")
  490. add_files("src/*.c")
  491. set_toolchains("llvm@llvm-10")
  492. </code></pre>
  493. <h4 id="fetchacrosscompilationtoolchain">Fetch a cross-compilation toolchain</h4>
  494. <p>We can also pull a specified cross-compilation toolchain in to compile the project.</p>
  495. <pre><code class="lang-lua">add_requires("muslcc")
  496. target("test")
  497. set_kind("binary")
  498. add_files("src/*.c")
  499. set_toolchains("@muslcc")
  500. </code></pre>
  501. <h4 id="fetchtoolchainandpackages">Fetch toolchain and packages</h4>
  502. <p>We can also use the specified <code>muslcc</code> cross-compilation toolchain to compile and integrate all dependent packages.</p>
  503. <pre><code class="lang-lua">add_requires("muslcc")
  504. add_requires("zlib", "libogg", {system = false})
  505. set_toolchains("@muslcc")
  506. target("test")
  507. set_kind("binary")
  508. add_files("src/*.c")
  509. add_packages("zlib", "libogg")
  510. </code></pre>
  511. <h2 id="plugins">Plugins</h2>
  512. <h4 id="generateideprojectfilepluginmakefilevs2002vs2022">Generate IDE project file plugin(makefile, vs2002 - vs2022 .. )</h4>
  513. <pre><code class="lang-bash">$ xmake project -k vsxmake -m "debug,release" # New vsproj generator (Recommended)
  514. $ xmake project -k vs -m "debug,release"
  515. $ xmake project -k cmake
  516. $ xmake project -k ninja
  517. $ xmake project -k compile_commands
  518. </code></pre>
  519. <h4 id="runacustomluascriptplugin">Run a custom lua script plugin</h4>
  520. <pre><code class="lang-bash">$ xmake l ./test.lua
  521. $ xmake l -c "print(&#39;hello xmake!&#39;)"
  522. $ xmake l lib.detect.find_tool gcc
  523. $ xmake l
  524. > print("hello xmake!")
  525. > {1, 2, 3}
  526. < {
  527. 1,
  528. 2,
  529. 3
  530. }
  531. </code></pre>
  532. <p>To see a list of bultin plugs, please visit <a href="https://xmake.io/#/plugin/builtin_plugins">Builtin plugins</a>.</p>
  533. <p>Please download and install other plugins from the plugins repository <a href="https://github.com/xmake-io/xmake-plugins">xmake-plugins</a>.</p>
  534. <h2 id="ideeditorintegration">IDE/Editor Integration</h2>
  535. <ul>
  536. <li><a href="https://github.com/xmake-io/xmake-vscode">xmake-vscode</a></li>
  537. </ul>
  538. <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-vscode/master/res/problem.gif" width="650px" /></p>
  539. <ul>
  540. <li><a href="https://github.com/xmake-io/xmake-sublime">xmake-sublime</a></li>
  541. </ul>
  542. <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" /></p>
  543. <ul>
  544. <li><a href="https://github.com/xmake-io/xmake-idea">xmake-idea</a></li>
  545. </ul>
  546. <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" /></p>
  547. <ul>
  548. <li><a href="https://github.com/Mythos-404/xmake.nvim">xmake.nvim</a> (third-party, thanks <a href="https://github.com/Mythos-404">@Mythos_404</a>)</li>
  549. </ul>
  550. <p><img src="https://raw.githubusercontent.com/Mythos-404/xmake.nvim/main/assets/XmakePreview.gif" width="650px" /></p>
  551. <ul>
  552. <li><a href="https://github.com/luzhlon/xmake.vim">xmake.vim</a> (third-party, thanks <a href="https://github.com/luzhlon">@luzhlon</a>)</li>
  553. <li><a href="https://github.com/HelloWorld886/xmake-visualstudio">xmake-visualstudio</a> (third-party, thanks <a href="https://github.com/HelloWorld886">@HelloWorld886</a>)</li>
  554. <li><a href="https://github.com/Arthapz/xmake-project-manager">xmake-qtcreator</a> (third-party, thanks <a href="https://github.com/Arthapz">@Arthapz</a>)</li>
  555. </ul>
  556. <h3 id="xmakegradlepluginjni">Xmake Gradle Plugin (JNI)</h3>
  557. <p>We can use the <a href="https://github.com/xmake-io/xmake-gradle">xmake-gradle</a> plugin to compile JNI libraries via gradle.</p>
  558. <pre><code>plugins {
  559. id &#39;org.tboox.gradle-xmake-plugin&#39; version &#39;1.1.5&#39;
  560. }
  561. android {
  562. externalNativeBuild {
  563. xmake {
  564. path "jni/xmake.lua"
  565. }
  566. }
  567. }
  568. </code></pre><p>The <code>xmakeBuild</code> task will be injected into the <code>assemble</code> task automatically if the <code>gradle-xmake-plugin</code> has been applied.</p>
  569. <pre><code class="lang-console">$ ./gradlew app:assembleDebug
  570. > Task :nativelib:xmakeConfigureForArm64
  571. > Task :nativelib:xmakeBuildForArm64
  572. >> xmake build
  573. [ 50%]: cache compiling.debug nativelib.cc
  574. [ 75%]: linking.debug libnativelib.so
  575. [100%]: build ok!
  576. >> install artifacts to /Users/ruki/projects/personal/xmake-gradle/nativelib/libs/arm64-v8a
  577. > Task :nativelib:xmakeConfigureForArmv7
  578. > Task :nativelib:xmakeBuildForArmv7
  579. >> xmake build
  580. [ 50%]: cache compiling.debug nativelib.cc
  581. [ 75%]: linking.debug libnativelib.so
  582. [100%]: build ok!
  583. >> install artifacts to /Users/ruki/projects/personal/xmake-gradle/nativelib/libs/armeabi-v7a
  584. > Task :nativelib:preBuild
  585. > Task :nativelib:assemble
  586. > Task :app:assembleDebug
  587. </code></pre>
  588. <h2 id="ciintegration">CI Integration</h2>
  589. <h3 id="githubaction">GitHub Action</h3>
  590. <p>The <a href="https://github.com/xmake-io/github-action-setup-xmake">github-action-setup-xmake</a> plugin for GitHub Actions can allow you to use Xmake with minimal efforts if you use GitHub Actions for your CI pipeline.</p>
  591. <pre><code class="lang-yaml">uses: xmake-io/github-action-setup-xmake@v1
  592. with:
  593. xmake-version: latest
  594. </code></pre>
  595. <h2 id="whoisusingxmake">Who is using Xmake?</h2>
  596. <p>The list of people and projects who are using Xmake is available <a href="https://xmake.io/#/about/who_is_using_xmake">here</a>.</p>
  597. <p>If you are using Xmake, you are welcome to submit your information to the above list through a PR, so that other users and the developers can gauge interest. Ihis also let users to use xmake more confidently and give us motivation to continue to maintain it.</p>
  598. <p>This will help the Xmake project and it&#39;s community grow stronger and expand!</p>
  599. <h2 id="contacts">Contacts</h2>
  600. <ul>
  601. <li>Email:<a href="mailto:[email protected]">[email protected]</a></li>
  602. <li>Homepage:<a href="https://xmake.io">xmake.io</a></li>
  603. <li>Community<ul>
  604. <li><a href="https://www.reddit.com/r/xmake/">Chat on Reddit</a></li>
  605. <li><a href="https://t.me/tbooxorg">Chat on Telegram</a></li>
  606. <li><a href="https://discord.gg/xmake">Chat on Discord</a></li>
  607. <li>Chat on QQ Group: 343118190, 662147501</li>
  608. </ul>
  609. </li>
  610. <li>Source Code:<a href="https://github.com/xmake-io/xmake">GitHub</a>, <a href="https://gitee.com/tboox/xmake">Gitee</a></li>
  611. <li>WeChat Public: tboox-os</li>
  612. </ul>
  613. <h2 id="thanks">Thanks</h2>
  614. <p>This project exists thanks to all the people who have <a href="CONTRIBUTING.md">contributed</a>:<br><a href="https://github.com/xmake-io/xmake/graphs/contributors"><img src="https://opencollective.com/xmake/contributors.svg?width=890&amp;button=false" /></a></p>
  615. <ul>
  616. <li><a href="https://github.com/TitanSnow">TitanSnow</a>: Provide the xmake <a href="https://github.com/TitanSnow/ts-xmake-logo">logo</a> and install scripts</li>
  617. <li><a href="https://github.com/uael">uael</a>: Provide the semantic versioning library <a href="https://github.com/uael/sv">sv</a></li>
  618. <li><a href="https://github.com/OpportunityLiu">OpportunityLiu</a>: Improve cuda, tests and ci</li>
  619. <li><a href="https://github.com/xq114">xq144</a>: Improve <code>xrepo env shell</code>, and contribute a lot of packages to the <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a> repository.</li>
  620. <li><code>enderger</code>: Helped smooth out the edges on the English translation of the README</li>
  621. </ul>
  622. </article>
  623. </body>
  624. </html>