Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 18, 2024
1 parent 93894cb commit 88d4c9b
Show file tree
Hide file tree
Showing 20 changed files with 296 additions and 115 deletions.
28 changes: 28 additions & 0 deletions manual/custom_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,20 @@ rule("foo")
end)
```

### rule:before_config

#### Custom pre-configuration script

Used to implement the execution script before custom target configuration, for example:

```lua
rule("test")
before_config(function (target)
end)
```

It will be executed before on_config.

### rule:before_link

#### Custom pre-link script
Expand Down Expand Up @@ -1228,6 +1242,20 @@ It is generally used to pre-process certain source files before compilation.
Similar to the usage of [rule:on_buildcmd_files](#ruleon_buildcmd_files), but the time when this interface is called is before compiling some source files,
It is generally used to pre-process certain source files before compilation.

### rule:after_config

#### Custom post-configuration script

Used to implement the execution script after custom target configuration, for example:

```lua
rule("test")
after_config(function (target)
end)
```

It will be executed after on_config.

### rule:after_link

#### Custom post-linking script
Expand Down
5 changes: 5 additions & 0 deletions mirror/about/who_is_using_xmake.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ <h2 id="userlist">User list</h2>
</thead>
<tbody>
<tr>
<td style="text-align:left">[Aleksandr Alibekov]</td>
<td style="text-align:left"><a href="https://github.com/HotWizard/TurboINI">TurboINI</a></td>
<td style="text-align:left">Xmake is so simple and nice to use.</td>
</tr>
<tr>
<td style="text-align:left"><a href="https://gitlab.com/tenten8401">Isaac A.</a></td>
<td style="text-align:left"><a href="https://gitlab.com/tenten8401/vuefusion">VueFusion</a> VR Full Body Tracker</td>
<td style="text-align:left">Xmake is awesome</td>
Expand Down
2 changes: 1 addition & 1 deletion mirror/getting_started.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h3 id="supportedpackagerepositories">Supported package repositories</h3>
<li><a href="https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository">User-built repositories</a></li>
<li>Conan (conan::openssl/1.1.1g)</li>
<li>Conda (conda::libpng 1.3.67)</li>
<li>Vcpkg (vcpkg:ffmpeg)</li>
<li>Vcpkg (vcpkg::ffmpeg)</li>
<li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
<li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
<li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
Expand Down
2 changes: 1 addition & 1 deletion mirror/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ <h3 id="supportedpackagerepositories">Supported package repositories</h3>
<li><a href="https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository">User-built repositories</a></li>
<li>Conan (conan::openssl/1.1.1g)</li>
<li>Conda (conda::libpng 1.3.67)</li>
<li>Vcpkg (vcpkg:ffmpeg)</li>
<li>Vcpkg (vcpkg::ffmpeg)</li>
<li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
<li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
<li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
Expand Down
16 changes: 16 additions & 0 deletions mirror/manual/custom_rule.html
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,14 @@ <h4 id="customizebatchcompilingscriptprocessmultiplesourcefilesatonce">Customize
end
end)
</code></pre>
<h3 id="rulebefore_config">rule:before_config</h3>
<h4 id="custompreconfigurationscript">Custom pre-configuration script</h4>
<p>Used to implement the execution script before custom target configuration, for example:</p>
<pre><code class="lang-lua">rule("test")
before_config(function (target)
end)
</code></pre>
<p>It will be executed before on_config.</p>
<h3 id="rulebefore_link">rule:before_link</h3>
<h4 id="customprelinkscript">Custom pre-link script</h4>
<p>Execution scripts used to implement custom target links, for example:</p>
Expand Down Expand Up @@ -901,6 +909,14 @@ <h4 id="customizeprecompilationscriptstoprocessmultiplesourcefilesatonce">Custom
<h3 id="rulebefore_buildcmd_files">rule:before_buildcmd_files</h3>
<h4 id="customizetheprecompilationbatchscripttoprocessmultiplesourcefilesatonce">Customize the pre-compilation batch script to process multiple source files at once</h4>
<p>Similar to the usage of <a href="#ruleon_buildcmd_files">rule:on_buildcmd_files</a>, but the time when this interface is called is before compiling some source files,<br>It is generally used to pre-process certain source files before compilation.</p>
<h3 id="ruleafter_config">rule:after_config</h3>
<h4 id="custompostconfigurationscript">Custom post-configuration script</h4>
<p>Used to implement the execution script after custom target configuration, for example:</p>
<pre><code class="lang-lua">rule("test")
after_config(function (target)
end)
</code></pre>
<p>It will be executed after on_config.</p>
<h3 id="ruleafter_link">rule:after_link</h3>
<h4 id="custompostlinkingscript">Custom post-linking script</h4>
<p>The execution script used to implement the custom target link is similar to <a href="#ruleafter_link">rule:after_link</a>.</p>
Expand Down
4 changes: 2 additions & 2 deletions mirror/manual/global_interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ <h5 id="installthirdpartymanagerpackage">Install third-party manager package</h5
<ul>
<li>Conan (conan::openssl/1.1.1g)</li>
<li>Conda (conda::libpng 1.3.67)</li>
<li>Vcpkg (vcpkg:ffmpeg)</li>
<li>Vcpkg (vcpkg::ffmpeg)</li>
<li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
<li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
<li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
Expand Down Expand Up @@ -390,7 +390,7 @@ <h5 id="rewritepackagedependencyconfiguration">Rewrite package dependency config
<p>If the dependency path is deep, such as the dependency chain of <code>foo -> bar -> xyz</code>, we can write: <code>foo.bar.xyz</code></p>
<p>We can also rewrite the internal zlib library version that libpng depends on:</p>
<pre><code class="lang-lua">add_requires("libpng")
add_requireconfs("libpng.zlib", {version = "1.2.10"})
add_requireconfs("libpng.zlib", {override = true, version = "1.2.10"})
</code></pre>
<h5 id="patternmatchingforcascadingdependencies">Pattern matching for cascading dependencies</h5>
<p>If a package has a lot of dependencies, and the dependency level is also very deep, what to do, for example, the package libwebp, its dependencies are:</p>
Expand Down
4 changes: 2 additions & 2 deletions mirror/manual/project_target.html
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,11 @@ <h4 id="setsourcecodelanguagestandards">Set source code language standards</h4>
<td><code>gnu++2a</code></td>
</tr>
<tr>
<td><code>cxx20</code></td>
<td><code>cxx23</code></td>
<td><code>c++23</code></td>
</tr>
<tr>
<td><code>gnuxx20</code></td>
<td><code>gnuxx23</code></td>
<td><code>gnu++23</code></td>
</tr>
<tr>
Expand Down
9 changes: 9 additions & 0 deletions mirror/package/remote_package.html
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ <h3 id="addcargosdependencypackage">Add cargo&#39;s dependency package</h3>
</code></pre>
<p>However, we can also use cxxbridge in C++ to call the Rust library interface to reuse all Rust packages in disguise.</p>
<p>For a complete example, see: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library">Call Rust in C++</a></p>
<h3 id="addnugetdependencypackages">Add NuGet dependency packages</h3>
<p>After 2.9.7, we also support getting native libraries from dotnet/nuget and quickly integrating them.</p>
<pre><code class="lang-lua">add_requires("nuget::zlib_static", {alias = "zlib"})

target("test")
set_kind("binary")
add_files("src/*.cpp")
add_packages("zlib")
</code></pre>
<h2 id="usingselfbuiltprivatepackagerepository">Using self-built private package repository</h2>
<p>If the required package is not in the official repository <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a>, we can submit the contribution code to the repository for support.<br>But if some packages are only for personal or private projects, we can create a private repository repo. The repository organization structure can be found at: <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a></p>
<p>For example, now we have a private repository repo:<a href="mailto:`[email protected]">`[email protected]</a>:myrepo/xmake-repo.git`</p>
Expand Down
8 changes: 8 additions & 0 deletions mirror/toolchain/builtin_toolchains.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ <h3 id="clang">Clang</h3>
<pre><code class="lang-console">$ xmake f --toolchain=clang -c
$ xmake
</code></pre>
<p>On Windows, it will automatically load the msvc environment.</p>
<p>In addition, we also support PortableBuildTools + clang environment:</p>
<pre><code class="lang-console">$ xmake f -c --sdk=C:/BuildTools --toolchain=clang
$ xmake -v
[50%]: cache compiling.release src\main.cpp C:\Users\star\scoop\apps\llvm\current\bin\clang -c -Qunused-arguments -m64 --target=x86_64-windows-msvc -fexceptions -fcxx-exceptions -o build\.objs\test\windows\x64\release\src\main.cpp.obj src\main.cpp
[75%]: linking.release test.exe C:\Users\star\scoop\apps\llvm\current\bin\clang++ -o build\windows\x64\release\test.exe build\.objs\test\windows\x64\release\src\main.cpp.obj -m64 --target=x86_64-windows-msvc
[100%]: build ok, spent 0.235s
</code></pre>
<h3 id="clangcl">Clang-cl</h3>
<p>If you simply switch to the clang-cl.exe compiler, and use msvc for the rest of the link operation, then we don&#39;t need to switch the entire tool chain, just cut the c/c++ compiler.</p>
<pre><code class="lang-console">$ xmake f --cc=clang-cl --cxx=clang-cl -c
Expand Down
2 changes: 1 addition & 1 deletion mirror/zh-cn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ <h3 id="">支持的包管理仓库</h3>
<li><a href="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">用户自建仓库</a></li>
<li>Conan (conan::openssl/1.1.1g)</li>
<li>Conda (conda::libpng 1.3.67)</li>
<li>Vcpkg (vcpkg:ffmpeg)</li>
<li>Vcpkg (vcpkg::ffmpeg)</li>
<li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
<li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
<li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
Expand Down
16 changes: 16 additions & 0 deletions mirror/zh-cn/manual/custom_rule.html
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,14 @@ <h4 id="">自定义批处理编译脚本,一次处理多个源文件</h4>
end
end)
</code></pre>
<h3 id="rulebefore_config">rule:before_config</h3>
<h4 id="">自定义配置前脚本</h4>
<p>用于实现自定义 target 配置前的执行脚本,例如:</p>
<pre><code class="lang-lua">rule("test")
before_config(function (target)
end)
</code></pre>
<p>它会在 on_config 之前被执行。</p>
<h3 id="rulebefore_link">rule:before_link</h3>
<h4 id="">自定义链接前脚本</h4>
<p>用于实现自定义target链接前的执行脚本,例如:</p>
Expand Down Expand Up @@ -906,6 +914,14 @@ <h4 id="">自定义编译前脚本,一次处理多个源文件</h4>
<h3 id="rulebefore_buildcmd_files">rule:before_buildcmd_files</h3>
<h4 id="">自定义编译前批处理脚本,一次处理多个源文件</h4>
<p><a href="#ruleon_buildcmd_files">rule:on_buildcmd_files</a>用法类似,不过这个接口被调用的时机是在编译某些源文件之前,<br>一般用于对某些源文件进行编译前的预处理。</p>
<h3 id="ruleafter_config">rule:after_config</h3>
<h4 id="">自定义配置后脚本</h4>
<p>用于实现自定义 target 配置后的执行脚本,例如:</p>
<pre><code class="lang-lua">rule("test")
after_config(function (target)
end)
</code></pre>
<p>它会在 on_config 之后被执行。</p>
<h3 id="ruleafter_link">rule:after_link</h3>
<h4 id="">自定义链接后脚本</h4>
<p>用于实现自定义target链接后的执行脚本,用法跟<a href="#rulebefore_link">rule:before_link</a>类似。</p>
Expand Down
4 changes: 2 additions & 2 deletions mirror/zh-cn/manual/global_interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ <h5 id="">安装第三方管理器的包</h5>
<ul>
<li>Conan (conan::openssl/1.1.1g)</li>
<li>Conda (conda::libpng 1.3.67)</li>
<li>Vcpkg (vcpkg:ffmpeg)</li>
<li>Vcpkg (vcpkg::ffmpeg)</li>
<li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
<li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
<li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
Expand Down Expand Up @@ -397,7 +397,7 @@ <h5 id="">改写包依赖配置</h5>
<p>如果依赖路径很深,比如 <code>foo -> bar -> xyz</code> 的依赖链,我们可以写成:<code>foo.bar.xyz</code></p>
<p>我们也可以改写 libpng 依赖的内部 zlib 库版本:</p>
<pre><code class="lang-lua">add_requires("libpng")
add_requireconfs("libpng.zlib", {version = "1.2.10"})
add_requireconfs("libpng.zlib", {override = true, version = "1.2.10"})
</code></pre>
<h5 id="">级联依赖的模式匹配</h5>
<p>如果一个包的依赖非常多,且依赖层次也很深,怎么办呢,比如 libwebp 这个包,它的依赖有:</p>
Expand Down
9 changes: 9 additions & 0 deletions mirror/zh-cn/package/remote_package.html
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@ <h3 id="cargo">添加 cargo 的依赖包</h3>
</code></pre>
<p>不过,我们也可以在 C++ 中通过 cxxbridge 的方式,调用 Rust 库接口,来变相复用所有的 Rust 包。</p>
<p>完整例子见:<a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library">Call Rust in C++</a></p>
<h3 id="nuget">添加 NuGet 的依赖包</h3>
<p>2.9.7 之后,我们也支持从 dotnet/nuget 中,获取 native 库并快速集成。</p>
<pre><code class="lang-lua">add_requires("nuget::zlib_static", {alias = "zlib"})

