Skip to content

Commit aadf1a6

Browse files
committed
update docs
1 parent 1462f57 commit aadf1a6

File tree

5 files changed

+301
-235
lines changed

5 files changed

+301
-235
lines changed

mirror/guide/configuration.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ <h2 id="environmentvariables">Environment variables</h2>
789789
XMAKE_RAMDIR Set the ramdisk directory.
790790
<empty>
791791
XMAKE_GLOBALDIR Set the global config directory of xmake.
792-
/Users/ruki/.xmake
792+
/Users/ruki
793793
XMAKE_ROOT Allow xmake to run under root.
794794
<empty>
795795
XMAKE_COLORTERM Set the color terminal environment.
@@ -833,8 +833,8 @@ <h3 id="xmake_globaldir">XMAKE_GLOBALDIR</h3>
833833
<ul>
834834
<li>Set the root directory of the global configuration file</li>
835835
</ul>
836-
<p>That is, the storage directory of the global configuration of <code>xmake g/global</code>, as well as other global files such as installation packages, caches, etc., will be stored in this directory by default.</p>
837-
<p>The default path is: <code>~/.xmake</code>.</p>
836+
<p>A <code>.xmake</code> directory, which serves as the storage directory of the global configuration of <code>xmake g/global</code> configuration, will be created under this path. Other global files such as installation packages, caches, etc., will be stored in this directory by default.</p>
837+
<p>The default path is: <code>~</code>.</p>
838838
<h3 id="xmake_root">XMAKE_ROOT</h3>
839839
<p>-Allow users to run in root mode</p>
840840
<p>Usually xmake is forbidden to run under root by default, which is very insecure. But if the user has to run under root, he can also set this variable to force it on.</p>
@@ -877,13 +877,13 @@ <h3 id="xmake_pkg_installdir">XMAKE_PKG_INSTALLDIR</h3>
877877
<ul>
878878
<li>Set the installation root directory of the dependent package</li>
879879
</ul>
880-
<p>The default global directory for xmake&#39;s remote package installation is <code>~/.xmake/packages</code>, but users can also set this variable to modify it individually.</p>
881-
<p>We can also use <code>xmake g --pkg_installdir=/xxx</code> to set it, the effect is the same.</p>
880+
<p>The default global directory for xmake&#39;s remote package installation is <code>$XMAKE_GLOBALDIR/.xmake/packages</code>, but users can also set this variable to modify it individually.</p>
881+
<p>We can also use <code>xmake g --pkg_installdir=/xxx</code> to set it, the effect is the same. However, the environment variable takes precedence over this configuration.</p>
882882
<h3 id="xmake_pkg_cachedir">XMAKE_PKG_CACHEDIR</h3>
883883
<ul>
884884
<li>Set the cache directory of dependent packages</li>
885885
</ul>
886-
<p>The default path is in the <code>~/.xmake/cache</code> directory, which stores various cache files during the package installation process, which takes up more storage space, and the user can also set it separately.</p>
886+
<p>The default path is in the <code>$XMAKE_GLOBALDIR/.xmake/cache</code> directory, which stores various cache files during the package installation process, which takes up more storage space, and the user can also set it separately.</p>
887887
<p>Of course, Xmake will automatically clean up all cache files of the previous month every month.</p>
888888
<h3 id="xmake_program_dir">XMAKE_PROGRAM_DIR</h3>
889889
<ul>
@@ -991,7 +991,7 @@ <h3 id="xmake_rcfiles">XMAKE_RCFILES</h3>
991991
<pre><code class="lang-console">$ export XMAKE_RCFILES=xmakerc.lua
992992
$ xmake
993993
</code></pre>
994-
<p>If not set, the default path is: <code>~/.xmake/xmakerc.lua</code>.</p>
994+
<p>If this environment variable is not set, users can set the global configuration file in <code>/etc/xmakerc.lua</code>, <code>~/xmakerc.lua</code>, and <code>$XMAKE_GLOBALDIR/.xmake/xmakerc.lua</code>. The search priority is listed from highest to lowest.</p>
995995
<h3 id="xmake_logfile">XMAKE_LOGFILE</h3>
996996
<ul>
997997
<li>Set the log file path</li>

