ruki 4 vuotta sitten
vanhempi
sitoutus
cd080f3a69

+ 47 - 0
manual/builtin_modules.md

@@ -128,6 +128,53 @@ Version 2.1.5 adds two new properties: `import("xxx.xxx", {try = true, anonymous
 If the try is true, the imported module does not exist, only return nil, and will not interrupt xmake after throwing an exception.
 If anonymous is true, the imported module will not introduce the current scope, only the imported object reference will be returned in the import interface.
 
+#### Custom extension module
+
+Through import, we can import not only many built-in extension modules of xmake, but also user-defined extension modules.
+
+Just put your own module in the project directory and import it according to the import method described above.
+
+So, what if you want to define a module? xmake has a set of convention rules for module writing specifications, and does not follow Lua's native require import mechanism, and there is no need to use return in the module to return it globally.
+
+If we have a module file foo.lua, its content is as follows:
+
+```lua
+function _foo(a, b)
+    return a + b
+end
+
+function add(a, b)
+    _foo(a, b)
+end
+
+function main(a, b)
+    add(a, b)
+end
+```
+
+Among them main is the entry function, optional, if set, the module foo can be called directly, for example:
+
+```lua
+import("foo")
+foo(1, 2)
+```
+
+Or directly like this:
+
+```lua
+import("foo")(1, 2)
+```
+
+
+Others without underscore are public module interface functions, such as add.
+
+```lua
+import("foo")
+foo.add(1, 2)
+```
+
+The underscore prefixed `_foo` is a private function that is used internally by the module and is not exported, so users cannot call it outside.
+
 ### inherit
 
 #### Import and inherit base class modules

+ 29 - 0
mirror/manual/builtin_modules.html

@@ -179,6 +179,35 @@ end
 <p>This is not a reference to the module, but all the public interfaces of the module imported, so that it will be merged with the interface of the current module to achieve inheritance between modules.</p>
 <p>Version 2.1.5 adds two new properties: `import("xxx.xxx", {try = true, anonymous = true}).</p>
 <p>If the try is true, the imported module does not exist, only return nil, and will not interrupt xmake after throwing an exception.<br>If anonymous is true, the imported module will not introduce the current scope, only the imported object reference will be returned in the import interface.</p>
+<h4 id="customextensionmodule">Custom extension module</h4>
+<p>Through import, we can import not only many built-in extension modules of xmake, but also user-defined extension modules.</p>
+<p>Just put your own module in the project directory and import it according to the import method described above.</p>
+<p>So, what if you want to define a module? xmake has a set of convention rules for module writing specifications, and does not follow Lua&#39;s native require import mechanism, and there is no need to use return in the module to return it globally.</p>
+<p>If we have a module file foo.lua, its content is as follows:</p>
+<pre><code class="lang-lua">function _foo(a, b)
+    return a + b
+end
+
+function add(a, b)
+    _foo(a, b)
+end
+
+function main(a, b)
+    add(a, b)
+end
+</code></pre>
+<p>Among them main is the entry function, optional, if set, the module foo can be called directly, for example:</p>
+<pre><code class="lang-lua">import("foo")
+foo(1, 2)
+</code></pre>
+<p>Or directly like this:</p>
+<pre><code class="lang-lua">import("foo")(1, 2)
+</code></pre>
+<p>Others without underscore are public module interface functions, such as add.</p>
+<pre><code class="lang-lua">import("foo")
+foo.add(1, 2)
+</code></pre>
+<p>The underscore prefixed <code>_foo</code> is a private function that is used internally by the module and is not exported, so users cannot call it outside.</p>
 <h3 id="inherit">inherit</h3>
 <h4 id="importandinheritbaseclassmodules">Import and inherit base class modules</h4>
 <p>This is equivalent to the <code>inherit</code> mode of the <a href="#import">import</a> interface, which is:</p>

+ 29 - 0
mirror/zh-cn/manual/builtin_modules.html

@@ -178,6 +178,35 @@ end
 <p>这样导入的不是这个模块的引用,而是导入的这个模块的所有公有接口本身,这样就会跟当前模块的接口进行合并,实现模块间的继承。</p>
 <p>2.1.5版本新增两个新属性:<code>import("xxx.xxx", {try = true, anonymous = true})</code></p>
 <p>try为true,则导入的模块不存在的话,仅仅返回nil,并不会抛异常后中断xmake.<br>anonymous为true,则导入的模块不会引入当前作用域,仅仅在import接口返回导入的对象引用。</p>
+<h4 id="">自定义扩展模块</h4>
+<p>通过 import 我们除了可以导入 xmake 内置的很多扩展模块,还可以导入用户自己定义的扩展模块。</p>
+<p>只需要将自己的模块放到工程目录下,按照上文介绍的导入方式进行导入即可。</p>
+<p>那么,如果去定义模块呢?xmake 对模块的编写规范是有一套约定规则的,并没有沿用 lua 原生的 require 导入机制,并不需要在模块中使用 return 来全局返回它。</p>
+<p>假如我们有一个模块文件 foo.lua,它的内容如下:</p>
+<pre><code class="lang-lua">function _foo(a, b)
+    return a + b
+end
+
+function add(a, b)
+    _foo(a, b)
+end
+
+function main(a, b)
+    add(a, b)
+end
+</code></pre>
+<p>其中 main 为入口函数,可选,如果设置,模块 foo 可以直接被调用,例如:</p>
+<pre><code class="lang-lua">import("foo")
+foo(1, 2)
+</code></pre>
+<p>或者直接这样:</p>
+<pre><code class="lang-lua">import("foo")(1, 2)
+</code></pre>
+<p>其他不带下划线的为 public 模块接口函数,例如 add。</p>
+<pre><code class="lang-lua">import("foo")
+foo.add(1, 2)
+</code></pre>
+<p>而里面带下划线前缀的 _foo 是私有函数,模块内部使用,不对外导出,所以在外面用户是不能够调用它的。</p>
 <h3 id="inherit">inherit</h3>
 <h4 id="">导入并继承基类模块</h4>
 <p>这个等价于<a href="#import">import</a>接口的<code>inherit</code>模式,也就是:</p>

