Browse Source

update docs

ruki 1 year ago
parent
commit
22e69e4e4d

+ 14 - 0
guide/configuration.md

@@ -122,6 +122,20 @@ $ xmake f -p watchos [-a i386|armv7k]
 $ xmake
 ```
 
+### HarmonyOS
+
+Version 2.9.1 adds native toolchain compilation support for the Hongmeng OS platform:
+
+```bash
+$ xmake f -p harmony
+```
+
+xmake will automatically detect the default SDK path, but you can also specify the Harmony SDK path.
+
+```bash
+$ xmake f -p Harmony --sdk=/Users/ruki/Library/Huawei/Sdk/openharmony/10/native
+```
+
 ## Cross Compilation
 
 Generally, if we need to compile and generate object files that can be run on other devices in the current pc environment, we need to compile and generate them through the corresponding cross-compilation tool chain, such as compiling linux programs on win/macos, or Compile object files of other embedded devices, etc.

+ 103 - 59
manual/native_modules.md

@@ -3,9 +3,20 @@ Native modules can be used in the build workflow.
 
 ### Native module
 
-xmake will do dual-stage build if any native-module added. Native-modules can be imported in script-scope after first stage's build.
+We know that in xmake, you can import some lua modules through the import interface for use in the script domain. However, if the operation of some modules is time-consuming, then lua implementation is not an ideal choice.
+Therefore, in the new version, we have added support for the native lua module, which can be implemented through native to achieve speed-up optimization. Moreover, importing and using the module is as simple as the lua module.
 
-#### Establish shared module
+When using native modules, xmake will perform two stages of compilation. First, it will automatically compile the native module, and then import the module into lua as a library or binary. For users, they only need to call import to import.
+
+#### Define dynamic library module
+
+The advantage of the dynamic library module is that it not only achieves performance acceleration through native, but also avoids the creation of additional sub-processes for each call, making it more lightweight and further improving the speed.
+
+We can first define a dynamic library module, which fully supports all C APIs of Lua, so we can also directly introduce some third-party open source Lua native modules for use.
+
+Here we also have a complete example of importing the lua-cjson module for reference: [native_module_cjson](https://github.com/xmake-io/xmake/tree/master/tests/projects/other/native_module_cjson)
+
+First, we first implement the shared native code, so the interface is exported through the lua API.
 
 ./modules/foo/foo.c
 
@@ -13,45 +24,61 @@ xmake will do dual-stage build if any native-module added. Native-modules can be
 #include <xmi.h>
 
 static int c_add(lua_State* lua) {
-    int a = lua_tointeger(lua, 1);
-    int b = lua_tointeger(lua, 2);
-    lua_pushinteger(lua, a + b);
-    return 1;
+     int a = lua_tointeger(lua, 1);
+     int b = lua_tointeger(lua, 2);
+     lua_pushinteger(lua, a + b);
+     return 1;
 }
 
 static int c_sub(lua_State* lua) {
-    int a = lua_tointeger(lua, 1);
-    int b = lua_tointeger(lua, 2);
-    lua_pushinteger(lua, a - b);
-    return 1;
+     int a = lua_tointeger(lua, 1);
+     int b = lua_tointeger(lua, 2);
+     lua_pushinteger(lua, a - b);
+     return 1;
 }
 
 int luaopen(foo, lua_State* lua) {
-    // Collect 'add' and 'sub'
-    static const luaL_Reg funcs[] = {
-        {"add", c_add},
-        {"sub", c_sub},
-        {NULL, NULL}
-    };
-    lua_newtable(lua);
-    // send function table to lua runtime
-    luaL_setfuncs(lua, funcs, 0);
-    return 1;
+     //Collect add and sub
+     static const luaL_Reg funcs[] = {
+         {"add", c_add},
+         {"sub", c_sub},
+         {NULL, NULL}
+     };
+     lua_newtable(lua);
+     // pass function list
+     luaL_setfuncs(lua, funcs, 0);
+     return 1;
 }
 ```
 
+Notice here that we have included an interface header file of `xmi.h`. In fact, we can also directly introduce `lua.h` and `luaconf.h`. The effect is the same, but it will provide better cross-platform performance. , it will automatically handle the differences between lua/luajit and versions internally.
+
+Then, we configure `add_rules("modules.shared")` to compile as a shared native module without introducing any other dependencies.
+
+Even Lua dependencies do not need to be introduced, because the xmake main program has exported all Lua interfaces and can be used directly, so the entire module is very lightweight.
+
 ./modules/foo/xmake.lua
 
 ```lua
 add_rules("mode.debug", "mode.release")
 
 target("foo")
-    -- set this target as a 'shared' lua module
-    add_rules("module.shared")
-    add_files("foo.c")
+     -- Specify the target as the library lua module
+     add_rules("module.shared")
+     add_files("foo.c")
 ```
 
-#### Establish binary module
+#### Define binary module
+
+In addition to the dynamic library module, we also provide the import of another binary module. It is actually an executable file. Every time the module interface is called, a child process will be called.
+
+So what are the benefits of it? Although it is not as efficient as the dynamic library module, its module implementation is simpler. There is no need to call the lua API. It only needs to process the parameter data and output the return value through stdout.
+
+In addition, compared to binary distribution, it is distributed through source code, so it also solves the cross-platform problem.
+
+Whether to use a dynamic library module or a binary module depends on your needs. If you want a simple implementation, you can consider a binary module. If you want to be efficient, use a dynamic library module.
+
+In addition, if you need to speed up through parallel execution, you can also use binary modules.
 
 ./modules/bar/bar.cpp
 
@@ -61,16 +88,10 @@ target("foo")
 #include <cstdlib>
 
 int main(int argc, char** argv) {
-    int a = atoi(argv[1]);
-    int b = atoi(argv[2]);
-    printf("%d", 
-#ifdef ADD
-        a + b
-#else
-        a - b
-#endif
-    );
-    return 0;
+     int a = atoi(argv[1]);
+     int b = atoi(argv[2]);
+     printf("%d", a + b);
+     return 0;
 }
 ```
 
@@ -80,39 +101,62 @@ int main(int argc, char** argv) {
 add_rules("mode.debug", "mode.release")
 
 target("add")
-    -- set this target as a 'binary' lua module
-    add_rules("module.binary")
-    add_files("bar.cpp")
-    add_defines("ADD")
-
-target("sub")
-    add_rules("module.binary")
-    add_files("bar.cpp")
+     -- Specify the target as a binary lua module
+     add_rules("module.binary")
+     add_files("bar.cpp")
 ```
 
 #### Import native module
 
