Selaa lähdekoodia

add glsl2spv rule

ruki 4 vuotta sitten
vanhempi
sitoutus
7336df22ec

+ 115 - 0
guide/project_examples.md

@@ -839,6 +839,121 @@ target("test")
 
 For more examples, see: [Rust Examples](https://github.com/xmake-io/xmake/tree/master/tests/projects/rust)
 
+### Add cargo package dependences
+
+example: https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cargo_deps
+
+```lua
+add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+    set_kind("binary")
+    add_files("src/main.rs")
+    add_packages("cargo::base64", "cargo::flate2")
+```
+
+### Use cxxbridge to call rust in c++
+
+example: https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+add_requires("cargo::cxx 1.0")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.rs")
+    set_values("rust.cratetype", "staticlib")
+    add_packages("cargo::cxx")
+
+target("test")
+    set_kind("binary")
+    add_rules("rust.cxxbridge")
+    add_deps("foo")
+    add_files("src/main.cc")
+    add_files("src/bridge.rsx")
+```
+
+foo.rs
+
+```rust
+#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+    return a + b;
+}
+```
+
+bridge interface file in c++, bridge.rsx
+
+```rust
+#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+```
+
+main.cc
+
+```c++
+#include <stdio.h>
+#include "bridge.rs.h"
+
+int main(int argc, char** argv) {
+    printf("add(1, 2) == %d\n", add(1, 2));
+    return 0;
+}
+```
+
+### Call c++ in rust
+
+example: https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/rust_call_cxx_library
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.cc")
+
+target("test")
+    set_kind("binary")
+    add_deps("foo")
+    add_files("src/main.rs")
+```
+
+main.rs
+
+```rust
+extern "C" {
+	fn add(a: i32, b: i32) -> i32;
+}
+
+fn main() {
+    unsafe {
+	    println!("add(1, 2) = {}", add(1, 2));
+    }
+}
+```
+
+foo.cc
+
+```c++
+extern "C" int add(int a, int b) {
+    return a + b;
+}
+```
+
 ## Swift Program
 
 Create an empty project:

+ 58 - 0
manual/custom_rule.md

@@ -627,6 +627,64 @@ cat build/.gens/test/macosx/x86_64/release/rules/c++/bin2c/image.png.h
   0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x78, 0x6D, 0x61, 0x6B, 0x65, 0x21, 0x0A, 0x00
 ```
 
