|
|
@@ -96,10 +96,10 @@
|
|
|
<h2 id="installation">Installation</h2>
|
|
|
<h4 id="master">Master</h4>
|
|
|
<h4 id="via-curl">via curl</h4>
|
|
|
-<pre><code class="lang-bash">bash <(curl -fsSL https://xmake.io/shget.text)
|
|
|
+<pre><code class="lang-bash">bash <(curl -fsSL https://xmake.io/shget.text)
|
|
|
</code></pre>
|
|
|
<h4 id="via-wget">via wget</h4>
|
|
|
-<pre><code class="lang-bash">bash <(wget https://xmake.io/shget.text -O -)
|
|
|
+<pre><code class="lang-bash">bash <(wget https://xmake.io/shget.text -O -)
|
|
|
</code></pre>
|
|
|
<h4 id="via-powershell">via powershell</h4>
|
|
|
<pre><code class="lang-powershell">Invoke-Expression (Invoke-Webrequest 'https://xmake.io/psget.text' -UseBasicParsing).Content
|
|
|
@@ -179,9 +179,9 @@ $ xmake update dev
|
|
|
└── xmake.lua
|
|
|
</code></pre><p>It is a simple console program only for printing <code>hello xmake!</code></p>
|
|
|
<p>The content of <code>xmake.lua</code> is very simple:</p>
|
|
|
-<pre><code class="lang-lua">target("hello")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
+<pre><code class="lang-lua">target("hello")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
</code></pre>
|
|
|
<p>Support languages:</p>
|
|
|
<ul>
|
|
|
@@ -194,7 +194,7 @@ $ xmake update dev
|
|
|
<li>golang</li>
|
|
|
<li>rust</li>
|
|
|
</ul>
|
|
|
-<p><p class="tip"><br> If you want to known more options, please run: <code>xmake create --help</code><br></p>
|
|
|
+<p><p class="tip"><br> If you want to known more options, please run: <code>xmake create --help</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h4 id="build-project">Build Project</h4>
|
|
|
@@ -207,7 +207,7 @@ $ xmake update dev
|
|
|
<pre><code class="lang-bash">$ xmake run -d hello
|
|
|
</code></pre>
|
|
|
<p>It will start the debugger (.e.g lldb, gdb, windbg, vsjitdebugger, ollydbg ..) to load our program.</p>
|
|
|
-<pre><code class="lang-bash">[lldb]$target create "build/hello"
|
|
|
+<pre><code class="lang-bash">[lldb]$target create "build/hello"
|
|
|
Current executable set to 'build/hello' (x86_64).
|
|
|
[lldb]$b main
|
|
|
Breakpoint 1: where = hello`main, address = 0x0000000100000f50
|
|
|
@@ -217,41 +217,41 @@ Process 7509 stopped
|
|
|
* thread #1: tid = 0x435a2, 0x0000000100000f50 hello`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
|
|
|
frame #0: 0x0000000100000f50 hello`main
|
|
|
hello`main:
|
|
|
--> 0x100000f50 <+0>: pushq %rbp
|
|
|
- 0x100000f51 <+1>: movq %rsp, %rbp
|
|
|
- 0x100000f54 <+4>: leaq 0x2b(%rip), %rdi ; "hello world!"
|
|
|
- 0x100000f5b <+11>: callq 0x100000f64 ; symbol stub for: puts
|
|
|
+-> 0x100000f50 <+0>: pushq %rbp
|
|
|
+ 0x100000f51 <+1>: movq %rsp, %rbp
|
|
|
+ 0x100000f54 <+4>: leaq 0x2b(%rip), %rdi ; "hello world!"
|
|
|
+ 0x100000f5b <+11>: callq 0x100000f64 ; symbol stub for: puts
|
|
|
[lldb]$
|
|
|
</code></pre>
|
|
|
-<p><p class="tip"><br> You can also use short command option, for exmaple: <code>xmake r</code> or <code>xmake run</code><br></p>
|
|
|
+<p><p class="tip"><br> You can also use short command option, for exmaple: <code>xmake r</code> or <code>xmake run</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h2 id="project-examples">Project Examples</h2>
|
|
|
<h4 id="executable-program">Executable Program</h4>
|
|
|
-<pre><code class="lang-lua">target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*c")
|
|
|
+<pre><code class="lang-lua">target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*c")
|
|
|
</code></pre>
|
|
|
<h4 id="static-library-program">Static Library Program</h4>
|
|
|
-<pre><code class="lang-lua">target("library")
|
|
|
- set_kind("static")
|
|
|
- add_files("src/library/*.c")
|
|
|
+<pre><code class="lang-lua">target("library")
|
|
|
+ set_kind("static")
|
|
|
+ add_files("src/library/*.c")
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*c")
|
|
|
- add_deps("library")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*c")
|
|
|
+ add_deps("library")
|
|
|
</code></pre>
|
|
|
<p>We use <code>add_deps</code> to link a static library to test target.</p>
|
|
|
<h4 id="share-library-program">Share Library Program</h4>
|
|
|
-<pre><code class="lang-lua">target("library")
|
|
|
- set_kind("shared")
|
|
|
- add_files("src/library/*.c")
|
|
|
+<pre><code class="lang-lua">target("library")
|
|
|
+ set_kind("shared")
|
|
|
+ add_files("src/library/*.c")
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*c")
|
|
|
- add_deps("library")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*c")
|
|
|
+ add_deps("library")
|
|
|
</code></pre>
|
|
|
<p>We use <code>add_deps</code> to link a share library to test target.</p>
|
|
|
<h4 id="qt-program">Qt Program</h4>
|
|
|
@@ -269,36 +269,36 @@ $ xmake create -l c++ -t quickapp_qt test
|
|
|
</code></pre>
|
|
|
<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/160">#160</a>.</p>
|
|
|
<h5 id="static-library">Static Library</h5>
|
|
|
-<pre><code class="lang-lua">target("qt_static_library")
|
|
|
- add_rules("qt.static")
|
|
|
- add_files("src/*.cpp")
|
|
|
- add_frameworks("QtNetwork", "QtGui")
|
|
|
+<pre><code class="lang-lua">target("qt_static_library")
|
|
|
+ add_rules("qt.static")
|
|
|
+ add_files("src/*.cpp")
|
|
|
+ add_frameworks("QtNetwork", "QtGui")
|
|
|
</code></pre>
|
|
|
<h5 id="shared-library">Shared Library</h5>
|
|
|
-<pre><code class="lang-lua">target("qt_shared_library")
|
|
|
- add_rules("qt.shared")
|
|
|
- add_files("src/*.cpp")
|
|
|
- add_frameworks("QtNetwork", "QtGui")
|
|
|
+<pre><code class="lang-lua">target("qt_shared_library")
|
|
|
+ add_rules("qt.shared")
|
|
|
+ add_files("src/*.cpp")
|
|
|
+ add_frameworks("QtNetwork", "QtGui")
|
|
|
</code></pre>
|
|
|
<h5 id="console-program">Console Program</h5>
|
|
|
-<pre><code class="lang-lua">target("qt_console")
|
|
|
- add_rules("qt.console")
|
|
|
- add_files("src/*.cpp")
|
|
|
+<pre><code class="lang-lua">target("qt_console")
|
|
|
+ add_rules("qt.console")
|
|
|
+ add_files("src/*.cpp")
|
|
|
</code></pre>
|
|
|
<h5 id="quick-application">Quick Application</h5>
|
|
|
-<pre><code class="lang-lua">target("qt_quickapp")
|
|
|
- add_rules("qt.application")
|
|
|
- add_files("src/*.cpp")
|
|
|
- add_files("src/qml.qrc")
|
|
|
- add_frameworks("QtQuick")
|
|
|
+<pre><code class="lang-lua">target("qt_quickapp")
|
|
|
+ add_rules("qt.application")
|
|
|
+ add_files("src/*.cpp")
|
|
|
+ add_files("src/qml.qrc")
|
|
|
+ add_frameworks("QtQuick")
|
|
|
</code></pre>
|
|
|
<h5 id="widgets-application">Widgets Application</h5>
|
|
|
-<pre><code class="lang-lua">target("qt_widgetapp")
|
|
|
- add_rules("qt.application")
|
|
|
- add_files("src/*.cpp")
|
|
|
- add_files("src/mainwindow.ui")
|
|
|
- add_files("src/mainwindow.h") -- add files with Q_OBJECT meta (only for qt.moc)
|
|
|
- add_frameworks("QtWidgets")
|
|
|
+<pre><code class="lang-lua">target("qt_widgetapp")
|
|
|
+ add_rules("qt.application")
|
|
|
+ add_files("src/*.cpp")
|
|
|
+ add_files("src/mainwindow.ui")
|
|
|
+ add_files("src/mainwindow.h") -- add files with Q_OBJECT meta (only for qt.moc)
|
|
|
+ add_frameworks("QtWidgets")
|
|
|
</code></pre>
|
|
|
<h5 id="android-application">Android Application</h5>
|
|
|
<p>After the 2.2.6 version, you can directly switch to the android platform to compile the Quick/Widgets application, generate the apk package, and install it to the device via the <code>xmake install</code> command.</p>
|
|
|
@@ -325,15 +325,15 @@ $ cd test
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
<pre><code class="lang-lua">-- define target
|
|
|
-target("cuda_console")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.cu")
|
|
|
+target("cuda_console")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.cu")
|
|
|
-- generate SASS code for SM architecture of current host
|
|
|
- add_cugencodes("native")
|
|
|
+ add_cugencodes("native")
|
|
|
-- generate PTX code for the virtual architecture to guarantee compatibility
|
|
|
- add_cugencodes("compute_30")
|
|
|
+ add_cugencodes("compute_30")
|
|
|
</code></pre>
|
|
|
-<p><p class="tip"><br>Starting with v2.2.7, the default build will enable device-link. (see <a href="https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/">Separate Compilation and Linking of CUDA C++ Device Code</a>)<br>If you want to disable device-link, you can set it with <code>add_values("cuda.devlink", false)</code>.<br></p>
|
|
|
+<p><p class="tip"><br>Starting with v2.2.7, the default build will enable device-link. (see <a href="https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/">Separate Compilation and Linking of CUDA C++ Device Code</a>)<br>If you want to disable device-link, you can set it with <code>add_values("cuda.devlink", false)</code>.<br></p>
|
|
|
|
|
|
</p>
|
|
|
<p>xmake will detect Cuda SDK automatically and we can also set the SDK directory manually.</p>
|
|
|
@@ -343,49 +343,49 @@ $ xmake
|
|
|
<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/158">#158</a>.</p>
|
|
|
<h4 id="wdk-driver-program">WDK Driver Program</h4>
|
|
|
<p>xmake will detect WDK automatically and we can also set the WDK directory manually.</p>
|
|
|
-<pre><code class="lang-console">$ xmake f --wdk="G:\Program Files\Windows Kits\10" -c
|
|
|
+<pre><code class="lang-console">$ xmake f --wdk="G:\Program Files\Windows Kits\10" -c
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/159">#159</a>.</p>
|
|
|
<h5 id="umdf-driver-program">UMDF Driver Program</h5>
|
|
|
-<pre><code class="lang-lua">target("echo")
|
|
|
- add_rules("wdk.driver", "wdk.env.umdf")
|
|
|
- add_files("driver/*.c")
|
|
|
- add_files("driver/*.inx")
|
|
|
- add_includedirs("exe")
|
|
|
+<pre><code class="lang-lua">target("echo")
|
|
|
+ add_rules("wdk.driver", "wdk.env.umdf")
|
|
|
+ add_files("driver/*.c")
|
|
|
+ add_files("driver/*.inx")
|
|
|
+ add_includedirs("exe")
|
|
|
|
|
|
-target("app")
|
|
|
- add_rules("wdk.binary", "wdk.env.umdf")
|
|
|
- add_files("exe/*.cpp")
|
|
|
+target("app")
|
|
|
+ add_rules("wdk.binary", "wdk.env.umdf")
|
|
|
+ add_files("exe/*.cpp")
|
|
|
</code></pre>
|
|
|
<h5 id="kmdf-driver-program">KMDF Driver Program</h5>
|
|
|
-<pre><code class="lang-lua">target("nonpnp")
|
|
|
- add_rules("wdk.driver", "wdk.env.kmdf")
|
|
|
- add_values("wdk.tracewpp.flags", "-func:TraceEvents(LEVEL,FLAGS,MSG,...)", "-func:Hexdump((LEVEL,FLAGS,MSG,...))")
|
|
|
- add_files("driver/*.c", {rule = "wdk.tracewpp"})
|
|
|
- add_files("driver/*.rc")
|
|
|
+<pre><code class="lang-lua">target("nonpnp")
|
|
|
+ add_rules("wdk.driver", "wdk.env.kmdf")
|
|
|
+ add_values("wdk.tracewpp.flags", "-func:TraceEvents(LEVEL,FLAGS,MSG,...)", "-func:Hexdump((LEVEL,FLAGS,MSG,...))")
|
|
|
+ add_files("driver/*.c", {rule = "wdk.tracewpp"})
|
|
|
+ add_files("driver/*.rc")
|
|
|
|
|
|
-target("app")
|
|
|
- add_rules("wdk.binary", "wdk.env.kmdf")
|
|
|
- add_files("exe/*.c")
|
|
|
- add_files("exe/*.inf")
|
|
|
+target("app")
|
|
|
+ add_rules("wdk.binary", "wdk.env.kmdf")
|
|
|
+ add_files("exe/*.c")
|
|
|
+ add_files("exe/*.inf")
|
|
|
</code></pre>
|
|
|
<h5 id="wdm-driver-program">WDM Driver Program</h5>
|
|
|
-<pre><code class="lang-lua">target("kcs")
|
|
|
- add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
- add_values("wdk.man.flags", "-prefix Kcs")
|
|
|
- add_values("wdk.man.resource", "kcsCounters.rc")
|
|
|
- add_values("wdk.man.header", "kcsCounters.h")
|
|
|
- add_values("wdk.man.counter_header", "kcsCounters_counters.h")
|
|
|
- add_files("*.c", "*.rc", "*.man")
|
|
|
-</code></pre>
|
|
|
-<pre><code class="lang-lua">target("msdsm")
|
|
|
- add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
- add_values("wdk.tracewpp.flags", "-func:TracePrint((LEVEL,FLAGS,MSG,...))")
|
|
|
- add_files("*.c", {rule = "wdk.tracewpp"})
|
|
|
- add_files("*.rc", "*.inf")
|
|
|
- add_files("*.mof|msdsm.mof")
|
|
|
- add_files("msdsm.mof", {values = {wdk_mof_header = "msdsmwmi.h"}})
|
|
|
+<pre><code class="lang-lua">target("kcs")
|
|
|
+ add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
+ add_values("wdk.man.flags", "-prefix Kcs")
|
|
|
+ add_values("wdk.man.resource", "kcsCounters.rc")
|
|
|
+ add_values("wdk.man.header", "kcsCounters.h")
|
|
|
+ add_values("wdk.man.counter_header", "kcsCounters_counters.h")
|
|
|
+ add_files("*.c", "*.rc", "*.man")
|
|
|
+</code></pre>
|
|
|
+<pre><code class="lang-lua">target("msdsm")
|
|
|
+ add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
+ add_values("wdk.tracewpp.flags", "-func:TracePrint((LEVEL,FLAGS,MSG,...))")
|
|
|
+ add_files("*.c", {rule = "wdk.tracewpp"})
|
|
|
+ add_files("*.rc", "*.inf")
|
|
|
+ add_files("*.mof|msdsm.mof")
|
|
|
+ add_files("msdsm.mof", {values = {wdk_mof_header = "msdsmwmi.h"}})
|
|
|
</code></pre>
|
|
|
<h5 id="package-driver">Package Driver</h5>
|
|
|
<p>We can run the following command to generate a .cab driver package.</p>
|
|
|
@@ -400,68 +400,68 @@ $ xmake [p|package] -o outputdir
|
|
|
- debug/x86/sampledsm.cab
|
|
|
- release/x64/sampledsm.cab
|
|
|
</code></pre><h5 id="driver-signing">Driver Signing</h5>
|
|
|
-<p>The driver signing is disabled when we compile driver in default case,<br>but we can add <code>set_values("wdk.sign.mode")</code> to enable test/release sign.</p>
|
|
|
+<p>The driver signing is disabled when we compile driver in default case,<br>but we can add <code>set_values("wdk.sign.mode")</code> to enable test/release sign.</p>
|
|
|
<h6 id="testsign">TestSign</h6>
|
|
|
<p>We can use test certificate of xmake to do testsign, but please run <code>$xmake l utils.wdk.testcert</code> install as admin to install a test certificate first (only once)!</p>
|
|
|
-<pre><code class="lang-lua">target("msdsm")
|
|
|
- add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
- set_values("wdk.sign.mode", "test")
|
|
|
+<pre><code class="lang-lua">target("msdsm")
|
|
|
+ add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
+ set_values("wdk.sign.mode", "test")
|
|
|
</code></pre>
|
|
|
<p>Or we set a valid certificate thumbprint to do it in local machine.</p>
|
|
|
-<pre><code class="lang-lua">target("msdsm")
|
|
|
- add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
- set_values("wdk.sign.mode", "test")
|
|
|
- set_values("wdk.sign.thumbprint", "032122545DCAA6167B1ADBE5F7FDF07AE2234AAA")
|
|
|
+<pre><code class="lang-lua">target("msdsm")
|
|
|
+ add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
+ set_values("wdk.sign.mode", "test")
|
|
|
+ set_values("wdk.sign.thumbprint", "032122545DCAA6167B1ADBE5F7FDF07AE2234AAA")
|
|
|
</code></pre>
|
|
|
<p>We can also do testsign via setting store/company info.</p>
|
|
|
-<pre><code class="lang-lua">target("msdsm")
|
|
|
- add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
- set_values("wdk.sign.mode", "test")
|
|
|
- set_values("wdk.sign.store", "PrivateCertStore")
|
|
|
- set_values("wdk.sign.company", "tboox.org(test)")
|
|
|
+<pre><code class="lang-lua">target("msdsm")
|
|
|
+ add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
+ set_values("wdk.sign.mode", "test")
|
|
|
+ set_values("wdk.sign.store", "PrivateCertStore")
|
|
|
+ set_values("wdk.sign.company", "tboox.org(test)")
|
|
|
</code></pre>
|
|
|
<h6 id="releasesign">ReleaseSign</h6>
|
|
|
<p>We can set a certificate file for release signing.</p>
|
|
|
-<pre><code class="lang-lua">target("msdsm")
|
|
|
- add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
- set_values("wdk.sign.mode", "release")
|
|
|
- set_values("wdk.sign.company", "xxxx")
|
|
|
- set_values("wdk.sign.certfile", path.join(os.projectdir(), "xxxx.cer"))
|
|
|
+<pre><code class="lang-lua">target("msdsm")
|
|
|
+ add_rules("wdk.driver", "wdk.env.wdm")
|
|
|
+ set_values("wdk.sign.mode", "release")
|
|
|
+ set_values("wdk.sign.company", "xxxx")
|
|
|
+ set_values("wdk.sign.certfile", path.join(os.projectdir(), "xxxx.cer"))
|
|
|
</code></pre>
|
|
|
<h5 id="support-low-version-system">Support Low-version System</h5>
|
|
|
<p>We can set <code>wdk.env.winver</code> to generate a driver package that is compatible with a low version system.</p>
|
|
|
-<pre><code class="lang-lua">set_values("wdk.env.winver", "win10")
|
|
|
-set_values("wdk.env.winver", "win10_rs3")
|
|
|
-set_values("wdk.env.winver", "win81")
|
|
|
-set_values("wdk.env.winver", "win8")
|
|
|
-set_values("wdk.env.winver", "win7")
|
|
|
-set_values("wdk.env.winver", "win7_sp1")
|
|
|
-set_values("wdk.env.winver", "win7_sp2")
|
|
|
-set_values("wdk.env.winver", "win7_sp3")
|
|
|
+<pre><code class="lang-lua">set_values("wdk.env.winver", "win10")
|
|
|
+set_values("wdk.env.winver", "win10_rs3")
|
|
|
+set_values("wdk.env.winver", "win81")
|
|
|
+set_values("wdk.env.winver", "win8")
|
|
|
+set_values("wdk.env.winver", "win7")
|
|
|
+set_values("wdk.env.winver", "win7_sp1")
|
|
|
+set_values("wdk.env.winver", "win7_sp2")
|
|
|
+set_values("wdk.env.winver", "win7_sp3")
|
|
|
</code></pre>
|
|
|
<p>We can also set windows version for WDK driver program:</p>
|
|
|
<pre><code class="lang-console">$ xmake f --wdk_winver=[win10_rs3|win8|win7|win7_sp1]
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
<h4 id="winsdk-application-program">WinSDK Application Program</h4>
|
|
|
-<pre><code class="lang-lua">target("usbview")
|
|
|
- add_rules("win.sdk.application")
|
|
|
+<pre><code class="lang-lua">target("usbview")
|
|
|
+ add_rules("win.sdk.application")
|
|
|
|
|
|
- add_files("*.c", "*.rc")
|
|
|
- add_files("xmlhelper.cpp", {rule = "win.sdk.dotnet"})
|
|
|
+ add_files("*.c", "*.rc")
|
|
|
+ add_files("xmlhelper.cpp", {rule = "win.sdk.dotnet"})
|
|
|
</code></pre>
|
|
|
<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/173">#173</a>.</p>
|
|
|
<h2 id="configuration">Configuration</h2>
|
|
|
<p>Set compilation configuration before building project with command <code>xmake f|config</code>.</p>
|
|
|
<p>And if you want to known more options, please run: <code>xmake f --help</code>。</p>
|
|
|
-<p><p class="tip"><br> You can use short or long command option, for exmaple: <br><br> <code>xmake f</code> or <code>xmake config</code>.<br><br> <code>xmake f -p linux</code> or <code>xmake config --plat=linux</code>.<br></p>
|
|
|
+<p><p class="tip"><br> You can use short or long command option, for exmaple: <br><br> <code>xmake f</code> or <code>xmake config</code>.<br><br> <code>xmake f -p linux</code> or <code>xmake config --plat=linux</code>.<br></p>
|
|
|
|
|
|
</p>
|
|
|
<h4 id="target-platforms">Target Platforms</h4>
|
|
|
<h5 id="current-host">Current Host</h5>
|
|
|
<pre><code class="lang-bash">$ xmake
|
|
|
</code></pre>
|
|
|
-<p><p class="tip"><br> XMake will detect the current host platform automatically and build project.<br></p>
|
|
|
+<p><p class="tip"><br> XMake will detect the current host platform automatically and build project.<br></p>
|
|
|
|
|
|
</p>
|
|
|
<h5 id="linux">Linux</h5>
|
|
|
@@ -477,7 +477,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p android --ndk=~/files/android-ndk-r10e/ -a arm64-v8a --bin=~/files/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin
|
|
|
</code></pre>
|
|
|
<p>The <a href="#-bin">--bin</a> option is used to set <code>bin</code> directory of toolchains.</p>
|
|
|
-<p><p class="tip"><br>Please attempt to set <code>--arch=</code> option if it had failed to check compiler.<br></p>
|
|
|
+<p><p class="tip"><br>Please attempt to set <code>--arch=</code> option if it had failed to check compiler.<br></p>
|
|
|
|
|
|
</p>
|
|
|
<h5 id="iphoneos">iPhoneOS</h5>
|
|
|
@@ -505,7 +505,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p cross --sdk=/usr/local/arm-xxx-gcc/ [--bin=/sdk/bin] [--cross=arm-linux-]
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
-<p>For custem cross platform (<code>is_plat("myplat")</code>):</p>
|
|
|
+<p>For custem cross platform (<code>is_plat("myplat")</code>):</p>
|
|
|
<pre><code class="lang-bash">$ xmake f -p myplat --sdk=/usr/local/arm-xxx-gcc/ [--bin=/sdk/bin] [--cross=arm-linux-]
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
@@ -691,7 +691,7 @@ $ xmake
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
-<p><p class="tip"><br>if you want to known more options, please run: <code>xmake f --help</code>。<br></p>
|
|
|
+<p><p class="tip"><br>if you want to known more options, please run: <code>xmake f --help</code>。<br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-sdk">--sdk</h6>
|
|
|
@@ -723,7 +723,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/home/toolchains_sdkdir --bin=/usr/opt/bin
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
-<p><p class="tip"><br>Before v2.2.1 version, this parameter name is <code>--toolchains</code>, exists more ambiguous, so we changed to <code>--bin=</code> to set the bin directory.<br></p>
|
|
|
+<p><p class="tip"><br>Before v2.2.1 version, this parameter name is <code>--toolchains</code>, exists more ambiguous, so we changed to <code>--bin=</code> to set the bin directory.<br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-cross">--cross</h6>
|
|
|
@@ -744,7 +744,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/user/toolsdk --as=armv7-linux-as
|
|
|
</code></pre>
|
|
|
<p>If the 'AS' environment variable exists, it will use the values specified in the current environment variables.</p>
|
|
|
-<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang compiler, .e.g <code>xmake f --as=gcc@/home/xxx/asmips.exe</code><br></p>
|
|
|
+<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang compiler, .e.g <code>xmake f --as=gcc@/home/xxx/asmips.exe</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-cc">--cc</h6>
|
|
|
@@ -754,7 +754,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/user/toolsdk --cc=armv7-linux-clang
|
|
|
</code></pre>
|
|
|
<p>If the 'CC' environment variable exists, it will use the values specified in the current environment variables.</p>
|
|
|
-<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang compiler, .e.g <code>xmake f --cc=gcc@/home/xxx/ccmips.exe</code><br></p>
|
|
|
+<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang compiler, .e.g <code>xmake f --cc=gcc@/home/xxx/ccmips.exe</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-cxx">--cxx</h6>
|
|
|
@@ -764,7 +764,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/user/toolsdk --cxx=armv7-linux-clang++
|
|
|
</code></pre>
|
|
|
<p>If the 'CXX' environment variable exists, it will use the values specified in the current environment variables.</p>
|
|
|
-<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang compiler, .e.g <code>xmake f --cxx=g++@/home/xxx/c++mips.exe</code><br></p>
|
|
|
+<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang compiler, .e.g <code>xmake f --cxx=g++@/home/xxx/c++mips.exe</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-ld">--ld</h6>
|
|
|
@@ -774,7 +774,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/user/toolsdk --ld=armv7-linux-clang++
|
|
|
</code></pre>
|
|
|
<p>If the 'LD' environment variable exists, it will use the values specified in the current environment variables.</p>
|
|
|
-<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang linker, .e.g <code>xmake f --ld=g++@/home/xxx/c++mips.exe</code><br></p>
|
|
|
+<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang linker, .e.g <code>xmake f --ld=g++@/home/xxx/c++mips.exe</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-sh">--sh</h6>
|
|
|
@@ -784,7 +784,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/user/toolsdk --sh=armv7-linux-clang++
|
|
|
</code></pre>
|
|
|
<p>If the 'SH' environment variable exists, it will use the values specified in the current environment variables.</p>
|
|
|
-<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang linker, .e.g <code>xmake f --sh=g++@/home/xxx/c++mips.exe</code><br></p>
|
|
|
+<p><p class="tip"><br>We can set a unknown compiler as like-gcc/clang linker, .e.g <code>xmake f --sh=g++@/home/xxx/c++mips.exe</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h6 id="-ar">--ar</h6>
|
|
|
@@ -794,7 +794,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p linux --sdk=/user/toolsdk --ar=armv7-linux-ar
|
|
|
</code></pre>
|
|
|
<p>If the 'AR' environment variable exists, it will use the values specified in the current environment variables.</p>
|
|
|
-<p><p class="tip"><br>We can set a unknown compiler as like-ar archiver, .e.g <code>xmake f --ar=ar@/home/xxx/armips.exe</code><br></p>
|
|
|
+<p><p class="tip"><br>We can set a unknown compiler as like-ar archiver, .e.g <code>xmake f --ar=ar@/home/xxx/armips.exe</code><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h4 id="global-configuration">Global Configuration</h4>
|
|
|
@@ -806,7 +806,7 @@ $ xmake
|
|
|
<pre><code class="lang-bash">$ xmake f -p android
|
|
|
$ xmake
|
|
|
</code></pre>
|
|
|
-<p><p class="tip"><br> You can use short or long command option, for exmaple: <code>xmake g</code> or <code>xmake global</code>.<br><br></p>
|
|
|
+<p><p class="tip"><br> You can use short or long command option, for exmaple: <code>xmake g</code> or <code>xmake global</code>.<br><br></p>
|
|
|
|
|
|
</p>
|
|
|
<h4 id="clean-configuration">Clean Configuration</h4>
|
|
|
@@ -821,9 +821,9 @@ $ xmake
|
|
|
<h2 id="syntax-description">Syntax Description</h2>
|
|
|
<p>xmake's project description file xmake.lua is based on the lua syntax, but in order to make the project build logic more convenient and concise, xmake encapsulates it, making writing xmake.lua not as cumbersome as some makefiles.</p>
|
|
|
<p>Basically write a simple project build description, just three lines, for example:</p>
|
|
|
-<pre><code class="lang-lua">target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
+<pre><code class="lang-lua">target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
</code></pre>
|
|
|
<h4 id="scope">Scope</h4>
|
|
|
<p>The description syntax of xmake is divided by scope, which is mainly divided into:</p>
|
|
|
@@ -834,11 +834,11 @@ $ xmake
|
|
|
</ul>
|
|
|
<p>Which ones belong to the outside and which ones belong to the inside? if you look at the comments below, you know what it is:</p>
|
|
|
<pre><code class="lang-lua">-- external scope
|
|
|
-target("test")
|
|
|
+target("test")
|
|
|
|
|
|
-- external scope
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
|
|
|
on_run(function ()
|
|
|
-- Internal scope
|
|
|
@@ -849,7 +849,7 @@ target("test")
|
|
|
end)
|
|
|
|
|
|
-- external scope
|
|
|
-task("hello")
|
|
|
+task("hello")
|
|
|
|
|
|
-- external scope
|
|
|
on_run(function ()
|
|
|
@@ -860,15 +860,15 @@ task("hello")
|
|
|
<h5 id="external-scope">external Scope</h5>
|
|
|
<p>For most projects, you don't need complicated engineering descriptions, and you don't need custom scripting support. You just need a simple <code>set_xxx</code> or <code>add_xxx</code> to meet your needs.</p>
|
|
|
<p>Then according to the 28th law, 80% of the cases, we only need to write:</p>
|
|
|
-<pre><code class="lang-lua">target("test")
|
|
|
- set_kind("static")
|
|
|
- add_files("src/test/*.c")
|
|
|
+<pre><code class="lang-lua">target("test")
|
|
|
+ set_kind("static")
|
|
|
+ add_files("src/test/*.c")
|
|
|
|
|
|
-target("demo")
|
|
|
- add_deps("test")
|
|
|
- set_kind("binary")
|
|
|
- add_links("test")
|
|
|
- add_files("src/demo/*.c")
|
|
|
+target("demo")
|
|
|
+ add_deps("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_links("test")
|
|
|
+ add_files("src/demo/*.c")
|
|
|
</code></pre>
|
|
|
<p>No complicated api calls, no complicated variable definitions, and if judgments and for loops. It's succinct and readable. At a glance, it doesn't matter if you don't understand lua grammar.</p>
|
|
|
<p>As a simple description of the syntax, it looks a bit like a function call, you will know how to configure it at a basic point of programming.</p>
|
|
|
@@ -890,12 +890,12 @@ target("demo")
|
|
|
<li>format: format string, short version of string.format</li>
|
|
|
</ul>
|
|
|
<p>There are also variable definitions and logical operations that can be used. after all, it is based on lua. The basic syntax is still there. We can switch the compiled files by if:</p>
|
|
|
-<pre><code class="lang-lua">target("test")
|
|
|
- set_kind("static")
|
|
|
- if is_plat("iphoneos") then
|
|
|
- add_files("src/test/ios/*.c")
|
|
|
+<pre><code class="lang-lua">target("test")
|
|
|
+ set_kind("static")
|
|
|
+ if is_plat("iphoneos") then
|
|
|
+ add_files("src/test/ios/*.c")
|
|
|
else
|
|
|
- add_files("src/test/*.c")
|
|
|
+ add_files("src/test/*.c")
|
|
|
end
|
|
|
</code></pre>
|
|
|
<p>It should be noted that the variable definition is divided into global variables and local variables. The local variables are only valid for the current xmake.lua, and do not affect the child xmake.lua.</p>
|
|
|
@@ -905,20 +905,20 @@ local var1 = 0
|
|
|
-- global variables that affect all subsmake.lua included after includes()
|
|
|
var2 = 1
|
|
|
|
|
|
-Includes("src")
|
|
|
+Includes("src")
|
|
|
</code></pre>
|
|
|
<h5 id="internal-scope">Internal Scope</h5>
|
|
|
<p>Also known as plug-ins, script scope, provide more complex and flexible script support, generally used to write some custom scripts, plug-in development, custom task tasks, custom modules, etc.</p>
|
|
|
<p>Usually included by <code>function () end</code>, and passed to the <code>on_xxx</code>, <code>before_xxx</code> and <code>after_xxx</code> interfaces, are all self-scoped.</p>
|
|
|
<p>E.g:</p>
|
|
|
<pre><code class="lang-lua">-- custom script
|
|
|
-target("hello")
|
|
|
+target("hello")
|
|
|
after_build(function ()
|
|
|
-- Internal scope
|
|
|
end)
|
|
|
|
|
|
-- custom tasks, plugins
|
|
|
-task("hello")
|
|
|
+task("hello")
|
|
|
on_run(function ()
|
|
|
-- Internal scope
|
|
|
end)
|
|
|
@@ -926,13 +926,13 @@ task("hello")
|
|
|
<p>In this scope, not only can you use most lua apis, but you can also use many extension modules provided by xmake. All extension modules are imported through import.</p>
|
|
|
<p>For details, please refer to: <a href="https://xmake.io/#/zh/manual?id=import">import module document</a></p>
|
|
|
<p>Here we give a simple example, after the compilation is complete, ldid signature on the ios target program:</p>
|
|
|
-<pre><code class="lang-lua">target("iosdemo")
|
|
|
- set_kind("binary")
|
|
|
- add_files("*.m")
|
|
|
+<pre><code class="lang-lua">target("iosdemo")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("*.m")
|
|
|
after_build(function (target)
|
|
|
|
|
|
-- Execute signature, if it fails, automatically interrupt, giving a highlight error message
|
|
|
- Os.run("ldid -S$(projectdir)/entitlements.plist %s", target:targetfile())
|
|
|
+ Os.run("ldid -S$(projectdir)/entitlements.plist %s", target:targetfile())
|
|
|
end)
|
|
|
</code></pre>
|
|
|
<p>It should be noted that in the internal scope, all calls are enabled with the exception catching mechanism. if the operation is wrong, xmake will be automatically interrupted and an error message will be given.</p>
|
|
|
@@ -940,82 +940,82 @@ task("hello")
|
|
|
<h5 id="interface-scope">Interface Scope</h5>
|
|
|
<p>All descriptions of api settings in the external scope are also scoped. They are called in different places and have different scopes of influence, for example:</p>
|
|
|
<pre><code class="lang-lua">-- global root scope, affecting all targets, including subproject target settings in includes()
|
|
|
-add_defines("DEBUG")
|
|
|
+add_defines("DEBUG")
|
|
|
|
|
|
-- define or enter the demo target scope (support multiple entry to append settings)
|
|
|
-target("demo")
|
|
|
- set_kind("shared")
|
|
|
- add_files("src/*.c")
|
|
|
+target("demo")
|
|
|
+ set_kind("shared")
|
|
|
+ add_files("src/*.c")
|
|
|
-- the current target scope only affects the current target
|
|
|
- add_defines("DEBUG2")
|
|
|
+ add_defines("DEBUG2")
|
|
|
|
|
|
-- option settings, only local settings are supported, not affected by global api settings
|
|
|
-option("test")
|
|
|
+option("test")
|
|
|
-- local scope of the current option
|
|
|
set_default(false)
|
|
|
|
|
|
-- other target settings, -DDEBUG will also be set
|
|
|
-target("demo2")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
+target("demo2")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
|
|
|
-- re-enter the demo target scope
|
|
|
-target("demo")
|
|
|
+target("demo")
|
|
|
-- append macro definitions, only valid for the current demo target
|
|
|
- add_defines("DEBUG3")
|
|
|
+ add_defines("DEBUG3")
|
|
|
</code></pre>
|
|
|
<p>Normally, entering another target/option domain setting will automatically leave the previous target/option field, but sometimes in order to compare some scope pollution, we can show off a domain, for example:</p>
|
|
|
-<pre><code class="lang-lua">option("test")
|
|
|
+<pre><code class="lang-lua">option("test")
|
|
|
set_default(false)
|
|
|
option_end()
|
|
|
|
|
|
-target("demo")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
+target("demo")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
target_end()
|
|
|
</code></pre>
|
|
|
<p>Call <code>option_end()</code>, <code>target_end()</code> to explicitly leave the current target/option field setting.</p>
|
|
|
<h5 id="scope-indentation">Scope indentation</h5>
|
|
|
<p>Indentation in xmake.lua is just a specification for more clear distinction. The current setting is for that scope, although it is ok even if it is not indented, but it is not very readable. .</p>
|
|
|
<p>e.g:</p>
|
|
|
-<pre><code class="lang-lua">target("xxxx")
|
|
|
- set_kind("binary")
|
|
|
- add_files("*.c")
|
|
|
+<pre><code class="lang-lua">target("xxxx")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("*.c")
|
|
|
</code></pre>
|
|
|
<p>with</p>
|
|
|
-<pre><code class="lang-lua">target("xxxx")
|
|
|
-set_kind("binary")
|
|
|
-add_files("*.c")
|
|
|
+<pre><code class="lang-lua">target("xxxx")
|
|
|
+set_kind("binary")
|
|
|
+add_files("*.c")
|
|
|
</code></pre>
|
|
|
<p>The above two methods are the same in effect, but in understanding, the first one is more intuitive. At first glance, you know that <code>add_files</code> is only set for target, not global.</p>
|
|
|
<p>Therefore, proper indentation helps to better maintain xmake.lua</p>
|
|
|
<p>Finally attached, tbox's <a href="https://github.com/tboox/tbox/blob/master/src/tbox/xmake.lua">xmake.lua</a> description, for reference only. .</p>
|
|
|
<h4 id="syntax-simplification">Syntax simplification</h4>
|
|
|
<p>The configuration field syntax of xmake.lua is very flexible and can be used in a variety of complex and flexible configurations in the relevant domain, but for many streamlined small block configurations, this time is slightly redundant:</p>
|
|
|
-<pre><code class="lang-lua">option("test1")
|
|
|
+<pre><code class="lang-lua">option("test1")
|
|
|
set_default(true)
|
|
|
set_showmenu(true)
|
|
|
- set_description("test1 option")
|
|
|
+ set_description("test1 option")
|
|
|
|
|
|
-option("test2")
|
|
|
+option("test2")
|
|
|
set_default(true)
|
|
|
set_showmeu(true)
|
|
|
|
|
|
-option("test3")
|
|
|
- set_default("hello")
|
|
|
+option("test3")
|
|
|
+ set_default("hello")
|
|
|
</code></pre>
|
|
|
<p>xmake 2.2.6 or later, for the above small block option domain settings, we can simplify the description into a single line:</p>
|
|
|
-<pre><code class="lang-lua">option("test1", {default = true, showmenu = true, description = "test1 option"})
|
|
|
-option("test2", {default = true, showmenu = true})
|
|
|
-option("test3", {default = "hello"})
|
|
|
+<pre><code class="lang-lua">option("test1", {default = true, showmenu = true, description = "test1 option"})
|
|
|
+option("test2", {default = true, showmenu = true})
|
|
|
+option("test3", {default = "hello"})
|
|
|
</code></pre>
|
|
|
<p>In addition to the option field, this simplified writing is also supported for other domains, such as:</p>
|
|
|
-<pre><code class="lang-lua">target("demo")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
+<pre><code class="lang-lua">target("demo")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
</code></pre>
|
|
|
<p>Simplified to:</p>
|
|
|
-<pre><code class="lang-lua">target("demo", {kind = "binary", files = "src/*.c"})
|
|
|
+<pre><code class="lang-lua">target("demo", {kind = "binary", files = "src/*.c"})
|
|
|
</code></pre>
|
|
|
<p>Of course, if the configuration requirements are more complicated, or the original multi-line setting method is more convenient, this depends on your own needs to evaluate which method is used.</p>
|
|
|
<h2 id="dependency-package-management">Dependency Package Management</h2>
|
|
|
@@ -1030,11 +1030,11 @@ option("test3", {default = "hello"})
|
|
|
- pcre.pkg
|
|
|
- ...
|
|
|
</code></pre><p>If you want the current project to recognize loading these packages, you first need to specify the package directory path, for example:</p>
|
|
|
-<pre><code class="lang-lua">add_packagedirs("packages")
|
|
|
+<pre><code class="lang-lua">add_packagedirs("packages")
|
|
|
</code></pre>
|
|
|
<p>Once specified, you can add integration package dependencies in the target scope via the <a href="https://xmake.io/#/zh/manual?id=targetadd_packages">add_packages</a> interface, for example:</p>
|
|
|
-<pre><code class="lang-lua">target("tbox")
|
|
|
- add_packages("zlib", "polarssl", "pcre", "mysql")
|
|
|
+<pre><code class="lang-lua">target("tbox")
|
|
|
+ add_packages("zlib", "polarssl", "pcre", "mysql")
|
|
|
</code></pre>
|
|
|
<p>So how to generate a *.pkg package, if it is based on xmake project, the generation method is very simple, only need:</p>
|
|
|
<pre><code class="lang-console">$ cd tbox
|
|
|
@@ -1055,25 +1055,25 @@ $ xmake package -o ../test/packages
|
|
|
<li>pkg-config</li>
|
|
|
</ul>
|
|
|
<p>And through the system and third-party package management tools for the installation of the dependency package, and then integrated with xmake, for example, we look for an openssl package:</p>
|
|
|
-<pre><code class="lang-lua">local packages = find_packages("openssl", "zlib")
|
|
|
+<pre><code class="lang-lua">local packages = find_packages("openssl", "zlib")
|
|
|
</code></pre>
|
|
|
<p>The returned results are as follows:</p>
|
|
|
<pre><code class="lang-lua">{
|
|
|
- {links = {"ssl", "crypto"}, linkdirs = {"/usr/local/lib"}, includedirs = {"/usr/local/include"}},
|
|
|
- {links = {"z"}, linkdirs = {"/usr/local/lib"}, includedirs = {"/usr/local/include"}}
|
|
|
+ {links = {"ssl", "crypto"}, linkdirs = {"/usr/local/lib"}, includedirs = {"/usr/local/include"}},
|
|
|
+ {links = {"z"}, linkdirs = {"/usr/local/lib"}, includedirs = {"/usr/local/include"}}
|
|
|
}
|
|
|
</code></pre>
|
|
|
<p>If the search is successful, return a table containing all the package information, if it fails, return nil</p>
|
|
|
<p>The return result here can be directly passed as the parameter of <code>target:add</code>, <code>option:add</code>, which is used to dynamically increase the configuration of <code>target/option</code>:</p>
|
|
|
-<pre><code class="lang-lua">option("zlib")
|
|
|
+<pre><code class="lang-lua">option("zlib")
|
|
|
set_showmenu(true)
|
|
|
before_check(function (option)
|
|
|
- option:add(find_packages("openssl", "zlib"))
|
|
|
+ option:add(find_packages("openssl", "zlib"))
|
|
|
end)
|
|
|
</code></pre>
|
|
|
-<pre><code class="lang-lua">target("test")
|
|
|
+<pre><code class="lang-lua">target("test")
|
|
|
on_load(function (target)
|
|
|
- target:add(find_packages("openssl", "zlib"))
|
|
|
+ target:add(find_packages("openssl", "zlib"))
|
|
|
end)
|
|
|
</code></pre>
|
|
|
<p>If third-party tools such as <code>homebrew</code>, <code>pkg-config</code> are installed on the system, then this interface will try to use them to improve the search results.</p>
|
|
|
@@ -1090,30 +1090,30 @@ $ xmake package -o ../test/packages
|
|
|
</code></pre>
|
|
|
<h4 id="remote-dependency-mode">Remote dependency mode</h4>
|
|
|
<p>This has been initially supported after the 2.2.2 version, the usage is much simpler, just set the corresponding dependency package, for example:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox 1.6.*", "libpng ~1.16", "zlib")
|
|
|
+<pre><code class="lang-lua">add_requires("tbox 1.6.*", "libpng ~1.16", "zlib")
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
- add_packages("tbox", "libpng", "zlib")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
+ add_packages("tbox", "libpng", "zlib")
|
|
|
</code></pre>
|
|
|
<p>The above <code>add_requires</code> is used to describe the dependencies required by the current project, and <code>add_packages</code> is used to apply dependencies to the test target. Only settings will automatically add links, linkdirs, includedirs, etc.</p>
|
|
|
<p>Then directly compile:</p>
|
|
|
<pre><code class="lang-console">$ xmake
|
|
|
</code></pre>
|
|
|
<p>xmake will remotely pull the relevant source package, then automatically compile and install, finally compile the project, and link the dependency package. The specific effect is shown in the following figure:</p>
|
|
|
-<p><img src="/assets/img/index/package_manage.png" width="80%" /></p>
|
|
|
+<p><img src="/assets/img/index/package_manage.png" width="80%" /></p>
|
|
|
<p>For more information and progress on package dependency management see the related issues: <a href="https://github.com/xmake-io/xmake/issues/69">Remote package management</a></p>
|
|
|
<h5 id="currently-supported-features">Currently Supported Features</h5>
|
|
|
<ul>
|
|
|
-<li>Semantic version support, for example: ">= 1.1.0 < 1.2", "~1.6", "1.2.x", "1.*"</li>
|
|
|
+<li>Semantic version support, for example: ">= 1.1.0 < 1.2", "~1.6", "1.2.x", "1.*"</li>
|
|
|
<li>Provide multi-warehouse management support such as official package warehouse, self-built private warehouse, project built-in warehouse, etc.</li>
|
|
|
<li>Cross-platform package compilation integration support (packages of different platforms and different architectures can be installed at the same time, fast switching use)</li>
|
|
|
<li>Debug dependency package support, source code debugging</li>
|
|
|
</ul>
|
|
|
<h5 id="dependency-package-processing-mechanism">Dependency Package Processing Mechanism</h5>
|
|
|
<p>Here we briefly introduce the processing mechanism of the entire dependency package:</p>
|
|
|
-<p><div align="center"><br><img src="/assets/img/index/package_arch.png" width="80%" /><br></div>
|
|
|
+<p><div align="center"><br><img src="/assets/img/index/package_arch.png" width="80%" /><br></div>
|
|
|
|
|
|
</p>
|
|
|
<ol>
|
|
|
@@ -1122,73 +1122,73 @@ target("test")
|
|
|
<li>Compile the project, and finally automatically link the enabled dependencies</li>
|
|
|
</ol>
|
|
|
<h5 id="semantic-version-settings">Semantic Version Settings</h5>
|
|
|
-<p>Xmake's dependency package management fully supports semantic version selection, for example: "~1.6.1". For a detailed description of the semantic version, see: <a href="https://semver.org/">https://semver.org/</a></p>
|
|
|
+<p>Xmake's dependency package management fully supports semantic version selection, for example: "~1.6.1". For a detailed description of the semantic version, see: <a href="https://semver.org/">https://semver.org/</a></p>
|
|
|
<p>Some semantic versions are written:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox 1.6.*", "pcre 1.3.x", "libpng ^1.18")
|
|
|
-add_requires("libpng ~1.16", "zlib 1.1.2 || >=1.2.11 <1.3.0")
|
|
|
+<pre><code class="lang-lua">add_requires("tbox 1.6.*", "pcre 1.3.x", "libpng ^1.18")
|
|
|
+add_requires("libpng ~1.16", "zlib 1.1.2 || >=1.2.11 <1.3.0")
|
|
|
</code></pre>
|
|
|
<p>The semantic version parser currently used by xmake is the <a href="https://github.com/uael/sv">sv</a> library contributed by <a href="https://github.com/uael">uael</a>, which also has a description of the version. For detailed instructions, please refer to the following: <a href="https://github.com/uael/sv#versions">Version Description</a></p>
|
|
|
<p>Of course, if we have no special requirements for the current version of the dependency package, then we can write directly:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox", "libpng", "zlib")
|
|
|
+<pre><code class="lang-lua">add_requires("tbox", "libpng", "zlib")
|
|
|
</code></pre>
|
|
|
<p>This will use the latest version of the package known, or the source code compiled by the master branch. If the current package has a git repo address, we can also specify a specific branch version:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox master")
|
|
|
-add_requires("tbox dev")
|
|
|
+<pre><code class="lang-lua">add_requires("tbox master")
|
|
|
+add_requires("tbox dev")
|
|
|
</code></pre>
|
|
|
<h5 id="extra-package-information-settings">Extra Package Information Settings</h5>
|
|
|
<h6 id="optional-package-settings">Optional Package Settings</h6>
|
|
|
<p>If the specified dependency package is not supported by the current platform, or if the compilation and installation fails, then xmake will compile the error, which is reasonable for some projects that must rely on certain packages to work.<br>However, if some packages are optional dependencies, they can be set to optional packages even if they are not compiled properly.</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox", {optional = true})
|
|
|
+<pre><code class="lang-lua">add_requires("tbox", {optional = true})
|
|
|
</code></pre>
|
|
|
<h6 id="disable-system-library">Disable System Library</h6>
|
|
|
<p>With the default settings, xmake will first check to see if the system library exists (if no version is required). If the user does not want to use the system library and the library provided by the third-party package management, then you can set:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox", {system = false})
|
|
|
+<pre><code class="lang-lua">add_requires("tbox", {system = false})
|
|
|
</code></pre>
|
|
|
<h6 id="using-the-debug-version-of-the-package">Using the debug version of the package</h6>
|
|
|
<p>If we want to debug the dependencies at the same time, we can set them to use the debug version of the package (provided that this package supports debug compilation):</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox", {debug = true})
|
|
|
+<pre><code class="lang-lua">add_requires("tbox", {debug = true})
|
|
|
</code></pre>
|
|
|
<p>If the current package does not support debug compilation, you can submit the modified compilation rules in the repository to support the debug, for example:</p>
|
|
|
-<pre><code class="lang-lua">package("openssl")
|
|
|
- on_install("linux", "macosx", function (package)
|
|
|
- os.vrun("./config %s --prefix=\"%s\"", package:debug() and "--debug" or "", package:installdir())
|
|
|
- os.vrun("make -j4")
|
|
|
- os.vrun("make install")
|
|
|
+<pre><code class="lang-lua">package("openssl")
|
|
|
+ on_install("linux", "macosx", function (package)
|
|
|
+ os.vrun("./config %s --prefix=\"%s\"", package:debug() and "--debug" or "", package:installdir())
|
|
|
+ os.vrun("make -j4")
|
|
|
+ os.vrun("make install")
|
|
|
end)
|
|
|
</code></pre>
|
|
|
<h6 id="passing-additional-compilation-information-to-the-package">Passing additional compilation information to the package</h6>
|
|
|
<p>Some packages have various compile options at compile time, and we can pass them in. Of course, the package itself supports:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("tbox", {configs = {small=true}})
|
|
|
+<pre><code class="lang-lua">add_requires("tbox", {configs = {small=true}})
|
|
|
</code></pre>
|
|
|
<p>Pass <code>--small=true</code> to the tbox package so that compiling the installed tbox package is enabled.</p>
|
|
|
<h5 id="install-third-party-packages">Install third-party packages</h5>
|
|
|
<p>After version 2.2.5, xmake supports support for dependency libraries in third-party package managers, such as: conan, brew, vcpkg, etc.</p>
|
|
|
<p>Add a homebrew dependency package:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("brew::zlib", {alias = "zlib"}})
|
|
|
-add_requires("brew::pcre2/libpcre2-8", {alias = "pcre2"}})
|
|
|
+<pre><code class="lang-lua">add_requires("brew::zlib", {alias = "zlib"}})
|
|
|
+add_requires("brew::pcre2/libpcre2-8", {alias = "pcre2"}})
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
- add_packages("pcre2", "zlib")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
+ add_packages("pcre2", "zlib")
|
|
|
</code></pre>
|
|
|
<p>Add a dependency package for vcpkg:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("vcpkg::zlib", "vcpkg::pcre2")
|
|
|
+<pre><code class="lang-lua">add_requires("vcpkg::zlib", "vcpkg::pcre2")
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
- add_packages("vcpkg::zlib", "vcpkg::pcre2")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
+ add_packages("vcpkg::zlib", "vcpkg::pcre2")
|
|
|
</code></pre>
|
|
|
<p>Add a conan dependency package:</p>
|
|
|
-<pre><code class="lang-lua">add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true})
|
|
|
-add_requires("CONAN::OpenSSL/1.0.2n@conan/stable", {alias = "openssl",
|
|
|
- configs = {options = "OpenSSL:shared=True"}})
|
|
|
+<pre><code class="lang-lua">add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true})
|
|
|
+add_requires("CONAN::OpenSSL/1.0.2n@conan/stable", {alias = "openssl",
|
|
|
+ configs = {options = "OpenSSL:shared=True"}})
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
- add_packages("openssl", "zlib")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
+ add_packages("openssl", "zlib")
|
|
|
</code></pre>
|
|
|
<p>After executing xmake to compile:</p>
|
|
|
<pre><code class="lang-console">ruki:test_package ruki$ xmake
|
|
|
@@ -1196,12 +1196,12 @@ checking for the architecture ... x86_64
|
|
|
checking for the Xcode directory ... /Applications/Xcode.app
|
|
|
checking for the SDK version of Xcode ... 10.14
|
|
|
note: try installing these packages (pass -y to skip confirm)?
|
|
|
- -> CONAN::zlib/1.2.11@conan/stable (debug)
|
|
|
- -> CONAN::OpenSSL/1.0.2n@conan/stable
|
|
|
+ -> CONAN::zlib/1.2.11@conan/stable (debug)
|
|
|
+ -> CONAN::OpenSSL/1.0.2n@conan/stable
|
|
|
please input: y (y/n)
|
|
|
|
|
|
- => installing CONAN::zlib/1.2.11@conan/stable .. ok
|
|
|
- => installing CONAN::OpenSSL/1.0.2n@conan/stable .. ok
|
|
|
+ => installing CONAN::zlib/1.2.11@conan/stable .. ok
|
|
|
+ => installing CONAN::OpenSSL/1.0.2n@conan/stable .. ok
|
|
|
|
|
|
[ 0%]: ccache compiling.release src/main.c
|
|
|
[100%]: linking.release test
|
|
|
@@ -1216,7 +1216,7 @@ please input: y (y/n)
|
|
|
<pre><code class="lang-console">$ xmake repo --add myrepo [email protected]:myrepo/xmake-repo.git dev
|
|
|
</code></pre>
|
|
|
<p>Or we write directly in xmake.lua:</p>
|
|
|
-<pre><code class="lang-lua">add_repositories("my-repo [email protected]:myrepo/xmake-repo.git")
|
|
|
+<pre><code class="lang-lua">add_repositories("my-repo [email protected]:myrepo/xmake-repo.git")
|
|
|
</code></pre>
|
|
|
<p>If we just want to add one or two private packages, this time to build a git repo is too big, we can directly put the package repository into the project, for example:</p>
|
|
|
<pre><code>projectdir
|
|
|
@@ -1228,35 +1228,35 @@ please input: y (y/n)
|
|
|
- main.c
|
|
|
- xmake.lua
|
|
|
</code></pre><p>The above myrepo directory is your own private package repository, built into your own project, and then add this repository location in xmake.lua:</p>
|
|
|
-<pre><code class="lang-lua">add_repositories("my-repo myrepo")
|
|
|
+<pre><code class="lang-lua">add_repositories("my-repo myrepo")
|
|
|
</code></pre>
|
|
|
<p>This can be referred to <a href="https://github.com/tboox/benchbox">benchbox</a> project, which has a built-in private repository.</p>
|
|
|
<p>We can even build a package without directly building a package description into the project xmake.lua, which is useful for relying on one or two packages, for example:</p>
|
|
|
-<pre><code class="lang-lua">package("libjpeg")
|
|
|
+<pre><code class="lang-lua">package("libjpeg")
|
|
|
|
|
|
- set_urls("http://www.ijg.org/files/jpegsrc.$(version).tar.gz")
|
|
|
+ set_urls("http://www.ijg.org/files/jpegsrc.$(version).tar.gz")
|
|
|
|
|
|
- add_versions("v9c", "650250979303a649e21f87b5ccd02672af1ea6954b911342ea491f351ceb7122")
|
|
|
+ add_versions("v9c", "650250979303a649e21f87b5ccd02672af1ea6954b911342ea491f351ceb7122")
|
|
|
|
|
|
- on_install("windows", function (package)
|
|
|
- os.mv("jconfig.vc", "jconfig.h")
|
|
|
- os.vrun("nmake -f makefile.vc")
|
|
|
- os.cp("*.h", package:installdir("include"))
|
|
|
- os.cp("libjpeg.lib", package:installdir("lib"))
|
|
|
+ on_install("windows", function (package)
|
|
|
+ os.mv("jconfig.vc", "jconfig.h")
|
|
|
+ os.vrun("nmake -f makefile.vc")
|
|
|
+ os.cp("*.h", package:installdir("include"))
|
|
|
+ os.cp("libjpeg.lib", package:installdir("lib"))
|
|
|
end)
|
|
|
|
|
|
- on_install("macosx", "linux", function (package)
|
|
|
- import("package.tools.autoconf").install(package)
|
|
|
+ on_install("macosx", "linux", function (package)
|
|
|
+ import("package.tools.autoconf").install(package)
|
|
|
end)
|
|
|
|
|
|
package_end()
|
|
|
|
|
|
-add_requires("libjpeg")
|
|
|
+add_requires("libjpeg")
|
|
|
|
|
|
-target("test")
|
|
|
- set_kind("binary")
|
|
|
- add_files("src/*.c")
|
|
|
- add_packages("libjpeg")
|
|
|
+target("test")
|
|
|
+ set_kind("binary")
|
|
|
+ add_files("src/*.c")
|
|
|
+ add_packages("libjpeg")
|
|
|
</code></pre>
|
|
|
<h5 id="package-management-command-use">Package Management Command Use</h5>
|
|
|
<p>The package management command <code>$ xmake require</code> can be used to manually display the download, install, uninstall, retrieve, and view package information.</p>
|
|
|
@@ -1264,13 +1264,13 @@ target("test")
|
|
|
<pre><code class="lang-console">$ xmake require tbox
|
|
|
</code></pre>
|
|
|
<p>Install the specified version package:</p>
|
|
|
-<pre><code class="lang-console">$ xmake require tbox "~1.6"
|
|
|
+<pre><code class="lang-console">$ xmake require tbox "~1.6"
|
|
|
</code></pre>
|
|
|
<p>Force a re-download of the installation and display detailed installation information:</p>
|
|
|
-<pre><code class="lang-console">$ xmake require -f -v tbox "1.5.x"
|
|
|
+<pre><code class="lang-console">$ xmake require -f -v tbox "1.5.x"
|
|
|
</code></pre>
|
|
|
<p>Pass additional setup information:</p>
|
|
|
-<pre><code class="lang-console">$ xmake require --extra="debug=true,config={small=true}" tbox
|
|
|
+<pre><code class="lang-console">$ xmake require --extra="debug=true,config={small=true}" tbox
|
|
|
</code></pre>
|
|
|
<p>Install the debug package and pass the compilation configuration information of <code>small=true</code> to the package.</p>
|
|
|
<h6 id="uninstalling-the-specified-package">Uninstalling the specified package</h6>
|