+For module import, we only need to call import, which is exactly the same as importing lua modules.
+
 ./xmake.lua
 
 ```lua
 add_rules("mode.debug", "mode.release")
--- include all targets in ./modules as native modules
+--Add native modules in the ./modules directory
 add_moduledirs("modules")
 
 target("test")
-set_kind("phony")
-on_load(function(target)
-    local foo = import("foo", {
-        -- Build this module everytime?
-        always_build = true
-    })
-    local bar = import("bar", {
-        always_build = true
-    })
-    print("foo: 1 + 1 = %s", foo.add(1, 1))
-    print("foo: 1 - 1 = %s", foo.sub(1, 1))
-    print("bar: 1 + 1 = %s", bar.add(1, 1))
-    print("bar: 1 - 1 = %s", bar.sub(1, 1))
-end)
-
-```
+     set_kind("phony")
+     on_load(function(target)
+         import("foo", {always_build = true})
+         import("bar")
+         print("foo: 1 + 1 = %s", foo.add(1, 1))
+         print("foo: 1 - 1 = %s", foo.sub(1, 1))
+         print("bar: 1 + 1 = %s", bar.add(1, 1))
+     end)
+```
+
+Since the construction of the plug-in module is completely independent from the main project, the native module will only be built once. If you want to trigger incremental plug-in compilation, you need to configure `always_build = true`, so that xmake will detect it every time Check whether the plug-in code has been changed. If so, the plug-in will be automatically incrementally built.
+
+The first execution effect is as follows:
+
+```bash
+ruki-2:native_module ruki$ xmake
+[50%]: cache compiling.release src/foo.c
+[50%]: cache compiling.release src/bar.c
+[75%]: linking.release libmodule_foo.dylib
+[75%]: linking.release module_bar
+[100%]: build ok, spent 1.296s
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+```
+
+When executed for the second time, the plug-in will not be built and the module can be used directly:
+
+```bash
+ruki-2:native_module ruki$ xmake
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+```
+
+#### Use as codegen
+
+Through the new native module feature, we can also use it to implement auto-codegen, and then continue to execute the subsequent compilation process based on the automatically generated code.
+
+There is also a complete example here for reference: [autogen_shared_module](https://github.com/xmake-io/xmake/tree/master/tests/projects/other/autogen_shared_module).

+ 7 - 0
mirror/guide/configuration.html

@@ -158,6 +158,13 @@ $ xmake
 <pre><code class="lang-bash">$ xmake f -p watchos [-a i386|armv7k]
 $ xmake
 </code></pre>
+<h3 id="harmonyos">HarmonyOS</h3>
+<p>Version 2.9.1 adds native toolchain compilation support for the Hongmeng OS platform:</p>
+<pre><code class="lang-bash">$ xmake f -p harmony
+</code></pre>
+<p>xmake will automatically detect the default SDK path, but you can also specify the Harmony SDK path.</p>
+<pre><code class="lang-bash">$ xmake f -p Harmony --sdk=/Users/ruki/Library/Huawei/Sdk/openharmony/10/native
+</code></pre>
 <h2 id="crosscompilation">Cross Compilation</h2>
 <p>Generally, if we need to compile and generate object files that can be run on other devices in the current pc environment, we need to compile and generate them through the corresponding cross-compilation tool chain, such as compiling linux programs on win/macos, or Compile object files of other embedded devices, etc.</p>
 <p>The usual cross-compilation tool chain is based on gcc/clang, and most of them have a structure similar to the following:</p>

+ 55 - 9
mirror/manual/conditions.html

@@ -195,15 +195,61 @@ if is_plat("macosx", "iphoneos") then
     add_frameworks("Foundation")
 end
 </code></pre>
-<p>Support platforms:</p>
-<ul>
-<li>windows</li>
-<li>linux</li>
-<li>macosx</li>
-<li>android</li>
-<li>iphoneos</li>
-<li>watchos</li>
-</ul>
+<p>Available platforms:</p>
+<table>
+<thead>
+<tr>
+<th>Platform</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>android</td>
+</tr>
+<tr>
+<td>appletvos</td>
+</tr>
+<tr>
+<td>applexros</td>
+</tr>
+<tr>
+<td>bsd</td>
+</tr>
+<tr>
+<td>cross</td>
+</tr>
+<tr>
+<td>cygwin</td>
+</tr>
+<tr>
+<td>haiku</td>
+</tr>
+<tr>
+<td>iphoneos</td>
+</tr>
+<tr>
+<td>linux</td>
+</tr>
+<tr>
+<td>macosx</td>
+</tr>
+<tr>
+<td>mingw</td>
+</tr>
+<tr>
+<td>msys</td>
+</tr>
+<tr>
+<td>wasm</td>
+</tr>
+<tr>
+<td>watchos</td>
+</tr>
+<tr>
+<td>windows</td>
+</tr>
+</tbody>
+</table>
 <h3 id="is_host">is_host</h3>
 <h4 id="isthecurrentcompilationhostsystem">Is the current compilation host system</h4>
 <p>Some compilation platforms can be built on multiple different operating systems, for example: android ndk (on linux, macOS and windows).</p>

+ 1 - 1
mirror/manual/extension_modules.html

@@ -528,7 +528,7 @@ end
 <ul>
 <li>Get compiled command line list</li>
 </ul>
-<p>A little different from <a href="#compilercompargv">compiler.compargv</a> is that this interface returns a list of parameters, table representation, more convenient to operate:</p>
+<p>A little different from <a href="#compilercompcmd">compiler.compcmd</a> is that this interface returns a list of parameters, table representation, more convenient to operate:</p>
 <pre><code class="lang-lua">local program, argv = compiler.compargv("xxx.c", "xxx.o")
 </code></pre>
 <h4 id="compilercompflags">compiler.compflags</h4>

+ 213 - 0
mirror/manual/native_modules.html

@@ -0,0 +1,213 @@
+<!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/#/manual/native_modules">https://xmake.io/#/manual/native_modules</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>
+    <p>Native modules can be used in the build workflow.</p>
+<h3 id="nativemodule">Native module</h3>
+<p>We know that in xmake, you can import some lua modules through the import interface for use in the script domain. However, if the operation of some modules is time-consuming, then lua implementation is not an ideal choice.<br>Therefore, in the new version, we have added support for the native lua module, which can be implemented through native to achieve speed-up optimization. Moreover, importing and using the module is as simple as the lua module.</p>
+<p>When using native modules, xmake will perform two stages of compilation. First, it will automatically compile the native module, and then import the module into lua as a library or binary. For users, they only need to call import to import.</p>
+<h4 id="definedynamiclibrarymodule">Define dynamic library module</h4>
+<p>The advantage of the dynamic library module is that it not only achieves performance acceleration through native, but also avoids the creation of additional sub-processes for each call, making it more lightweight and further improving the speed.</p>
+<p>We can first define a dynamic library module, which fully supports all C APIs of Lua, so we can also directly introduce some third-party open source Lua native modules for use.</p>
+<p>Here we also have a complete example of importing the lua-cjson module for reference: <a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/other/native_module_cjson">native_module_cjson</a></p>
+<p>First, we first implement the shared native code, so the interface is exported through the lua API.</p>
+<p>./modules/foo/foo.c</p>
+<pre><code class="lang-c++">#include <xmi.h>
+
+static int c_add(lua_State* lua) {
+     int a = lua_tointeger(lua, 1);
+     int b = lua_tointeger(lua, 2);
+     lua_pushinteger(lua, a + b);
+     return 1;
+}
+
+static int c_sub(lua_State* lua) {
+     int a = lua_tointeger(lua, 1);
+     int b = lua_tointeger(lua, 2);
+     lua_pushinteger(lua, a - b);
+     return 1;
+}
+
+int luaopen(foo, lua_State* lua) {
+     //Collect add and sub
+     static const luaL_Reg funcs[] = {
+         {"add", c_add},
+         {"sub", c_sub},
+         {NULL, NULL}
+     };
+     lua_newtable(lua);
+     // pass function list
+     luaL_setfuncs(lua, funcs, 0);
+     return 1;
+}
+</code></pre>
+<p>Notice here that we have included an interface header file of <code>xmi.h</code>. In fact, we can also directly introduce <code>lua.h</code> and <code>luaconf.h</code>. The effect is the same, but it will provide better cross-platform performance. , it will automatically handle the differences between lua/luajit and versions internally.</p>
+<p>Then, we configure <code>add_rules("modules.shared")</code> to compile as a shared native module without introducing any other dependencies.</p>
+<p>Even Lua dependencies do not need to be introduced, because the xmake main program has exported all Lua interfaces and can be used directly, so the entire module is very lightweight.</p>
+<p>./modules/foo/xmake.lua</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+target("foo")
+     -- Specify the target as the library lua module
+     add_rules("module.shared")
+     add_files("foo.c")
+</code></pre>
+<h4 id="definebinarymodule">Define binary module</h4>
+<p>In addition to the dynamic library module, we also provide the import of another binary module. It is actually an executable file. Every time the module interface is called, a child process will be called.</p>
+<p>So what are the benefits of it? Although it is not as efficient as the dynamic library module, its module implementation is simpler. There is no need to call the lua API. It only needs to process the parameter data and output the return value through stdout.</p>
+<p>In addition, compared to binary distribution, it is distributed through source code, so it also solves the cross-platform problem.</p>
+<p>Whether to use a dynamic library module or a binary module depends on your needs. If you want a simple implementation, you can consider a binary module. If you want to be efficient, use a dynamic library module.</p>
+<p>In addition, if you need to speed up through parallel execution, you can also use binary modules.</p>
+<p>./modules/bar/bar.cpp</p>
+<pre><code class="lang-c++">#include <stdio.h>
+#include <stdlib.h>
+#include <cstdlib>
+
+int main(int argc, char** argv) {
+     int a = atoi(argv[1]);
+     int b = atoi(argv[2]);
+     printf("%d", a + b);
+     return 0;
+}
+</code></pre>
+<p>./modules/bar/xmake.lua</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+target("add")
+     -- Specify the target as a binary lua module
+     add_rules("module.binary")
+     add_files("bar.cpp")
+</code></pre>
+<h4 id="importnativemodule">Import native module</h4>
+<p>For module import, we only need to call import, which is exactly the same as importing lua modules.</p>
+<p>./xmake.lua</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+--Add native modules in the ./modules directory
+add_moduledirs("modules")
+
+target("test")
+     set_kind("phony")
+     on_load(function(target)
+         import("foo", {always_build = true})
+         import("bar")
+         print("foo: 1 + 1 = %s", foo.add(1, 1))
+         print("foo: 1 - 1 = %s", foo.sub(1, 1))
+         print("bar: 1 + 1 = %s", bar.add(1, 1))
+     end)
+</code></pre>
+<p>Since the construction of the plug-in module is completely independent from the main project, the native module will only be built once. If you want to trigger incremental plug-in compilation, you need to configure <code>always_build = true</code>, so that xmake will detect it every time Check whether the plug-in code has been changed. If so, the plug-in will be automatically incrementally built.</p>
+<p>The first execution effect is as follows:</p>
+<pre><code class="lang-bash">ruki-2:native_module ruki$ xmake
+[50%]: cache compiling.release src/foo.c
+[50%]: cache compiling.release src/bar.c
+[75%]: linking.release libmodule_foo.dylib
+[75%]: linking.release module_bar
+[100%]: build ok, spent 1.296s
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+</code></pre>
+<p>When executed for the second time, the plug-in will not be built and the module can be used directly:</p>
+<pre><code class="lang-bash">ruki-2:native_module ruki$ xmake
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+</code></pre>
+<h4 id="useascodegen">Use as codegen</h4>
+<p>Through the new native module feature, we can also use it to implement auto-codegen, and then continue to execute the subsequent compilation process based on the automatically generated code.</p>
+<p>There is also a complete example here for reference: <a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/other/autogen_shared_module">autogen_shared_module</a>.</p>
+</article>
+</body>
+</html>

+ 99 - 46
mirror/manual/project_target.html

@@ -609,41 +609,49 @@ set_optimize("fastest")
 <thead>
 <tr>
 <th>Value</th>
-<th>Description</th>
+<th>C language standard</th>
 </tr>
 </thead>
 <tbody>
 <tr>
-<td>ansi</td>
-<td>c language standard: ansi</td>
+<td><code>ansi</code></td>
+<td><code>ansi</code></td>
+</tr>
+<tr>
+<td><code>c89</code></td>
+<td><code>c89</code></td>
 </tr>
 <tr>
-<td>c89</td>
-<td>c language standard: c89</td>
+<td><code>gnu89</code></td>
+<td><code>gnu89</code></td>
 </tr>
 <tr>
-<td>gnu89</td>
-<td>c language standard: gnu89</td>
+<td><code>c90</code></td>
+<td><code>c90</code></td>
 </tr>
 <tr>
-<td>c99</td>
-<td>c language standard: c99</td>
+<td><code>gnu90</code></td>
+<td><code>gnu90</code></td>
 </tr>
 <tr>
-<td>gnu99</td>
-<td>c language standard: gnu99</td>
+<td><code>c99</code></td>
+<td><code>c99</code></td>
 </tr>
 <tr>
-<td>c11</td>
-<td>c language standard: c11</td>
+<td><code>gnu99</code></td>
+<td><code>gnu99</code></td>
 </tr>
 <tr>
-<td>c17</td>
-<td>c language standard: c17</td>
+<td><code>c11</code></td>
+<td><code>c11</code></td>
 </tr>
 <tr>
-<td>clatest</td>
-<td>c language standard: clatest</td>
+<td><code>c17</code></td>
+<td><code>c17</code></td>
+</tr>
+<tr>
+<td><code>clatest</code></td>
+<td><code>clatest</code></td>
 </tr>
 </tbody>
 </table>
@@ -651,65 +659,97 @@ set_optimize("fastest")
 <thead>
 <tr>
 <th>Value</th>
-<th>Description</th>
+<th>C++ language standard</th>
 </tr>
 </thead>
 <tbody>
 <tr>
-<td>cxx98</td>
-<td>c++ language standard: <code>c++98</code></td>
+<td><code>cxx98</code></td>
+<td><code>c++98</code></td>
+</tr>
+<tr>
+<td><code>gnuxx98</code></td>
+<td><code>gnu++98</code></td>
+</tr>
+<tr>
+<td><code>cxx03</code></td>
+<td><code>c++03</code></td>
+</tr>
+<tr>
+<td><code>gnuxx03</code></td>
+<td><code>gnu++03</code></td>
+</tr>
+<tr>
+<td><code>cxx11</code></td>
+<td><code>c++11</code></td>
 </tr>
 <tr>
-<td>gnuxx98</td>
-<td>c++ language standard: <code>gnu++98</code></td>
+<td><code>gnuxx11</code></td>
+<td><code>gnu++11</code></td>
 </tr>
 <tr>
-<td>cxx11</td>
-<td>c++ language standard: <code>c++11</code></td>
+<td><code>cxx14</code></td>
+<td><code>c++14</code></td>
 </tr>
 <tr>
-<td>gnuxx11</td>
-<td>c++ language standard: <code>gnu++11</code></td>
+<td><code>gnuxx14</code></td>
+<td><code>gnu++14</code></td>
 </tr>
 <tr>
-<td>cxx14</td>
-<td>c++ language standard: <code>c++14</code></td>
+<td><code>cxx1z</code></td>
+<td><code>c++1z</code></td>
 </tr>
 <tr>
-<td>gnuxx14</td>
-<td>c++ language standard: <code>gnu++14</code></td>
+<td><code>gnuxx1z</code></td>
+<td><code>gnu++1z</code></td>
 </tr>
 <tr>
-<td>cxx1z</td>
-<td>c++ language standard: <code>c++1z</code></td>
+<td><code>cxx17</code></td>
+<td><code>c++17</code></td>
 </tr>
 <tr>
-<td>gnuxx1z</td>
-<td>c++ language standard: <code>gnu++1z</code></td>
+<td><code>gnuxx17</code></td>
+<td><code>gnu++17</code></td>
 </tr>
 <tr>
-<td>cxx17</td>
-<td>c++ language standard: <code>c++17</code></td>
+<td><code>cxx20</code></td>
+<td><code>c++20</code></td>
 </tr>
 <tr>
-<td>gnuxx17</td>
-<td>c++ language standard: <code>gnu++17</code></td>
+<td><code>gnuxx20</code></td>
+<td><code>gnu++20</code></td>
 </tr>
 <tr>
-<td>cxx20</td>
-<td>c++ language standard: <code>c++20</code></td>
+<td><code>cxx2a</code></td>
+<td><code>c++2a</code></td>
 </tr>
 <tr>
-<td>gnuxx20</td>
-<td>c++ language standard: <code>gnu++20</code></td>
+<td><code>gnuxx2a</code></td>
+<td><code>gnu++2a</code></td>
 </tr>
 <tr>
-<td>cxxlatest</td>
-<td>c++ language standard: <code>c++latest</code></td>
+<td><code>cxx20</code></td>
+<td><code>c++23</code></td>
 </tr>
 <tr>
-<td>gnuxxlatest</td>
-<td>c++ language standard: <code>gnu++latest</code></td>
+<td><code>gnuxx20</code></td>
+<td><code>gnu++23</code></td>
+</tr>
+<tr>
+<td><code>cxx2b</code></td>
+<td><code>c++2b</code></td>
+</tr>
+<tr>
+<td><code>gnuxx2b</code></td>
+<td><code>gnu++2b</code></td>
+</tr>
+<tr>
+<td><code>cxxlatest</code></td>
+<td><code>c++latest</code></td>
+</tr>
+<tr>
+<td><code>gnuxxlatest</code></td>
+<td><code>gnu++latest</code></td>
 </tr>
 </tbody>
 </table>
@@ -813,6 +853,15 @@ target("test")
     add_files("src/*.md")
     add_files("src/*.markdown")
 </code></pre>
+<p>We can send arguments to rule in add_rules:</p>
+<pre><code class="lang-lua">rule("my_rule")
+    on_load(function (target)
+        local my_arg = target:extraconf("rules", "my_rule", "my_arg") -- "my arg"
+    end)
+
+target("test")
+    add_rules("my_rule", { my_arg = "my arg"})
+</code></pre>
 <p>We can also specify the application of local files to the rules, see: <a href="#targetadd_files">add_files</a>.</p>
 <h3 id="targeton_load">target:on_load</h3>
 <h4 id="runcustomloadtargetconfigurationscript">Run custom load target configuration script</h4>
@@ -1701,6 +1750,10 @@ add_culdflags("-gencode arch=compute_30,code=sm_30")
 <p>Add static link option</p>
 <pre><code class="lang-lua">add_ldflags("-L/xxx", "-lxxx")
 </code></pre>
+<p>While adding flags, argument with space is not allowed defaultly, use expand = false instead.</p>
+<pre><code class="lang-lua">-- add_ldflags("-L/my lib") ERROR: Invalid arguments
+add_ldflags({"-L/my lib"}, {expand = false}) -- OK
+</code></pre>
 <h3 id="targetadd_arflags">target:add_arflags</h3>
 <h4 id="addarchivelibraryflags">Add archive library flags</h4>
 <p>Affect the generation of static libraries</p>

+ 7 - 0
mirror/zh-cn/guide/configuration.html

@@ -157,6 +157,13 @@ $ xmake
 <pre><code class="lang-console">$ xmake f -p wasm --toolchain=wasi
 $ xmake
 </code></pre>
+<h3 id="harmonyos">HarmonyOS (鸿蒙)</h3>
+<p>2.9.1 版本新增了鸿蒙 OS 平台的 native 工具链编译支持:</p>
+<pre><code class="lang-bash">$ xmake f -p harmony
+</code></pre>
+<p>xmake 会自动探测默认的 SDK 路径,当然我们也可以指定 Harmony SDK 路径。</p>
+<pre><code class="lang-bash">$ xmake f -p Harmony --sdk=/Users/ruki/Library/Huawei/Sdk/openharmony/10/native
+</code></pre>
 <h2 id="">交叉编译配置</h2>
 <p>通常,如果我们需要在当前pc环境编译生成其他设备上才能运行的目标文件时候,就需要通过对应的交叉编译工具链来编译生成它们,比如在win/macos上编译linux的程序,或者在linux上编译其他嵌入式设备的目标文件等。</p>
 <p>通常的交叉编译工具链都是基于gcc/clang的,大都具有类似如下的结构:</p>

+ 1 - 1
mirror/zh-cn/manual/extension_modules.html

@@ -373,7 +373,7 @@ end
 <ul>
 <li>获取编译命令行列表</li>
 </ul>
-<p>跟<a href="#compilercompargv">compiler.compargv</a>稍微有点区别的是,此接口返回的是参数列表,table表示,更加方便操作:</p>
+<p>跟<a href="#compilercompcmd">compiler.compcmd</a>稍微有点区别的是,此接口返回的是参数列表,table表示,更加方便操作:</p>
 <pre><code class="lang-lua">local program, argv = compiler.compargv("xxx.c", "xxx.o")
 </code></pre>
 <h4 id="compilercompflags">compiler.compflags</h4>

+ 213 - 0
mirror/zh-cn/manual/native_modules.html

@@ -0,0 +1,213 @@
+<!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/manual/native_modules">https://xmake.io/#/zh-cn/manual/native_modules</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>
+    <p>构建流程里可以使用原生模块。</p>
+<h3 id="">原生模块</h3>
+<p>我们知道,在 xmake 中,可以通过 import 接口去导入一些 lua 模块在脚本域中使用,但是如果一些模块的操作比较耗时,那么 lua 实现并不是理想的选择。<br>因此,新版本中,我们新增了 native lua 模块的支持,可以通过 native 实现,来达到提速优化的效果,并且模块导入和使用,还是跟 lua 模块一样简单。</p>
+<p>使用原生模块时,xmake 会进行两段编译,先会自动编译原生模块,后将模块导入 lua 作为库或二进制,而对于用户,仅仅只需要调用 import 导入即可。</p>
+<h4 id="">定义动态库模块</h4>
+<p>动态库模块的好处是,不仅仅通过 native 实现了性能加速,另外避免了每次调用额外的子进程创建,因此更加的轻量,速度进一步得到提升。</p>
+<p>我们可以先定义一个动态库模块,里面完全支持 lua 的所有 c API,因此我们也可以将一些第三方的开源 lua native 模块直接引入进来使用。</p>
+<p>这里我们也有一个完整的导入 lua-cjson 模块的例子可以参考:<a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/other/native_module_cjson">native_module_cjson</a></p>
+<p>首先,我们先实现 shared 的 native 代码,所以接口通过 lua API 导出。</p>
+<p>./modules/foo/foo.c</p>
+<pre><code class="lang-c++">#include <xmi.h>
+
+static int c_add(lua_State* lua) {
+    int a = lua_tointeger(lua, 1);
+    int b = lua_tointeger(lua, 2);
+    lua_pushinteger(lua, a + b);
+    return 1;
+}
+
+static int c_sub(lua_State* lua) {
+    int a = lua_tointeger(lua, 1);
+    int b = lua_tointeger(lua, 2);
+    lua_pushinteger(lua, a - b);
+    return 1;
+}
+
+int luaopen(foo, lua_State* lua) {
+    // 收集add和sub
+    static const luaL_Reg funcs[] = {
+        {"add", c_add},
+        {"sub", c_sub},
+        {NULL, NULL}
+    };
+    lua_newtable(lua);
+    // 传递函数列表
+    luaL_setfuncs(lua, funcs, 0);
+    return 1;
+}
+</code></pre>
+<p>注意到这里,我们 include 了一个 <code>xmi.h</code> 的接口头文件,其实我们也可以直接引入 <code>lua.h</code>,<code>luaconf.h</code>,效果是一样的,但是会提供更好的跨平台性,内部会自动处理 lua/luajit还有版本间的差异。</p>
+<p>然后,我们配置 <code>add_rules("modules.shared")</code> 作为 shared native 模块来编译,不需要引入任何其他依赖。</p>
+<p>甚至连 lua 的依赖也不需要引入,因为 xmake 主程序已经对其导出了所有的 lua 接口,可直接使用,所以整个模块是非常轻量的。</p>
+<p>./modules/foo/xmake.lua</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+target("foo")
+    -- 指定目标为库lua模块
+    add_rules("module.shared")
+    add_files("foo.c")
+</code></pre>
+<h4 id="">定义二进制模块</h4>
+<p>出了动态库模块,我们还提供了另外一种二进制模块的导入。它其实就是一个可执行文件,每次调用模块接口,都会去调用一次子进程。</p>
+<p>那它有什么好处呢,尽管它没有动态库模块那么高效,但是它的模块实现更加的简单,不需要调用 lua API,仅仅只需要处理参数数据,通过 stdout 去输出返回值即可。</p>
+<p>另外,相比二进制分发,它是通过源码分发的,因此也解决了跨平台的问题。</p>
+<p>具体是使用动态库模块,还是二进制模块,具体看自己的需求,如果想要实现简单,可以考虑二进制模块,如果想要高效,就用动态库模块。</p>
+<p>另外,如果需要通过并行执行来提速,也可以使用二进制模块。</p>
+<p>./modules/bar/bar.cpp</p>
+<pre><code class="lang-c++">#include <stdio.h>
+#include <stdlib.h>
+#include <cstdlib>
+
+int main(int argc, char** argv) {
+    int a = atoi(argv[1]);
+    int b = atoi(argv[2]);
+    printf("%d", a + b);
+    return 0;
+}
+</code></pre>
+<p>./modules/bar/xmake.lua</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+
+target("add")
+    -- 指定目标为二进制lua模块
+    add_rules("module.binary")
+    add_files("bar.cpp")
+</code></pre>
+<h4 id="">导入原生模块</h4>
+<p>对于模块导入,我们仅仅需要调用 import,跟导入 lua 模块的用法完全一致。</p>
+<p>./xmake.lua</p>
+<pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
+-- 添加./modules目录内原生模块
+add_moduledirs("modules")
+
+target("test")
+    set_kind("phony")
+    on_load(function(target)
+        import("foo", {always_build = true})
+        import("bar")
+        print("foo: 1 + 1 = %s", foo.add(1, 1))
+        print("foo: 1 - 1 = %s", foo.sub(1, 1))
+        print("bar: 1 + 1 = %s", bar.add(1, 1))
+    end)
+</code></pre>
+<p>由于插件模块的构建是跟主工程完全独立的,因此,native 模块只会被构建一次,如果想要触发增量的插件编译,需要配置上 <code>always_build = true</code>,这样,xmake 就会每次检测插件代码是否有改动,如果有改动,会自动增量构建插件。</p>
+<p>首次执行效果如下:</p>
+<pre><code class="lang-bash">ruki-2:native_module ruki$ xmake
+[ 50%]: cache compiling.release src/foo.c
+[ 50%]: cache compiling.release src/bar.c
+[ 75%]: linking.release libmodule_foo.dylib
+[ 75%]: linking.release module_bar
+[100%]: build ok, spent 1.296s
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+</code></pre>
+<p>第二次执行,就不会再构建插件,可以直接使用模块:</p>
+<pre><code class="lang-bash">ruki-2:native_module ruki$ xmake
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+</code></pre>
+<h4 id="codegen">作为 codegen 来使用</h4>
+<p>通过新的 native 模块特性,我们也可以用来实现 auto-codegen,然后根据自动生成的代码,继续执行后续编译流程。</p>
+<p>这里也有完整的例子可以参考:<a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/other/autogen_shared_module">autogen_shared_module</a>。</p>
+</article>
+</body>
+</html>

+ 13 - 0
mirror/zh-cn/manual/project_target.html

@@ -819,6 +819,15 @@ target("test")
     add_files("src/*.md")
     add_files("src/*.markdown")
 </code></pre>
+<p>我们可以在add_rules时传参:</p>
+<pre><code class="lang-lua">rule("my_rule")
+    on_load(function (target)
+        local my_arg = target:extraconf("rules", "my_rule", "my_arg") -- "my arg"
+    end)
+
+target("test")
+    add_rules("my_rule", { my_arg = "my arg"})
+</code></pre>
 <p>我们也可以指定应用局部文件到规则,具体使用见:<a href="#targetadd_files">add_files</a>。</p>
 <h3 id="targeton_load">target:on_load</h3>
 <h4 id="">自定义目标加载脚本</h4>
@@ -1712,6 +1721,10 @@ add_culdflags("-gencode arch=compute_30,code=sm_30")
 <p>添加静态链接选项</p>
 <pre><code class="lang-lua">add_ldflags("-L/xxx", "-lxxx")
 </code></pre>
+<p>在添加链接选项时,默认无法支持参数内有空格,使用expand = false:</p>
+<pre><code class="lang-lua">-- add_ldflags("-L/my lib") ERROR: Invalid arguments
+add_ldflags({"-L/my lib"}, {expand = false}) -- OK
+</code></pre>
 <h3 id="targetadd_arflags">target:add_arflags</h3>
 <h4 id="">添加静态库归档选项</h4>
 <p>影响对静态库的生成</p>

+ 114 - 104
sitemap.xml

@@ -12,522 +12,532 @@
 
 <url>
   <loc>https://xmake.io/mirror/guide/project_examples.html</loc>
-  <lastmod>2024-04-08T16:07:30+08:00</lastmod>
+  <lastmod>2024-04-22T11:51:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2024-04-08T16:07:31+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2024-04-08T16:07:31+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/build_policies.html</loc>
-  <lastmod>2024-04-08T16:07:31+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2024-04-08T16:07:31+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2024-04-08T16:07:31+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2024-04-08T16:07:31+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/remote_build.html</loc>
-  <lastmod>2024-04-08T16:07:32+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/unity_build.html</loc>
-  <lastmod>2024-04-08T16:07:32+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/distcc_build.html</loc>
-  <lastmod>2024-04-08T16:07:32+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/trybuild.html</loc>
-  <lastmod>2024-04-08T16:07:32+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/autogen.html</loc>
-  <lastmod>2024-04-08T16:07:33+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/build_cache.html</loc>
-  <lastmod>2024-04-08T16:07:33+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2024-04-08T16:07:33+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2024-04-08T16:07:33+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2024-04-08T16:07:34+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2024-04-08T16:07:34+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2024-04-08T16:07:34+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2024-04-08T16:07:34+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2024-04-08T16:07:34+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2024-04-08T16:07:35+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2024-04-08T16:07:35+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2024-04-08T16:07:35+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2024-04-08T16:07:35+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2024-04-08T16:07:36+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2024-04-08T16:07:36+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2024-04-08T16:07:36+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/build_policies.html</loc>
-  <lastmod>2024-04-08T16:07:37+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2024-04-08T16:07:37+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2024-04-08T16:07:37+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2024-04-08T16:07:37+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/remote_build.html</loc>
-  <lastmod>2024-04-08T16:07:38+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/unity_build.html</loc>
-  <lastmod>2024-04-08T16:07:38+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/distcc_build.html</loc>
-  <lastmod>2024-04-08T16:07:38+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/trybuild.html</loc>
-  <lastmod>2024-04-08T16:07:38+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/autogen.html</loc>
-  <lastmod>2024-04-08T16:07:39+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/build_cache.html</loc>
-  <lastmod>2024-04-08T16:07:39+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2024-04-08T16:07:39+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2024-04-08T16:07:39+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2024-04-08T16:07:39+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2024-04-08T16:07:40+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2024-04-08T16:07:40+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2024-04-08T16:07:40+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2024-04-08T16:07:40+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2024-04-08T16:07:40+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2024-04-08T16:07:41+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2024-04-08T16:07:41+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2024-04-08T16:07:41+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2024-04-08T16:07:42+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2024-04-08T16:07:42+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2024-04-08T16:07:42+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:09+08:00</lastmod>
+</url>
+
+<url>
+  <loc>https://xmake.io/mirror/zh-cn/manual/native_modules.html</loc>
+  <lastmod>2024-04-22T11:52:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2024-04-08T16:07:42+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2024-04-08T16:07:42+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2024-04-08T16:07:43+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2024-04-08T16:07:43+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2024-04-08T16:07:43+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2024-04-08T16:07:43+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2024-04-08T16:07:43+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2024-04-08T16:07:44+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2024-04-08T16:07:44+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2024-04-08T16:07:44+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2024-04-08T16:07:44+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2024-04-08T16:07:45+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2024-04-08T16:07:45+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2024-04-08T16:07:45+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2024-04-08T16:07:45+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/xpack.html</loc>
-  <lastmod>2024-04-08T16:07:45+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2024-04-08T16:07:46+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2024-04-08T16:07:46+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2024-04-08T16:07:46+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2024-04-08T16:07:46+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2024-04-08T16:07:46+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2024-04-08T16:07:47+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2024-04-08T16:07:47+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2024-04-08T16:07:47+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2024-04-08T16:07:47+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2024-04-08T16:07:47+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2024-04-08T16:07:48+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:14+08:00</lastmod>
+</url>
+
+<url>
+  <loc>https://xmake.io/mirror/manual/native_modules.html</loc>
+  <lastmod>2024-04-22T11:52:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2024-04-08T16:07:48+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2024-04-08T16:07:48+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2024-04-08T16:07:48+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2024-04-08T16:07:48+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2024-04-08T16:07:49+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2024-04-08T16:07:49+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2024-04-08T16:07:49+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2024-04-08T16:07:49+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2024-04-08T16:07:49+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2024-04-08T16:07:50+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2024-04-08T16:07:50+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2024-04-08T16:07:50+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2024-04-08T16:07:50+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2024-04-08T16:07:50+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2024-04-08T16:07:51+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/xpack.html</loc>
-  <lastmod>2024-04-08T16:07:51+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2024-04-08T16:07:51+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2024-04-08T16:07:51+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2024-04-08T16:07:51+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2024-04-08T16:07:52+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2024-04-08T16:07:52+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2024-04-08T16:07:52+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2024-04-08T16:07:52+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2024-04-08T16:07:52+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2024-04-08T16:07:52+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2024-04-08T16:07:53+08:00</lastmod>
+  <lastmod>2024-04-22T11:52:19+08:00</lastmod>
 </url>
 
 </urlset>

+ 14 - 0
zh-cn/guide/configuration.md

@@ -120,6 +120,20 @@ $ xmake f -p wasm --toolchain=wasi
 $ xmake
 ```
 