+#### utils.glsl2spv
+
+This rule can be used in v2.6.1 and above. Import glsl shader files such as `*.vert/*.frag` into the project, and then realize automatic compilation to generate `*.spv` files.
+
+In addition, we also support binary embedding spv file data in the form of C/C++ header file, which is convenient for program use.
+
+##### Compile and generate spv file
+
+xmake will automatically call glslangValidator or glslc to compile shaders to generate .spv files, and then output them to the specified `{outputdir = "build"}` directory.
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {outputdir = "build"})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+```
+
+Note that the `add_packages("glslang")` here is mainly used to import and bind the glslangValidator in the glslang package to ensure that xmake can always use it.
+
+Of course, if you have already installed it on your own system, you don’t need to bind this package additionally, but I still recommend adding it.
+
+##### Compile and generate c/c++ header files
+
+We can also use the bin2c module internally to generate the corresponding binary header file from the compiled spv file, which is convenient for direct import in user code. We only need to enable `{bin2c = true}`. :w
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {bin2c = true})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+```
+
+Then we can introduce in the code like this:
+
+```c
+static unsigned char g_test_vert_spv_data[] = {
+    #include "test.vert.spv.h"
+};
+
+static unsigned char g_test_frag_spv_data[] = {
+    #include "test.frag.spv.h"
+};
+```
+
+Similar to the usage of bin2c rules, see the complete example: [glsl2spv example](https://github.com/xmake-io/xmake/tree/master/tests/projects/other/glsl2spv)
+
 ### rule
 
 #### Defining rules

+ 7 - 0
mirror/about/sponsor.html

@@ -115,6 +115,13 @@
 </thead>
 <tbody>
 <tr>
+<td>2021.11.15</td>
+<td>朱*</td>
+<td>alipay</td>
+<td>¥50</td>
+<td>xmake非常好用,继续加油!</td>
+</tr>
+<tr>
 <td>2021.10.04</td>
 <td>S*o</td>
 <td>wechat</td>

+ 88 - 0
mirror/guide/project_examples.html

@@ -638,6 +638,94 @@ target("test")
     add_files("src/*.rs")
 </code></pre>
 <p>For more examples, see: <a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/rust">Rust Examples</a></p>
+<h3 id="addcargopackagedependences">Add cargo package dependences</h3>
+<p>example: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cargo_deps">https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cargo_deps</a></p>
+<pre><code class="lang-lua">add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+    set_kind("binary")
+    add_files("src/main.rs")
+    add_packages("cargo::base64", "cargo::flate2")
+</code></pre>
+<h3 id="usecxxbridgetocallrustinc">Use cxxbridge to call rust in c++</h3>
+<p>example: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library">https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library</a></p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+add_requires("cargo::cxx 1.0")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.rs")
+    set_values("rust.cratetype", "staticlib")
+    add_packages("cargo::cxx")
+
+target("test")
+    set_kind("binary")
+    add_rules("rust.cxxbridge")
+    add_deps("foo")
+    add_files("src/main.cc")
+    add_files("src/bridge.rsx")
+</code></pre>
+<p>foo.rs</p>
+<pre><code class="lang-rust">#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+    return a + b;
+}
+</code></pre>
+<p>bridge interface file in c++, bridge.rsx</p>
+<pre><code class="lang-rust">#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+</code></pre>
+<p>main.cc</p>
+<pre><code class="lang-c++">#include <stdio.h>
+#include "bridge.rs.h"
+
+int main(int argc, char** argv) {
+    printf("add(1, 2) == %d\n", add(1, 2));
+    return 0;
+}
+</code></pre>
+<h3 id="callcinrust">Call c++ in rust</h3>
+<p>example: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/rust_call_cxx_library">https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/rust_call_cxx_library</a></p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.cc")
+
+target("test")
+    set_kind("binary")
+    add_deps("foo")
+    add_files("src/main.rs")
+</code></pre>
+<p>main.rs</p>
+<pre><code class="lang-rust">extern "C" {
+    fn add(a: i32, b: i32) -> i32;
+}
+
+fn main() {
+    unsafe {
+        println!("add(1, 2) = {}", add(1, 2));
+    }
+}
+</code></pre>
+<p>foo.cc</p>
+<pre><code class="lang-c++">extern "C" int add(int a, int b) {
+    return a + b;
+}
+</code></pre>
 <h2 id="swiftprogram">Swift Program</h2>
 <p>Create an empty project:</p>
 <pre><code class="lang-console">$ xmake create -l swift -t console test

+ 41 - 0
mirror/manual/custom_rule.html

@@ -501,6 +501,47 @@ int main(int argc, char** argv)
 <pre><code class="lang-console">cat build/.gens/test/macosx/x86_64/release/rules/c++/bin2c/image.png.h
   0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x78, 0x6D, 0x61, 0x6B, 0x65, 0x21, 0x0A, 0x00
 </code></pre>