mirror/package/local_package.html

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,97 @@ <h4 id="specifythesearchmode">Specify the search mode</h4>
260260
<p>xmake will automatically append the following configuration internally when it looks for cmake packages.</p>
261261
<pre><code class="lang-cmake">find_package(ABC CONFIG REQUIRED)
262262
</code></pre>
263+
<h4 id="stepbysteplocalpackagingtutorial">Step by Step Local Packaging Tutorial</h4>
264+
<p>In this tutorial we will package a static library called foo, upload it to a GitHub repository and consume it similar to a manner of CMake FetchContent</p>
265+
<ul>
266+
<li>Create an xmake project</li>
267+
</ul>
268+
<pre><code class="lang-bash">$ xmake create -P package_origin
269+
</code></pre>
270+
<ul>
271+
<li>Imitate this filetree to prepare files for your package</li>
272+
</ul>
273+
<pre><code class="lang-bash">│ .gitignore
274+
│ xmake.lua
275+
└───src
276+
│ main.cpp
277+
├───inc
278+
│ └───foo
279+
│ foo.hpp
280+
└───lib
281+
└───foo
282+
foo.cpp
283+
</code></pre>
284+
<ul>
285+
<li>Create static library target in xmake</li>
286+
</ul>
287+
<pre><code class="lang-lua">target("foo")
288+
set_kind("static")
289+
add_files("src/lib/foo/*.cpp")
290+
add_headerfiles("src/inc/foo/*.hpp")
291+
add_includedirs("src/inc/foo", {public = true})
292+
</code></pre>
293+
<ul>
294+
<li>Implement the functionality of your target</li>
295+
</ul>
296+
<p>foo.hpp</p>
297+
<pre><code class="lang-cpp">void foo();
298+
</code></pre>
299+
<p>foo.cpp</p>
300+
<pre><code class="lang-cpp">#include <iostream>
301+
#include "foo.hpp"
302+
303+
void foo() {
304+
std::cout << "foo";
305+
}
306+
</code></pre>
307+
<ul>
308+
<li>Build your project and create the package</li>
309+
</ul>
310+
<pre><code class="lang-bash">$ xmake build
311+
$ xmake package foo
312+
</code></pre>
313+
<ul>
314+
<li>Move packages artifacts to a custom package repository.</li>
315+
</ul>
316+
<pre><code class="lang-bash">$ mkdir xmake_local_package_tutorial
317+
$ cp -r build/packages xmake_local_package_tutorial/packages
318+
$ cd xmake_local_package_tutorial
319+
$ git init
320+
$ git add .
321+
$ git commit -a -m "init"
322+
</code></pre>
323+
<p>Then push this new package repository to your custom repository, e.g. <code>https://github.com/xxx/xmake_local_package_tutorial.git</code></p>
324+
<ul>
325+
<li>Create a project where you intend on consuming the package</li>
326+
</ul>
327+
<pre><code class="lang-bash">$ xmake create package_consumption
328+
</code></pre>
329+
<ul>
330+
<li>Consume the package by adding the repository, finding the package and then linking the package to target of your choosing</li>
331+
</ul>
332+
<pre><code class="lang-lua">add_repositories("foo https://github.com/xxx/xmake_local_package_tutorial.git")
333+
add_requires("foo")
334+
335+
target("package_consumption")
336+
set_kind("binary")
337+
add_files("src/*.cpp")
338+
add_packages("foo")
339+
</code></pre>
340+
<p>you can also use local repository.</p>
341+
<pre><code class="lang-lua">add_repositories("foo /localpath/xmake_local_package_tutorial")
342+
</code></pre>
343+
<pre><code class="lang-cpp">#include "foo.hpp"
344+
int main() {
345+
foo();
346+
return 0;
347+
}
348+
</code></pre>
349+
<p>Congratulations, you have packaged a library and consumed it xmake!</p>
350+
<pre><code class="lang-bash">$ xmake build
351+
$ xmake run
352+
foo
353+
</code></pre>
263354
</article>
264355
</body>
265356
</html>