+### HarmonyOS (鸿蒙)
+
+2.9.1 版本新增了鸿蒙 OS 平台的 native 工具链编译支持:
+
+```bash
+$ xmake f -p harmony
+```
+
+xmake 会自动探测默认的 SDK 路径,当然我们也可以指定 Harmony SDK 路径。
+
+```bash
+$ xmake f -p Harmony --sdk=/Users/ruki/Library/Huawei/Sdk/openharmony/10/native
+```
+
 ## 交叉编译配置
 
 通常,如果我们需要在当前pc环境编译生成其他设备上才能运行的目标文件时候,就需要通过对应的交叉编译工具链来编译生成它们,比如在win/macos上编译linux的程序,或者在linux上编译其他嵌入式设备的目标文件等。

+ 74 - 29
zh-cn/manual/native_modules.md

@@ -3,10 +3,21 @@
 
 ### 原生模块
 
-使用原生模块时,xmake会进行两段编译,先编译原生模块,后将模块导入lua作为库或二进制。
+我们知道,在 xmake 中,可以通过 import 接口去导入一些 lua 模块在脚本域中使用,但是如果一些模块的操作比较耗时,那么 lua 实现并不是理想的选择。
+因此,新版本中,我们新增了 native lua 模块的支持,可以通过 native 实现,来达到提速优化的效果,并且模块导入和使用,还是跟 lua 模块一样简单。
+
+使用原生模块时,xmake 会进行两段编译,先会自动编译原生模块,后将模块导入 lua 作为库或二进制,而对于用户,仅仅只需要调用 import 导入即可。
 
 #### 定义动态库模块
 