+<h4 id="utilsglsl2spv">utils.glsl2spv</h4>
+<p>This rule can be used in v2.6.1 and above. Import glsl shader files such as <code>*.vert/*.frag</code> into the project, and then realize automatic compilation to generate <code>*.spv</code> files.</p>
+<p>In addition, we also support binary embedding spv file data in the form of C/C++ header file, which is convenient for program use.</p>
+<h5 id="compileandgeneratespvfile">Compile and generate spv file</h5>
+<p>xmake will automatically call glslangValidator or glslc to compile shaders to generate .spv files, and then output them to the specified <code>{outputdir = "build"}</code> directory.</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {outputdir = "build"})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+</code></pre>
+<p>Note that the <code>add_packages("glslang")</code> here is mainly used to import and bind the glslangValidator in the glslang package to ensure that xmake can always use it.</p>
+<p>Of course, if you have already installed it on your own system, you don’t need to bind this package additionally, but I still recommend adding it.</p>
+<h5 id="compileandgenerateccheaderfiles">Compile and generate c/c++ header files</h5>
+<p>We can also use the bin2c module internally to generate the corresponding binary header file from the compiled spv file, which is convenient for direct import in user code. We only need to enable <code>{bin2c = true}</code>. :w</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {bin2c = true})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+</code></pre>
+<p>Then we can introduce in the code like this:</p>
+<pre><code class="lang-c">static unsigned char g_test_vert_spv_data[] = {
+    #include "test.vert.spv.h"
+};
+
+static unsigned char g_test_frag_spv_data[] = {
+    #include "test.frag.spv.h"
+};
+</code></pre>
+<p>Similar to the usage of bin2c rules, see the complete example: <a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/other/glsl2spv">glsl2spv example</a></p>
 <h3 id="rule">rule</h3>
 <h4 id="definingrules">Defining rules</h4>
 <pre><code class="lang-lua">rule("markdown")

+ 23 - 6
mirror/package/remote_package.html

@@ -231,7 +231,7 @@ add_requires("brew::pcre2/libpcre2-8", {alias = "pcre2"})
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("pcre2", "zlib")
 </code></pre>
 <h3 id="addvcpkgdependencypackage">Add vcpkg dependency package</h3>
@@ -239,7 +239,7 @@ target("test")
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("vcpkg::zlib", "vcpkg::pcre2")
 </code></pre>
 <p>We can also add a package alias name to simplify the use of <code>add_packages</code>:</p>
@@ -248,17 +248,21 @@ add_requires("vcpkg::pcre2", {alias = "pcre2"})
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("zlib", "pcre2")
 </code></pre>
+<p>If the vcpkg package has optional features, we can also directly use the vcpkg syntax format <code>packagename[feature1,feature2]</code> to install the package.</p>
+<p>e.g:</p>
+<pre><code class="lang-lua">add_requires("vcpkg::boost[core]")
+</code></pre>
 <h3 id="addconandependencypackage">Add conan dependency package</h3>
 <pre><code class="lang-lua">add_requires("conan::zlib/1.2.11", {alias = "zlib", debug = true})
-add_requires("conan::openssl/1.1.1g", {alias = "openssl", 
+add_requires("conan::openssl/1.1.1g", {alias = "openssl",
     configs = {options = "OpenSSL:shared=True"}})
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("openssl", "zlib")
 </code></pre>
 <p>After executing xmake to compile:</p>
@@ -368,6 +372,19 @@ target("test")
      add_files("src/main.nim")
      add_packages("nimble::zip")
 </code></pre>
+<h3 id="addcargosdependencypackage">Add cargo&#39;s dependency package</h3>
+<p>Cargo dependency packages are mainly used for rust project integration, for example:</p>
+<pre><code class="lang-lua">add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+     set_kind("binary")
+     add_files("src/main.rs")
+     add_packages("cargo::base64", "cargo::flate2")
+</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>
 <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>
@@ -669,7 +686,7 @@ end
 <p>In the engineering project, we can also view a list of configurable parameters and values for a particular package:</p>
 <pre><code class="lang-bash">$ xmake require --info pcre2
 The package info of project:
-    require(pcre2): 
+    require(pcre2):
       -> description: A Perl Compatible Regular Expressions Library
       -> version: 10.31
       ...

+ 8 - 1
mirror/zh-cn/about/sponsor.html

@@ -116,6 +116,13 @@
 </thead>
 <tbody>
 <tr>
+<td>2021.11.15</td>
+<td>朱*</td>
+<td>支付宝</td>
+<td>¥50</td>
+<td>xmake非常好用,继续加油!</td>
+</tr>
+<tr>
 <td>2021.10.04</td>
 <td>S*o</td>
 <td>微信</td>
@@ -512,7 +519,7 @@
 <td>氧烷</td>
 <td>支付宝</td>
 <td>¥16.66</td>
-<td>xmake,赞��</td>
+<td>xmake,赞👍</td>
 </tr>
 <tr>
 <td>2017.11.19</td>

+ 88 - 0
mirror/zh-cn/guide/project_examples.html

@@ -641,6 +641,94 @@ target("test")
     add_files("src/*.rs")
 </code></pre>
 <p>更多例子见:<a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/rust">Rust Examples</a></p>
+<h3 id="cargo">添加 Cargo 包依赖</h3>
+<p>例子: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cargo_deps">https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cargo_deps</a></p>
+<pre><code class="lang-lua">add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+    set_kind("binary")
+    add_files("src/main.rs")
+    add_packages("cargo::base64", "cargo::flate2")
+</code></pre>
+<h3 id="cxxbridgecrust">使用 cxxbridge 在 c++ 中调用 rust</h3>
+<p>例子: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library">https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library</a></p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+add_requires("cargo::cxx 1.0")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.rs")
+    set_values("rust.cratetype", "staticlib")
+    add_packages("cargo::cxx")
+
+target("test")
+    set_kind("binary")
+    add_rules("rust.cxxbridge")
+    add_deps("foo")
+    add_files("src/main.cc")
+    add_files("src/bridge.rsx")
+</code></pre>
+<p>foo.rs</p>
+<pre><code class="lang-rust">#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+    return a + b;
+}
+</code></pre>
+<p>我们还需要在 c++ 项目中添加桥接文件 bridge.rsx</p>
+<pre><code class="lang-rust">#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+</code></pre>
+<p>main.cc</p>
+<pre><code class="lang-c++">#include <stdio.h>
+#include "bridge.rs.h"
+
+int main(int argc, char** argv) {
+    printf("add(1, 2) == %d\n", add(1, 2));
+    return 0;
+}
+</code></pre>
+<h3 id="rustc">在 Rust 中调用 C++</h3>
+<p>例子: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/rust_call_cxx_library">https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/rust_call_cxx_library</a></p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.cc")
+
+target("test")
+    set_kind("binary")
+    add_deps("foo")
+    add_files("src/main.rs")
+</code></pre>
+<p>main.rs</p>
+<pre><code class="lang-rust">extern "C" {
+    fn add(a: i32, b: i32) -> i32;
+}
+
+fn main() {
+    unsafe {
+        println!("add(1, 2) = {}", add(1, 2));
+    }
+}
+</code></pre>
+<p>foo.cc</p>
+<pre><code class="lang-c++">extern "C" int add(int a, int b) {
+    return a + b;
+}
+</code></pre>
 <h2 id="swift">Swift程序</h2>
 <p>创建空工程:</p>
 <pre><code class="lang-console">$ xmake create -l swift -t console test

+ 41 - 0
mirror/zh-cn/manual/custom_rule.html

@@ -504,6 +504,47 @@ int main(int argc, char** argv)
 <pre><code class="lang-console">cat build/.gens/test/macosx/x86_64/release/rules/c++/bin2c/image.png.h
   0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x78, 0x6D, 0x61, 0x6B, 0x65, 0x21, 0x0A, 0x00
 </code></pre>
+<h4 id="utilsglsl2spv">utils.glsl2spv</h4>
+<p>v2.6.1 以上版本可以使用次规则,在项目中引入 <code>*.vert/*.frag</code> 等 glsl shader 文件,然后实现自动编译生成 <code>*.spv</code> 文件。</p>
+<p>另外,我们还支持以 C/C++ 头文件的方式,二进制内嵌 spv 文件数据,方便程序使用。</p>
+<h5 id="spv">编译生成 spv 文件</h5>
+<p>xmake 会自动调用 glslangValidator 或者 glslc 去编译 shaders 生成 .spv 文件,然后输出到指定的 <code>{outputdir = "build"}</code> 目录下。</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {outputdir = "build"})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+</code></pre>
+<p>注,这里的 <code>add_packages("glslang")</code> 主要用于引入和绑定 glslang 包中的 glslangValidator,确保 xmake 总归能够使用它。</p>
+<p>当然,如果用户自己系统上已经安装了它,也可以不用额外绑定这个包,不过我还是建议添加一下。</p>
+<h5 id="cc">编译生成 c/c++ 头文件</h5>
+<p>我们也可以内部借助 bin2c 模块,将编译后的 spv 文件生成对应的二进制头文件,方便用户代码中直接引入,我们只需要启用 <code>{bin2c = true}</code>。:w</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {bin2c = true})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+</code></pre>
+<p>然后我们可以在代码这么引入:</p>
+<pre><code class="lang-c">static unsigned char g_test_vert_spv_data[] = {
+    #include "test.vert.spv.h"
+};
+
+static unsigned char g_test_frag_spv_data[] = {
+    #include "test.frag.spv.h"
+};
+</code></pre>
+<p>跟 bin2c 规则的使用方式类似,完整例子见:<a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/other/glsl2spv">glsl2spv example</a></p>
 <h3 id="rule">rule</h3>
 <h4 id="">定义规则</h4>
 <pre><code class="lang-lua">rule("markdown")

+ 17 - 0
mirror/zh-cn/package/remote_package.html

@@ -265,6 +265,10 @@ target("test")
     add_files("src/*.c")
     add_packages("zlib", "pcre2")
 </code></pre>
+<p>如果 vcpkg 包带有可选特性,我们也可以直接使用 vcpkg 的语法格式 <code>packagename[feature1,feature2]</code> 来安装包。</p>
+<p>例如:</p>
+<pre><code class="lang-lua">add_requires("vcpkg::boost[core]")
+</code></pre>
 <h3 id="conan">添加 conan 的依赖包</h3>
 <pre><code class="lang-lua">add_requires("conan::zlib/1.2.11", {alias = "zlib", debug = true})
 add_requires("conan::openssl/1.1.1g", {alias = "openssl",
@@ -382,6 +386,19 @@ target("test")
     add_files("src/main.nim")
     add_packages("nimble::zip")
 </code></pre>
+<h3 id="cargo">添加 cargo 的依赖包</h3>
+<p>Cargo 依赖包主要给 rust 项目集成使用,例如:</p>
+<pre><code class="lang-lua">add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+    set_kind("binary")
+    add_files("src/main.rs")
+    add_packages("cargo::base64", "cargo::flate2")
+</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>
 <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>

+ 36 - 9
package/remote_package.md

@@ -227,7 +227,7 @@ add_requires("brew::pcre2/libpcre2-8", {alias = "pcre2"})
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("pcre2", "zlib")
 ```
 
@@ -238,7 +238,7 @@ add_requires("vcpkg::zlib", "vcpkg::pcre2")
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("vcpkg::zlib", "vcpkg::pcre2")
 ```
 
@@ -250,20 +250,28 @@ add_requires("vcpkg::pcre2", {alias = "pcre2"})
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("zlib", "pcre2")
 ```
 
+If the vcpkg package has optional features, we can also directly use the vcpkg syntax format `packagename[feature1,feature2]` to install the package.
+
+e.g:
+
+```lua
+add_requires("vcpkg::boost[core]")
+```
+
 ### Add conan dependency package
 
 ```lua
 add_requires("conan::zlib/1.2.11", {alias = "zlib", debug = true})
-add_requires("conan::openssl/1.1.1g", {alias = "openssl", 
+add_requires("conan::openssl/1.1.1g", {alias = "openssl",
     configs = {options = "OpenSSL:shared=True"}})
 
 target("test")
     set_kind("binary")
-    add_files("src/*.c") 
+    add_files("src/*.c")
     add_packages("openssl", "zlib")
 ```
 
@@ -418,6 +426,25 @@ target("test")
      add_packages("nimble::zip")
 ```
 
+### Add cargo's dependency package
+
+Cargo dependency packages are mainly used for rust project integration, for example:
+
+```lua
+add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+     set_kind("binary")
+     add_files("src/main.rs")
+     add_packages("cargo::base64", "cargo::flate2")
+```
+
+However, we can also use cxxbridge in C++ to call the Rust library interface to reuse all Rust packages in disguise.
+
+For a complete example, see: [Call Rust in C++](https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library)
+
 ## 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.
@@ -495,7 +522,7 @@ target("test")
     add_packages("libjpeg")
 ```
 
-## Package Management Command 
+## Package Management Command
 
 The package management command `$ xmake require` can be used to manually display the download, install, uninstall, retrieve, and view package information.
 
@@ -565,7 +592,7 @@ Will also search for pcre, pcre2 and other packages.
 $ xmake require --list
 ```
 
-## Repository Management Command 
+## Repository Management Command
 
 As mentioned above, adding a private repository is available (supporting local path addition):
 
@@ -743,7 +770,7 @@ package("zlib")
     on_install("linux", "macosx", function (package)
         import("package.tools.autoconf").install(package, {"--static"})
     end)
- 
+
     on_install("iphoneos", "android@linux,macosx", "mingw@linux,macosx", function (package)
         import("package.tools.autoconf").configure(package, {host = "", "--static"})
         io.gsub("Makefile", "\nAR=.-\n",      "\nAR=" .. (package:build_getenv("ar") or "") .. "\n")
@@ -905,7 +932,7 @@ In the engineering project, we can also view a list of configurable parameters a
 ```bash
 $ xmake require --info pcre2
 The package info of project:
-    require(pcre2): 
+    require(pcre2):
       -> description: A Perl Compatible Regular Expressions Library
       -> version: 10.31
       ...

+ 90 - 90
sitemap.xml

@@ -12,452 +12,452 @@
 
 <url>
   <loc>https://xmake.io/mirror/guide/project_examples.html</loc>
-  <lastmod>2021-11-14T21:33:18+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:54+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/other_features.html</loc>
-  <lastmod>2021-11-14T21:33:18+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:54+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2021-11-14T21:33:18+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:54+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2021-11-14T21:33:18+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:54+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2021-11-14T21:33:19+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:54+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2021-11-14T21:33:19+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2021-11-14T21:33:19+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2021-11-14T21:33:19+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2021-11-14T21:33:19+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-11-14T21:33:19+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2021-11-14T21:33:20+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2021-11-14T21:33:20+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:55+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2021-11-14T21:33:20+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2021-11-14T21:33:20+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2021-11-14T21:33:20+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-11-14T21:33:20+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2021-11-14T21:33:21+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2021-11-14T21:33:21+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/other_features.html</loc>
-  <lastmod>2021-11-14T21:33:21+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2021-11-14T21:33:21+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2021-11-14T21:33:21+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2021-11-14T21:33:21+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2021-11-14T21:33:22+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2021-11-14T21:33:22+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2021-11-14T21:33:22+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2021-11-14T21:33:22+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-11-14T21:33:22+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2021-11-14T21:33:22+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2021-11-14T21:33:23+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2021-11-14T21:33:23+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2021-11-14T21:33:23+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2021-11-14T21:33:23+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2021-11-14T21:33:23+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-11-14T21:33:23+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:38:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2021-11-14T21:33:24+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2021-11-14T21:33:25+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2021-11-14T21:33:25+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2021-11-14T21:33:25+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2021-11-14T21:33:25+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2021-11-14T21:33:25+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2021-11-14T21:33:25+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2021-11-14T21:33:26+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2021-11-14T21:33:26+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2021-11-14T21:33:26+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2021-11-14T21:33:26+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2021-11-14T21:33:26+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2021-11-14T21:33:26+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2021-11-14T21:33:27+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2021-11-14T21:33:27+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2021-11-14T21:33:27+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-11-14T21:33:27+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2021-11-14T21:33:27+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2021-11-14T21:33:27+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2021-11-14T21:33:28+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2021-11-14T21:33:28+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-11-14T21:33:28+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-11-14T21:33:28+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2021-11-14T21:33:28+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2021-11-14T21:33:28+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2021-11-14T21:33:29+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2021-11-14T21:33:30+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2021-11-14T21:33:30+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2021-11-14T21:33:30+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2021-11-14T21:33:30+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2021-11-14T21:33:30+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2021-11-14T21:33:30+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2021-11-14T21:33:31+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2021-11-14T21:33:31+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2021-11-14T21:33:31+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2021-11-14T21:33:31+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2021-11-14T21:33:31+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-11-14T21:33:31+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2021-11-14T21:33:32+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2021-11-14T21:33:32+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2021-11-14T21:33:32+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2021-11-14T21:33:32+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-11-14T21:33:32+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-11-14T21:33:32+08:00</lastmod>
+  <lastmod>2021-12-02T12:39:08+08:00</lastmod>
 </url>
 
 </urlset>

+ 115 - 0
zh-cn/guide/project_examples.md

@@ -845,6 +845,121 @@ target("test")
 
 更多例子见:[Rust Examples](https://github.com/xmake-io/xmake/tree/master/tests/projects/rust)
 
+### 添加 Cargo 包依赖
+
+例子: https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cargo_deps
+
+```lua
+add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+    set_kind("binary")
+    add_files("src/main.rs")
+    add_packages("cargo::base64", "cargo::flate2")
+```
+
+### 使用 cxxbridge 在 c++ 中调用 rust
+
+例子: https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+add_requires("cargo::cxx 1.0")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.rs")
+    set_values("rust.cratetype", "staticlib")
+    add_packages("cargo::cxx")
+
+target("test")
+    set_kind("binary")
+    add_rules("rust.cxxbridge")
+    add_deps("foo")
+    add_files("src/main.cc")
+    add_files("src/bridge.rsx")
+```
+
+foo.rs
+
+```rust
+#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+    return a + b;
+}
+```
+
+我们还需要在 c++ 项目中添加桥接文件 bridge.rsx
+
+```rust
+#[cxx::bridge]
+mod foo {
+    extern "Rust" {
+        fn add(a: i32, b: i32) -> i32;
+    }
+}
+```
+
+main.cc
+
+```c++
+#include <stdio.h>
+#include "bridge.rs.h"
+
+int main(int argc, char** argv) {
+    printf("add(1, 2) == %d\n", add(1, 2));
+    return 0;
+}
+```
+
+### 在 Rust 中调用 C++
+
+例子: https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/rust_call_cxx_library
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+target("foo")
+    set_kind("static")
+    add_files("src/foo.cc")
+
+target("test")
+    set_kind("binary")
+    add_deps("foo")
+    add_files("src/main.rs")
+```
+
+main.rs
+
+```rust
+extern "C" {
+	fn add(a: i32, b: i32) -> i32;
+}
+
+fn main() {
+    unsafe {
+	    println!("add(1, 2) = {}", add(1, 2));
+    }
+}
+```
+
+foo.cc
+
+```c++
+extern "C" int add(int a, int b) {
+    return a + b;
+}
+```
+
 ## Swift程序
 
 创建空工程:

+ 58 - 0
zh-cn/manual/custom_rule.md

@@ -629,6 +629,64 @@ cat build/.gens/test/macosx/x86_64/release/rules/c++/bin2c/image.png.h
   0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x78, 0x6D, 0x61, 0x6B, 0x65, 0x21, 0x0A, 0x00
 ```
 
+#### utils.glsl2spv
+
+v2.6.1 以上版本可以使用次规则,在项目中引入 `*.vert/*.frag` 等 glsl shader 文件,然后实现自动编译生成 `*.spv` 文件。
+
+另外,我们还支持以 C/C++ 头文件的方式,二进制内嵌 spv 文件数据,方便程序使用。
+
+##### 编译生成 spv 文件
+
+xmake 会自动调用 glslangValidator 或者 glslc 去编译 shaders 生成 .spv 文件,然后输出到指定的 `{outputdir = "build"}` 目录下。
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {outputdir = "build"})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+```
+
+注,这里的 `add_packages("glslang")` 主要用于引入和绑定 glslang 包中的 glslangValidator,确保 xmake 总归能够使用它。
+
+当然,如果用户自己系统上已经安装了它,也可以不用额外绑定这个包,不过我还是建议添加一下。
+
+##### 编译生成 c/c++ 头文件
+
+我们也可以内部借助 bin2c 模块,将编译后的 spv 文件生成对应的二进制头文件,方便用户代码中直接引入,我们只需要启用 `{bin2c = true}`。:w
+
+```lua
+add_rules("mode.debug", "mode.release")
+
+add_requires("glslang", {configs = {binaryonly = true}})
+
+target("test")
+    set_kind("binary")
+    add_rules("utils.glsl2spv", {bin2c = true})
+    add_files("src/*.c")
+    add_files("src/*.vert", "src/*.frag")
+    add_packages("glslang")
+```
+
+然后我们可以在代码这么引入:
+
+```c
+static unsigned char g_test_vert_spv_data[] = {
+    #include "test.vert.spv.h"
+};
+
+static unsigned char g_test_frag_spv_data[] = {
+    #include "test.frag.spv.h"
+};
+```
+
+跟 bin2c 规则的使用方式类似,完整例子见:[glsl2spv example](https://github.com/xmake-io/xmake/tree/master/tests/projects/other/glsl2spv)
+
 ### rule
 
 #### 定义规则

+ 28 - 0
zh-cn/package/remote_package.md

@@ -281,6 +281,15 @@ target("test")
     add_packages("zlib", "pcre2")
 ```
 
+如果 vcpkg 包带有可选特性,我们也可以直接使用 vcpkg 的语法格式 `packagename[feature1,feature2]` 来安装包。
+
+例如:
+
+```lua
+add_requires("vcpkg::boost[core]")
+```
+
+
 ### 添加 conan 的依赖包
 
 ```lua
@@ -445,6 +454,25 @@ target("test")
     add_packages("nimble::zip")
 ```
 
+### 添加 cargo 的依赖包
+
+Cargo 依赖包主要给 rust 项目集成使用,例如:
+
+```lua
+add_rules("mode.release", "mode.debug")
+add_requires("cargo::base64 0.13.0")
+add_requires("cargo::flate2 1.0.17", {configs = {features = "zlib"}})
+
+target("test")
+    set_kind("binary")
+    add_files("src/main.rs")
+    add_packages("cargo::base64", "cargo::flate2")
+```
+
+不过,我们也可以在 C++ 中通过 cxxbridge 的方式,调用 Rust 库接口,来变相复用所有的 Rust 包。
+
+完整例子见:[Call Rust in C++](https://github.com/xmake-io/xmake/tree/dev/tests/projects/rust/cxx_call_rust_library)
+
 ## 使用自建私有包仓库
 
 如果需要的包不在官方仓库[xmake-repo](https://github.com/xmake-io/xmake-repo)中,我们可以提交贡献代码到仓库进行支持。