mirror/zh-cn/guide/configuration.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ <h2 id="">环境变量</h2>
797797
XMAKE_RAMDIR Set the ramdisk directory.
798798
<empty>
799799
XMAKE_GLOBALDIR Set the global config directory of xmake.
800-
/Users/ruki/.xmake
800+
/Users/ruki
801801
XMAKE_ROOT Allow xmake to run under root.
802802
<empty>
803803
XMAKE_COLORTERM Set the color terminal environment.
@@ -841,8 +841,8 @@ <h3 id="xmake_globaldir">XMAKE_GLOBALDIR</h3>
841841
<ul>
842842
<li>设置全局配置文件根目录</li>
843843
</ul>
844-
<p>也就是 <code>xmake g/global</code> 全局配置的存储目录,还有安装包,缓存等其他全局文件,默认都会存储在这个目录下。</p>
845-
<p>默认路径为:<code>~/.xmake</code></p>
844+
<p>xmake将在该目录下创建 <code>.xmake</code>,作为 <code>xmake g/global</code> 全局配置的存储目录,还有安装包,缓存等其他全局文件,默认都会存储在这个目录下。</p>
845+
<p>默认路径为:<code>~</code></p>
846846
<h3 id="xmake_root">XMAKE_ROOT</h3>
847847
<ul>
848848
<li>允许用户在 root 模式下运行</li>
@@ -887,13 +887,13 @@ <h3 id="xmake_pkg_installdir">XMAKE_PKG_INSTALLDIR</h3>
887887
<ul>
888888
<li>设置依赖包的安装根目录</li>
889889
</ul>
890-
<p>xmake 的远程包安装的全局目录默认是 <code>~/.xmake/packages</code>,但是用户也可以设置这个变量,去单独修改它。</p>
891-
<p>我们也可以使用 <code>xmake g --pkg_installdir=/xxx</code> 去设置它,效果是一样的。</p>
890+
<p>xmake 的远程包安装的全局目录默认是 <code>$XMAKE_GLOBALDIR/.xmake/packages</code>,但是用户也可以设置这个变量,去单独修改它。</p>
891+
<p>我们也可以使用 <code>xmake g --pkg_installdir=/xxx</code> 去设置它,效果是一样的。但环境变量的优先级高于此配置。</p>
892892
<h3 id="xmake_pkg_cachedir">XMAKE_PKG_CACHEDIR</h3>
893893
<ul>
894894
<li>设置依赖包的缓存目录</li>
895895
</ul>
896-
<p>默认路径在 <code>~/.xmake/cache</code> 目录,存储包安装过程中的各种缓存文件,比较占存储空间,用户也可以单独设置它。</p>
896+
<p>默认路径在 <code>$XMAKE_GLOBALDIR/.xmake/cache</code> 目录,存储包安装过程中的各种缓存文件,比较占存储空间,用户也可以单独设置它。</p>
897897
<p>当然,xmake 在每个月都会自动清理上个月的所有缓存文件。</p>
898898
<h3 id="xmake_program_dir">XMAKE_PROGRAM_DIR</h3>
899899
<ul>
@@ -1001,7 +1001,7 @@ <h3 id="xmake_rcfiles">XMAKE_RCFILES</h3>
10011001
<pre><code class="lang-bash">$ export XMAKE_RCFILES=xmakerc.lua
10021002
$ xmake
10031003
</code></pre>
1004-
<p>如果不设置,默认路径为:<code>~/.xmake/xmakerc.lua</code></p>
1004+
<p>如果不设置此环境变量,用户可以在<code>/etc/xmakerc.lua</code><code>~/xmakerc.lua</code><code>$XMAKE_GLOBALDIR/.xmake/xmakerc.lua</code>设置全局配置文件,搜索优先级从高至低排列</p>
10051005
<h3 id="xmake_logfile">XMAKE_LOGFILE</h3>
10061006
<ul>
10071007
<li>设置日志文件路径</li>

0 commit comments

Comments
 (0)