target("test")
set_kind("binary")
add_files("src/*.cpp")
add_packages("zlib")
</code></pre>
<h2 id="">使用自建私有包仓库</h2>
<p>如果需要的包不在官方仓库<a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a>中,我们可以提交贡献代码到仓库进行支持。<br>但如果有些包仅用于个人或者私有项目,我们可以建立一个私有仓库repo,仓库组织结构可参考:<a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a></p>
<p>比如,现在我们有一个一个私有仓库repo:<a href="mailto:`[email protected]">`[email protected]</a>:myrepo/xmake-repo.git`</p>
Expand Down
10 changes: 10 additions & 0 deletions mirror/zh-cn/toolchain/builtin_toolchains.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ <h3 id="clang">Clang</h3>
<pre><code class="lang-console">$ xmake f --toolchain=clang -c
$ xmake
</code></pre>
<p>在 windows 上,它会自动加载 msvc 环境。</p>
<p>另外,我们也支持 PortableBuildTools + clang 环境:</p>
<pre><code class="lang-console">$ xmake f -c --sdk=C:/BuildTools --toolchain=clang
$ xmake -v
[ 50%]: cache compiling.release src\main.cpp
C:\Users\star\scoop\apps\llvm\current\bin\clang -c -Qunused-arguments -m64 --target=x86_64-windows-msvc -fexceptions -fcxx-exceptions -o build\.objs\test\windows\x64\release\src\main.cpp.obj src\main.cpp
[ 75%]: linking.release test.exe
C:\Users\star\scoop\apps\llvm\current\bin\clang++ -o build\windows\x64\release\test.exe build\.objs\test\windows\x64\release\src\main.cpp.obj -m64 --target=x86_64-windows-msvc
[100%]: build ok, spent 0.235s
</code></pre>
<h3 id="clangcl">Clang-cl</h3>
<p>如果只是单纯的切换使用 clang-cl.exe 编译器,剩下的链接操作还是用 msvc,那么我们不需要整个工具链切换,仅仅切换 c/c++ 编译器。</p>
<pre><code class="lang-console">$ xmake f --cc=clang-cl --cxx=clang-cl -c
Expand Down
13 changes: 13 additions & 0 deletions package/remote_package.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,19 @@ However, we can also use cxxbridge in C++ to call the Rust library interface to

For a complete example, see: [Call Rust in C++](https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library)

### Add NuGet dependency packages

After 2.9.7, we also support getting native libraries from dotnet/nuget and quickly integrating them.

```lua
add_requires("nuget::zlib_static", {alias = "zlib"})

target("test")
set_kind("binary")
add_files("src/*.cpp")
add_packages("zlib")
```

## Using self-built private package repository

If the required package is not in the official repository [xmake-repo](https://github.com/xmake-io/xmake-repo), we can submit the contribution code to the repository for support.
Expand Down
Loading

0 comments on commit 88d4c9b

Please sign in to comment.