+ 90 - 90
sitemap.xml

@@ -12,452 +12,452 @@
 
 <url>
   <loc>https://xmake.io/mirror/guide/project_examples.html</loc>
-  <lastmod>2021-11-09T21:23:21+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/other_features.html</loc>
-  <lastmod>2021-11-09T21:23:21+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2021-11-09T21:23:21+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2021-11-09T21:23:22+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2021-11-09T21:23:22+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2021-11-09T21:23:22+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2021-11-09T21:23:22+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2021-11-09T21:23:22+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2021-11-09T21:23:22+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-11-09T21:23:23+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2021-11-09T21:23:23+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2021-11-09T21:23:23+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2021-11-09T21:23:23+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2021-11-09T21:23:23+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2021-11-09T21:23:23+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-11-09T21:23:24+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2021-11-09T21:23:24+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2021-11-09T21:23:24+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/other_features.html</loc>
-  <lastmod>2021-11-09T21:23:24+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2021-11-09T21:23:24+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2021-11-09T21:23:24+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2021-11-09T21:23:25+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2021-11-09T21:23:25+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2021-11-09T21:23:25+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2021-11-09T21:23:25+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2021-11-09T21:23:25+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-11-09T21:23:26+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2021-11-09T21:23:26+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2021-11-09T21:23:26+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2021-11-09T21:23:26+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2021-11-09T21:23:26+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2021-11-09T21:23:27+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2021-11-09T21:23:27+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-11-09T21:23:27+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2021-11-09T21:23:27+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2021-11-09T21:23:27+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2021-11-09T21:23:27+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2021-11-09T21:23:28+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2021-11-09T21:23:28+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2021-11-09T21:23:28+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2021-11-09T21:23:28+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2021-11-09T21:23:28+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2021-11-09T21:23:29+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2021-11-09T21:23:29+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2021-11-09T21:23:29+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2021-11-09T21:23:29+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2021-11-09T21:23:29+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2021-11-09T21:23:30+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2021-11-09T21:23:30+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2021-11-09T21:23:30+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2021-11-09T21:23:30+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2021-11-09T21:23:30+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2021-11-09T21:23:30+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2021-11-09T21:23:31+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2021-11-09T21:23:31+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2021-11-09T21:23:31+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-11-09T21:23:31+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2021-11-09T21:23:31+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2021-11-09T21:23:32+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2021-11-09T21:23:32+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2021-11-09T21:23:32+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-11-09T21:23:32+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-11-09T21:23:32+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2021-11-09T21:23:32+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2021-11-09T21:23:33+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2021-11-09T21:23:33+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2021-11-09T21:23:33+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2021-11-09T21:23:33+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2021-11-09T21:23:33+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2021-11-09T21:23:34+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2021-11-09T21:23:34+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2021-11-09T21:23:34+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2021-11-09T21:23:34+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2021-11-09T21:23:34+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2021-11-09T21:23:34+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2021-11-09T21:23:35+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2021-11-09T21:23:35+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2021-11-09T21:23:35+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2021-11-09T21:23:35+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2021-11-09T21:23:35+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2021-11-09T21:23:36+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2021-11-09T21:23:36+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2021-11-09T21:23:36+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-11-09T21:23:36+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2021-11-09T21:23:36+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2021-11-09T21:23:36+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2021-11-09T21:23:37+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2021-11-09T21:23:37+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-11-09T21:23:37+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-11-09T21:23:37+08:00</lastmod>
+  <lastmod>2021-11-13T14:43:24+08:00</lastmod>
 </url>
 
 </urlset>

+ 47 - 0
zh-cn/manual/builtin_modules.md

@@ -126,6 +126,53 @@ import("xxx.xxx", {inherit = true})
 try为true,则导入的模块不存在的话,仅仅返回nil,并不会抛异常后中断xmake.
 anonymous为true,则导入的模块不会引入当前作用域,仅仅在import接口返回导入的对象引用。
 
+#### 自定义扩展模块
+
+通过 import 我们除了可以导入 xmake 内置的很多扩展模块,还可以导入用户自己定义的扩展模块。
+
+只需要将自己的模块放到工程目录下,按照上文介绍的导入方式进行导入即可。
+
+那么,如果去定义模块呢?xmake 对模块的编写规范是有一套约定规则的,并没有沿用 lua 原生的 require 导入机制,并不需要在模块中使用 return 来全局返回它。
+
+假如我们有一个模块文件 foo.lua,它的内容如下:
+
+```lua
+function _foo(a, b)
+    return a + b
+end
+
+function add(a, b)
+    _foo(a, b)
+end
+
+function main(a, b)
+    add(a, b)
+end
+```
+
+其中 main 为入口函数,可选,如果设置,模块 foo 可以直接被调用,例如:
+
+```lua
+import("foo")
+foo(1, 2)
+```
+
+或者直接这样:
+
+```lua
+import("foo")(1, 2)
+```
+
+
+其他不带下划线的为 public 模块接口函数,例如 add。
+
+```lua
+import("foo")
+foo.add(1, 2)
+```
+
+而里面带下划线前缀的 `_foo` 是私有函数,模块内部使用,不对外导出,所以在外面用户是不能够调用它的。
+
 ### inherit
 
 #### 导入并继承基类模块