+动态库模块的好处是,不仅仅通过 native 实现了性能加速,另外避免了每次调用额外的子进程创建,因此更加的轻量,速度进一步得到提升。
+
+我们可以先定义一个动态库模块,里面完全支持 lua 的所有 c API,因此我们也可以将一些第三方的开源 lua native 模块直接引入进来使用。
+
+这里我们也有一个完整的导入 lua-cjson 模块的例子可以参考:[native_module_cjson](https://github.com/xmake-io/xmake/tree/master/tests/projects/other/native_module_cjson)
+
+首先,我们先实现 shared 的 native 代码,所以接口通过 lua API 导出。
+
 ./modules/foo/foo.c
 
 ```c++
@@ -40,6 +51,12 @@ int luaopen(foo, lua_State* lua) {
 }
 ```
 
+注意到这里,我们 include 了一个 `xmi.h` 的接口头文件,其实我们也可以直接引入 `lua.h`,`luaconf.h`,效果是一样的,但是会提供更好的跨平台性,内部会自动处理 lua/luajit还有版本间的差异。
+
+然后,我们配置 `add_rules("modules.shared")` 作为 shared native 模块来编译,不需要引入任何其他依赖。
+
+甚至连 lua 的依赖也不需要引入,因为 xmake 主程序已经对其导出了所有的 lua 接口,可直接使用,所以整个模块是非常轻量的。
+
 ./modules/foo/xmake.lua
 
 ```lua
@@ -53,6 +70,16 @@ target("foo")
 
 #### 定义二进制模块
 
+出了动态库模块,我们还提供了另外一种二进制模块的导入。它其实就是一个可执行文件,每次调用模块接口,都会去调用一次子进程。
+
+那它有什么好处呢,尽管它没有动态库模块那么高效,但是它的模块实现更加的简单,不需要调用 lua API,仅仅只需要处理参数数据,通过 stdout 去输出返回值即可。
+
+另外,相比二进制分发,它是通过源码分发的,因此也解决了跨平台的问题。
+
+具体是使用动态库模块,还是二进制模块,具体看自己的需求,如果想要实现简单,可以考虑二进制模块,如果想要高效,就用动态库模块。
+
+另外,如果需要通过并行执行来提速,也可以使用二进制模块。
+
 ./modules/bar/bar.cpp
 
 ```c++
@@ -63,13 +90,7 @@ target("foo")
 int main(int argc, char** argv) {
     int a = atoi(argv[1]);
     int b = atoi(argv[2]);
-    printf("%d", 
-#ifdef ADD
-        a + b
-#else
-        a - b
-#endif
-    );
+    printf("%d", a + b);
     return 0;
 }
 ```
@@ -83,15 +104,12 @@ target("add")
     -- 指定目标为二进制lua模块
     add_rules("module.binary")
     add_files("bar.cpp")
-    add_defines("ADD")
-
-target("sub")
-    add_rules("module.binary")
-    add_files("bar.cpp")
 ```
 
 #### 导入原生模块
 
+对于模块导入,我们仅仅需要调用 import,跟导入 lua 模块的用法完全一致。
+
 ./xmake.lua
 
 ```lua
@@ -100,19 +118,46 @@ add_rules("mode.debug", "mode.release")
 add_moduledirs("modules")
 
 target("test")
-set_kind("phony")
-on_load(function(target)
-    local foo = import("foo", {
-        -- 是否每次构建时会尝试构建模块
-        always_build = true
-    })
-    local bar = import("bar", {
-        always_build = true
-    })
-    print("foo: 1 + 1 = %s", foo.add(1, 1))
-    print("foo: 1 - 1 = %s", foo.sub(1, 1))
-    print("bar: 1 + 1 = %s", bar.add(1, 1))
-    print("bar: 1 - 1 = %s", bar.sub(1, 1))
-end)
-
-```
+    set_kind("phony")
+    on_load(function(target)
+        import("foo", {always_build = true})
+        import("bar")
+        print("foo: 1 + 1 = %s", foo.add(1, 1))
+        print("foo: 1 - 1 = %s", foo.sub(1, 1))
+        print("bar: 1 + 1 = %s", bar.add(1, 1))
+    end)
+```
+
+由于插件模块的构建是跟主工程完全独立的,因此,native 模块只会被构建一次,如果想要触发增量的插件编译,需要配置上 `always_build = true`,这样,xmake 就会每次检测插件代码是否有改动,如果有改动,会自动增量构建插件。
+
+首次执行效果如下:
+
+```bash
+ruki-2:native_module ruki$ xmake
+[ 50%]: cache compiling.release src/foo.c
+[ 50%]: cache compiling.release src/bar.c
+[ 75%]: linking.release libmodule_foo.dylib
+[ 75%]: linking.release module_bar
+[100%]: build ok, spent 1.296s
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+```
+
+第二次执行,就不会再构建插件,可以直接使用模块:
+
+```bash
+ruki-2:native_module ruki$ xmake
+foo: 1 + 1 = 2
+foo: 1 - 1 = 0
+bar: 1 + 1 = 2
+[100%]: build ok, spent 0.447s
+```
+
+#### 作为 codegen 来使用
+
+通过新的 native 模块特性,我们也可以用来实现 auto-codegen,然后根据自动生成的代码,继续执行后续编译流程。
+
+这里也有完整的例子可以参考:[autogen_shared_module](https://github.com/xmake-io/xmake/tree/master/tests/projects/other/autogen_shared_module)。
+