| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>xmake</title>
- <link rel="icon" href="/assets/img/favicon.ico">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <meta name="description" content="Description">
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <link href="/assets/npm/github-markdown/github-markdown.min.css" rel="stylesheet">
- <style>
- .markdown-body {
- box-sizing: border-box;
- min-width: 200px;
- max-width: 980px;
- margin: 0 auto;
- padding: 45px;
- }
- @media (max-width: 767px) {
- .markdown-body {
- padding: 15px;
- }
- }
- </style>
- </head>
- <body>
- <article class="markdown-body">
- <h4>This is a mirror page, please see the original page: </h4><a href="https://xmake.io/#/zh-cn/getting_started">https://xmake.io/#/zh-cn/getting_started</a>
- <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>
- </br>
- <script type="text/javascript" charset="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
- <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CE7I52QU&placement=xmakeio" id="_carbonads_js"></script>
- <style>
- #carbonads {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
- Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
- }
- #carbonads {
- display: flex;
- max-width: 330px;
- background-color: hsl(0, 0%, 98%);
- box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, .1);
- }
- #carbonads a {
- color: inherit;
- text-decoration: none;
- }
- #carbonads a:hover {
- color: inherit;
- }
- #carbonads span {
- position: relative;
- display: block;
- overflow: hidden;
- }
- #carbonads .carbon-wrap {
- display: flex;
- }
- .carbon-img {
- display: block;
- margin: 0;
- line-height: 1;
- }
- .carbon-img img {
- display: block;
- }
- .carbon-text {
- font-size: 13px;
- padding: 10px;
- line-height: 1.5;
- text-align: left;
- }
- .carbon-poweredby {
- display: block;
- padding: 8px 10px;
- 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);
- text-align: center;
- text-transform: uppercase;
- letter-spacing: .5px;
- font-weight: 600;
- font-size: 9px;
- line-height: 1;
- }
- </style>
- <h2 id="">捐助</h2>
- <p>🙏 xmake项目属于个人开源项目,它的发展需要您的帮助,如果您愿意支持xmake项目的开发,欢迎为其捐赠,支持它的发展。</p>
- <p>👉 <a href="https://xmake.io/#/zh-cn/about/sponsor">捐助页面</a></p>
- <p>也可以通过购买周边纪念物品的方式,来支持我们的项目发展。</p>
- <p>👉 <a href="https://xmake.io/#/zh-cn/about/peripheral_items">周边物品</a></p>
- <h2 id="">技术支持</h2>
- <p>你也可以考虑通过 <a href="https://github.com/sponsors/waruqi">Github 的赞助计划</a> 赞助我们来获取额外的技术支持服务,然后你就能获取 <a href="https://github.com/xmake-io/technical-support">xmake-io/technical-support</a> 仓库的访问权限,获取更多技术咨询相关的信息。</p>
- <ul>
- <li>[x] 更高优先级的 Issues 问题处理</li>
- <li>[x] 一对一技术咨询服务</li>
- <li>[x] Review xmake.lua 并提供改进建议</li>
- </ul>
- <h2 id="new">课程(New)</h2>
- <p><a href="https://www.lanqiao.cn/courses/2764">Xmake 带你轻松构建 C/C++ 项目</a> 是我们在实验楼上新推出的一门 xmake 入门和进阶课程(收费),以边学边做实验的方式快速学习 xmake 的使用。</p>
- <p>通过此处优惠码购买可享 9 折优惠:<code>NYFbmf3X</code></p>
- <h2 id="xmake">谁在使用 Xmake?</h2>
- <p>如果您在使用 xmake,欢迎点击编辑 <a href="https://github.com/xmake-io/xmake-docs/blob/master/zh-cn/about/who_is_using_xmake.md">此页面</a> 通过 PR 将信息提交至下面的列表,让更多的用户了解有多少用户在使用 xmake,也能让用户更加安心使用 xmake。</p>
- <p>我们也会有更多的动力去持续投入,让 xmake 项目和社区更加繁荣。</p>
- <h2 id="">安装</h2>
- <h4 id="curl">使用curl</h4>
- <pre><code class="lang-bash">curl -fsSL https://xmake.io/shget.text | bash
- </code></pre>
- <h4 id="wget">使用wget</h4>
- <pre><code class="lang-bash">wget https://xmake.io/shget.text -O - | bash
- </code></pre>
- <h4 id="powershell">使用powershell</h4>
- <pre><code class="lang-powershell">Invoke-Expression (Invoke-Webrequest 'https://xmake.io/psget.text' -UseBasicParsing).Content
- </code></pre>
- <h4 id="">其他安装方式</h4>
- <p>如果不想使用脚本安装,也可以点击查看 <a href="https://xmake.io/#/zh-cn/guide/installation">安装文档</a>,了解其他安装方法。</p>
- <h2 id="">简单的工程描述</h2>
- <pre><code class="lang-lua">target("hello")
- set_kind("binary")
- add_files("src/*.cpp")
- </code></pre>
- <h2 id="">包依赖描述</h2>
- <pre><code class="lang-lua">add_requires("tbox 1.6.*", "zlib", "libpng ~1.6")
- </code></pre>
- <p>官方的xmake包管理仓库: <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a></p>
- <h2 id="">构建工程</h2>
- <pre><code class="lang-bash">$ xmake
- </code></pre>
- <h2 id="">运行目标</h2>
- <pre><code class="lang-bash">$ xmake run console
- </code></pre>
- <h2 id="">调试程序</h2>
- <pre><code class="lang-bash">$ xmake run -d console
- </code></pre>
- <h2 id="">配置平台</h2>
- <pre><code class="lang-bash">$ xmake f -p [windows|linux|macosx|android|iphoneos ..] -a [x86|arm64 ..] -m [debug|release]
- $ xmake
- </code></pre>
- <h2 id="">图形化菜单配置</h2>
- <pre><code class="lang-bash">$ xmake f --menu
- </code></pre>
- <p><img src="https://xmake.io/assets/img/index/menuconf.png" width="650px" /></p>
- <h2 id="ninja">跟ninja一样快的构建速度</h2>
- <p>测试工程: <a href="https://github.com/xmake-io/xmake/tree/master/core">xmake-core</a></p>
- <h3 id="">多任务并行编译测试</h3>
- <table>
- <thead>
- <tr>
- <th>构建系统</th>
- <th>Termux (8core/-j12)</th>
- <th>构建系统</th>
- <th>MacOS (8core/-j12)</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>xmake</td>
- <td>24.890s</td>
- <td>xmake</td>
- <td>12.264s</td>
- </tr>
- <tr>
- <td>ninja</td>
- <td>25.682s</td>
- <td>ninja</td>
- <td>11.327s</td>
- </tr>
- <tr>
- <td>cmake(gen+make)</td>
- <td>5.416s+28.473s</td>
- <td>cmake(gen+make)</td>
- <td>1.203s+14.030s</td>
- </tr>
- <tr>
- <td>cmake(gen+ninja)</td>
- <td>4.458s+24.842s</td>
- <td>cmake(gen+ninja)</td>
- <td>0.988s+11.644s</td>
- </tr>
- </tbody>
- </table>
- <h3 id="">单任务编译测试</h3>
- <table>
- <thead>
- <tr>
- <th>构建系统</th>
- <th>Termux (-j1)</th>
- <th>构建系统</th>
- <th>MacOS (-j1)</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>xmake</td>
- <td>1m57.707s</td>
- <td>xmake</td>
- <td>39.937s</td>
- </tr>
- <tr>
- <td>ninja</td>
- <td>1m52.845s</td>
- <td>ninja</td>
- <td>38.995s</td>
- </tr>
- <tr>
- <td>cmake(gen+make)</td>
- <td>5.416s+2m10.539s</td>
- <td>cmake(gen+make)</td>
- <td>1.203s+41.737s</td>
- </tr>
- <tr>
- <td>cmake(gen+ninja)</td>
- <td>4.458s+1m54.868s</td>
- <td>cmake(gen+ninja)</td>
- <td>0.988s+38.022s</td>
- </tr>
- </tbody>
- </table>
- <h2 id="">包依赖管理</h2>
- <h3 id="">下载和编译</h3>
- <p><img src="https://xmake.io/assets/img/index/package_manage.png" width="650px" /></p>
- <h3 id="">架构和流程</h3>
- <p><img src="https://xmake.io/assets/img/index/package_arch.png" width="650px" /></p>
- <h2 id="">支持平台</h2>
- <ul>
- <li>Windows (x86, x64)</li>
- <li>macOS (i386, x86_64)</li>
- <li>Linux (i386, x86_64, cross-toolchains ..)</li>
- <li>*BSD (i386, x86_64)</li>
- <li>Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a)</li>
- <li>iOS (armv7, armv7s, arm64, i386, x86_64)</li>
- <li>WatchOS (armv7k, i386)</li>
- <li>MSYS (i386, x86_64)</li>
- <li>MinGW (i386, x86_64)</li>
- <li>Cygwin (i386, x86_64)</li>
- <li>SDCC (stm8, mcs51, ..)</li>
- <li>Cross (cross-toolchains ..)</li>
- </ul>
- <h2 id="">支持语言</h2>
- <ul>
- <li>C/C++</li>
- <li>Objc/Objc++</li>
- <li>Swift</li>
- <li>Assembly</li>
- <li>Golang</li>
- <li>Rust</li>
- <li>Dlang</li>
- <li>Cuda</li>
- </ul>
- <h2 id="">工程类型</h2>
- <ul>
- <li>静态库程序</li>
- <li>动态库类型</li>
- <li>控制台程序</li>
- <li>Cuda程序</li>
- <li>Qt应用程序</li>
- <li>WDK驱动程序</li>
- <li>WinSDK应用程序</li>
- <li>MFC应用程序</li>
- </ul>
- <h2 id="">更多例子</h2>
- <p>Debug和Release模式:</p>
- <pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
- target("console")
- set_kind("binary")
- add_files("src/*.c")
- if is_mode("debug") then
- add_defines("DEBUG")
- end
- </code></pre>
- <p>自定义脚本:</p>
- <pre><code class="lang-lua">target("test")
- set_kind("binary")
- add_files("src/*.c")
- after_build(function (target)
- print("hello: %s", target:name())
- os.exec("echo %s", target:targetfile())
- end)
- </code></pre>
- <p>下载和使用在<a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a>和第三方包仓库的依赖包:</p>
- <pre><code class="lang-lua">add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8")
- add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true})
- target("test")
- set_kind("binary")
- add_files("src/*.c")
- add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl")
- </code></pre>
- <p>Qt QuickApp应用程序:</p>
- <pre><code class="lang-lua">target("test")
- add_rules("qt.quickapp")
- add_files("src/*.cpp")
- add_files("src/qml.qrc")
- </code></pre>
- <p>Cuda程序:</p>
- <pre><code class="lang-lua">target("test")
- set_kind("binary")
- add_files("src/*.cu")
- add_cugencodes("native")
- add_cugencodes("compute_30")
- </code></pre>
- <p>WDK/UMDF驱动程序:</p>
- <pre><code class="lang-lua">target("echo")
- add_rules("wdk.driver", "wdk.env.umdf")
- add_files("driver/*.c")
- add_files("driver/*.inx")
- add_includedirs("exe")
- target("app")
- add_rules("wdk.binary", "wdk.env.umdf")
- add_files("exe/*.cpp")
- </code></pre>
- <p>更多WDK驱动程序例子(umdf/kmdf/wdm),见:<a href="https://xmake.io/#/zh-cn/guide/project_examples?id=wdk%e9%a9%b1%e5%8a%a8%e7%a8%8b%e5%ba%8f">WDK工程例子</a></p>
- <h2 id="">插件</h2>
- <h4 id="idemakefilevs2002vs2019">生成IDE工程文件插件(makefile, vs2002 - vs2019, ...)</h4>
- <pre><code class="lang-bash">$ xmake project -k vsxmake -m "debug;release" # 新版vs工程生成插件(推荐)
- $ xmake project -k vs -m "debug;release"
- $ xmake project -k cmake
- $ xmake project -k ninja
- $ xmake project -k compile_commands
- </code></pre>
- <h4 id="lua">加载自定义lua脚本插件</h4>
- <pre><code class="lang-bash">$ xmake l ./test.lua
- $ xmake l -c "print('hello xmake!')"
- $ xmake l lib.detect.find_tool gcc
- $ xmake l
- > print("hello xmake!")
- > {1, 2, 3}
- < {
- 1,
- 2,
- 3
- }
- </code></pre>
- <p>更多内置插件见相关文档:<a href="https://xmake.io/#/zh-cn/plugin/builtin_plugins">内置插件文档</a></p>
- <p>其他扩展插件,请到插件仓库进行下载安装: <a href="https://github.com/xmake-io/xmake-plugins">xmake-plugins</a>.</p>
- <h2 id="ide">IDE和编辑器插件</h2>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-vscode">xmake-vscode</a></li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-vscode/master/res/problem.gif" width="650px" /></p>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-sublime">xmake-sublime</a></li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" /></p>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-idea">xmake-idea</a></li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" /></p>
- <ul>
- <li><a href="https://github.com/Mythos-404/xmake.nvim">xmake.nvim</a> (第三方开发, 感谢<a href="https://github.com/Mythos-404">@Mythos_404</a>)</li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/Mythos-404/xmake.nvim/main/assets/XmakePreview.gif" width="650px" /></p>
- <ul>
- <li><p><a href="https://github.com/luzhlon/xmake.vim">xmake.vim</a> (third-party, thanks <a href="https://github.com/luzhlon">@luzhlon</a>)</p>
- </li>
- <li><p><a href="https://github.com/xmake-io/xmake-gradle">xmake-gradle</a>: 一个无缝整合xmake的gradle插件</p>
- </li>
- </ul>
- <h2 id="">项目例子</h2>
- <p>一些使用xmake的项目:</p>
- <ul>
- <li><a href="https://github.com/tboox/tbox">tbox</a></li>
- <li><a href="https://github.com/tboox/gbox">gbox</a></li>
- <li><a href="https://github.com/tboox/vm86">vm86</a></li>
- <li><a href="https://github.com/xmake-io/awesome-xmake">更多</a></li>
- </ul>
- <h2 id="">演示视频</h2>
- <p><a href="https://asciinema.org/a/133693"><br><img src="https://asciinema.org/a/133693.png" width="650px" /><br></a></p>
- <h2 id="">联系方式</h2>
- <ul>
- <li>邮箱:<a href="mailto:[email protected]">[email protected]</a></li>
- <li>主页:<a href="https://tboox.org/cn">tboox.org</a></li>
- <li>社区:<a href="https://www.reddit.com/r/xmake/">Reddit论坛</a></li>
- <li>源码:<a href="https://github.com/xmake-io/xmake">Github</a>, <a href="https://gitee.com/tboox/xmake">Gitee</a></li>
- <li>QQ群:343118190(满), 662147501</li>
- <li>微信公众号:tboox-os</li>
- </ul>
- <h2 id="">感谢</h2>
- <p>感谢所有对xmake有所<a href="CONTRIBUTING.md">贡献</a>的人:<br><a href="https://github.com/xmake-io/xmake/graphs/contributors"><img src="https://opencollective.com/xmake/contributors.svg?width=890&button=false" /></a></p>
- <ul>
- <li><a href="https://github.com/TitanSnow">TitanSnow</a>: 提供xmake <a href="https://github.com/TitanSnow/ts-xmake-logo">logo</a> 和安装脚本</li>
- <li><a href="https://github.com/uael">uael</a>: 提供语义版本跨平台c库 <a href="https://github.com/uael/sv">sv</a></li>
- <li><a href="https://github.com/OpportunityLiu">OpportunityLiu</a>: 改进cuda构建, tests框架和ci</li>
- </ul>
- </article>
- </body>
- </html>
|