| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- <!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="//cdn.jsdelivr.net/npm/[email protected]/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/#/plugin/builtin_plugins">https://xmake.io/#/plugin/builtin_plugins</a>
- </br>
- <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>
- <h2 id="generate-ide-project-files">Generate IDE Project Files</h2>
- <h3 id="generate-makefile">Generate Makefile</h3>
- <pre><code class="lang-bash">$ xmake project -k makefile
- </code></pre>
- <h3 id="generate-cmakelists-txt">Generate CMakelists.txt</h3>
- <pre><code class="lang-console">$ xmake project -k cmakelists
- </code></pre>
- <h3 id="generate-build-ninja">Generate build.ninja</h3>
- <p>!> Only supported in versions above 2.3.1</p>
- <pre><code class="lang-console">$ xmake project -k ninja
- </code></pre>
- <h3 id="generate-compiler_flags">Generate compiler_flags</h3>
- <pre><code class="lang-console">$ xmake project -k compiler_flags
- </code></pre>
- <h3 id="generate-compiler_commands">Generate compiler_commands</h3>
- <p>We can export the compilation commands info of all source files and it is JSON compilation database format.</p>
- <pre><code class="lang-console">$ xmake project -k compile_commands
- </code></pre>
- <p>The the content of the output file:</p>
- <pre><code>[
- { "directory": "/home/user/llvm/build",
- "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
- "file": "file.cc" },
- ...
- ]
- </code></pre><p>Please see <a href="#https://clang.llvm.org/docs/JSONCompilationDatabase.html">JSONCompilationDatabase</a> if need known more info about <code>compile_commands</code>.</p>
- <h3 id="generate-visualstudio-project">Generate VisualStudio Project</h3>
- <h4 id="compile-with-xmake-integration">Compile with xmake integration</h4>
- <p>v2.2.8 or later, provides a new version of the vs project generation plugin extension, which is very different from the previous plugin processing mode for generating vs. The previously generated vs project is the compilation of all files and then transferred to vs. To handle compilation.</p>
- <p>But this mode, there is no way to support the rules of xmake. Because xmake's rules use a lot of custom scripts like <code>on_build</code>, they can't be expanded, so projects like qt, wdk can't support exporting to vs. compile.</p>
- <p>Therefore, in order to solve this problem, the new version of the vs. build plugin performs the compile operation by directly calling the xmake command under vs, and also supports intellisense and definition jumps, as well as breakpoint debugging.</p>
- <p>The specific use is similar to the old version:</p>
- <pre><code class="lang-console">$ xmake project -k [vsxmake2010|vsxmake2013|vsxmake2015|..] -m "debug;release"
- </code></pre>
- <p>If no version is specified, xmake will automatically detect the current version of vs to generate:</p>
- <pre><code class="lang-bash">$ xmake project -k vsxmake -m "debug;release"
- </code></pre>
- <p><img src="/assets/img/manual/qt_vs.png" alt=""></p>
- <p>In addition, the vsxmake plugin will additionally generate a custom configuration property page for easy and flexible modification and appending some xmake compilation configuration in the vs., and even switch to other cross toolchains in the configuration to achieve the vs. vs. Cross-compilation of other platforms such as android, linux.</p>
- <p><img src="/assets/img/manual/property_page_vsxmake.png" alt=""></p>
- <h4 id="using-vs-built-in-compilation-mechanism">Using vs built-in compilation mechanism</h4>
- <p>!> It is recommended to use the new version of the vs. plugin provided after v2.2.8 mentioned above. The support is more complete. The generation method here does not support the rules of xmake, and the generation of projects such as qt.</p>
- <pre><code class="lang-bash">$ xmake project -k [vs2008|vs2013|vs2015|..]
- </code></pre>
- <p>v2.1.2 or later, it supports multi-mode and multi-architecture generation for vs201x project.</p>
- <p>For example:</p>
- <pre><code class="lang-bash">$ xmake project -k vs2017 -m "debug,release"
- </code></pre>
- <p>It will generate four project configurations: <code>debug|x86</code>, <code>debug|x64</code>, <code>release|x86</code>, <code>release|x64</code>.</p>
- <p>Or you can set modes to <code>xmake.lua</code>:</p>
- <pre><code class="lang-lua">set_modes("debug", "release")
- </code></pre>
- <p>Then, we run the following command:</p>
- <pre><code class="lang-bash">$ xmake project -k vs2017
- </code></pre>
- <p>The effect is same.</p>
- <h2 id="run-the-custom-lua-script">Run the Custom Lua Script</h2>
- <h3 id="run-the-given-script">Run the given script</h3>
- <p>Write a simple lua script:</p>
- <pre><code class="lang-lua">function main()
- print("hello xmake!")
- end
- </code></pre>
- <p>Run this lua script.</p>
- <pre><code class="lang-bash">$ xmake lua /tmp/test.lua
- </code></pre>
- <p><p class="tip"><br> You can also use <code>import</code> api to write a more advance lua script.<br></p>
- </p>
- <h3 id="run-the-builtin-script">Run the builtin script</h3>
- <p>You can run <code>xmake lua -l</code> to list all builtin script name, for example:</p>
- <pre><code class="lang-bash">$ xmake lua -l
- scripts:
- cat
- cp
- echo
- versioninfo
- ...
- </code></pre>
- <p>And run them:</p>
- <pre><code class="lang-bash">$ xmake lua cat ~/file.txt
- $ xmake lua echo "hello xmake"
- $ xmake lua cp /tmp/file /tmp/file2
- $ xmake lua versioninfo
- </code></pre>
- <h3 id="run-interactive-commands-repl-">Run interactive commands (REPL)</h3>
- <p>Enter interactive mode:</p>
- <pre><code class="lang-bash">$ xmake lua
- > 1 + 2
- 3
- > a = 1
- > a
- 1
- > for _, v in pairs({1, 2, 3}) do
- >> print(v)
- >> end
- 1
- 2
- 3
- </code></pre>
- <p>And we can <code>import</code> modules:</p>
- <pre><code class="lang-bash">> task = import("core.project.task")
- > task.run("hello")
- hello xmake!
- </code></pre>
- <p>If you want to cancel multiline input, please input character <code>q</code>, for example:</p>
- <pre><code class="lang-bash">> for _, v in ipairs({1, 2}) do
- >> print(v)
- >> q <-- cancel multiline and clear previous input
- > 1 + 2
- 3
- </code></pre>
- <h2 id="show-specified-information-and-list">Show specified information and list</h2>
- <h3 id="show-basic-information-about-xmake-itself-and-the-current-project">Show basic information about xmake itself and the current project</h3>
- <pre><code class="lang-bash">$ xmake show
- The information of xmake:
- version: 2.3.3+202006011009
- host: macosx/x86_64
- programdir: /Users/ruki/.local/share/xmake
- programfile: /Users/ruki/.local/bin/xmake
- globaldir: /Users/ruki/.xmake
- tmpdir: /var/folders/32/w9cz0y_14hs19lkbs6v6_fm80000gn/T/.xmake501/200603
- workingdir: /Users/ruki/projects/personal/tbox
- packagedir: /Users/ruki/.xmake/packages
- packagedir(cache): /Users/ruki/.xmake/cache/packages/2006
- The information of project: tbox
- version: 1.6.5
- plat: macosx
- arch: x86_64
- mode: release
- buildir: build
- configdir: /Users/ruki/projects/personal/tbox/.xmake/macosx/x86_64
- projectdir: /Users/ruki/projects/personal/tbox
- projectfile: /Users/ruki/projects/personal/tbox/xmake.lua
- </code></pre>
- <h3 id="show-toolchains-list">Show toolchains list</h3>
- <pre><code class="lang-bash">$ xmake show -l toolchains
- xcode Xcode IDE
- vs VisualStudio IDE
- yasm The Yasm Modular Assembler
- clang A C language family frontend for LLVM
- go Go Programming Language Compiler
- dlang D Programming Language Compiler
- sdcc Small Device C Compiler
- cuda CUDA Toolkit
- ndk Android NDK
- rust Rust Programming Language Compiler
- llvm A collection of modular and reusable compiler and toolchain technologies
- cross Common cross compilation toolchain
- nasm NASM Assembler
- gcc GNU Compiler Collection
- mingw Minimalist GNU for Windows
- gnu-rm GNU Arm Embedded Toolchain
- envs Environment variables toolchain
- fasm Flat Assembler
- </code></pre>
- <h3 id="show-the-information-of-the-given-target">Show the information of the given target</h3>
- <pre><code class="lang-bash">$ xmake show --target=tbox
- The information of target(tbox):
- kind: static
- targetfile: build/macosx/x86_64/release/libtbox.a
- rules: mode.release, mode.debug, mode.profile, mode.coverage
- options: info, float, wchar, exception, force-utf8, deprecated, xml, zip, hash, regex, coroutine, object, charset, database
- packages: mbedtls, polarssl, openssl, pcre2, pcre, zlib, mysql, sqlite3
- links: pthread
- syslinks: pthread, dl, m, c
- cxflags: -Wno-error=deprecated-declarations, -fno-strict-aliasing, -Wno-error=expansion-to-defined, -fno-stack-protector
- defines: __tb_small__, __tb_prefix__="tbox"
- mxflags: -Wno-error=deprecated-declarations, -fno-strict-aliasing, -Wno-error=expansion-to-defined
- headerfiles: src/(tbox/**.h)|**/impl/**.h, src/(tbox/prefix/**/prefix.S), src/(tbox/math/impl/*.h), src/(tbox/utils/impl/*.h), build/macosx/x86_64/release/tbox.config.h
- includedirs: src, build/macosx/x86_64/release
- at: /Users/ruki/projects/personal/tbox/src/tbox/xmake.lua
- sourcebatch(cc): with rule(c.build)
- -> src/tbox/string/static_string.c
- -> build/.objs/tbox/macosx/x86_64/release/src/tbox/string/static_string.c.o
- -> build/.deps/tbox/macosx/x86_64/release/src/tbox/string/static_string.c.o.d
- -> src/tbox/platform/sched.c
- -> build/.objs/tbox/macosx/x86_64/release/src/tbox/platform/sched.c.o
- -> build/.deps/tbox/macosx/x86_64/release/src/tbox/platform/sched.c.o.d
- -> src/tbox/stream/stream.c
- -> build/.objs/tbox/macosx/x86_64/release/src/tbox/stream/stream.c.o
- -> build/.deps/tbox/macosx/x86_64/release/src/tbox/stream/stream.c.o.d
- -> src/tbox/utils/base32.c
- -> build/.objs/tbox/macosx/x86_64/release/src/tbox/utils/base32.c.o
- -> build/.deps/tbox/macosx/x86_64/release/src/tbox/utils/base32.c.o.d
- </code></pre>
- <h3 id="show-builtin-compilation-modes-list">Show builtin compilation modes list</h3>
- <pre><code class="lang-bash">$ xmake show -l modes
- </code></pre>
- <h3 id="show-builtin-compilation-rules-list">Show builtin compilation rules list</h3>
- <pre><code class="lang-bash">$ xmake show -l rules
- </code></pre>
- <h3 id="show-other-information">Show other information</h3>
- <p>It is still being perfected, see: <a href="https://github.com/xmake-io/xmake/issues/798">https://github.com/xmake-io/xmake/issues/798</a></p>
- <p>Or run</p>
- <pre><code class="lang-bash">$ xmake show --help
- </code></pre>
- <h2 id="macros-recording-and-playback">Macros Recording and Playback</h2>
- <h3 id="introduction">Introduction</h3>
- <p>We can record and playback our xmake commands and save as macro quickly using this plugin.</p>
- <p>And we can run this macro to simplify our jobs repeatably.</p>
- <h3 id="record-commands">Record Commands</h3>
- <pre><code class="lang-bash"># begin to record commands
- $ xmake macro --begin
- # run some xmake commands
- $ xmake f -p android --ndk=/xxx/ndk -a arm64-v8a
- $ xmake p
- $ xmake f -p mingw --sdk=/mingwsdk
- $ xmake p
- $ xmake f -p linux --sdk=/toolsdk --toolchains=/xxxx/bin
- $ xmake p
- $ xmake f -p iphoneos -a armv7
- $ xmake p
- $ xmake f -p iphoneos -a arm64
- $ xmake p
- $ xmake f -p iphoneos -a armv7s
- $ xmake p
- $ xmake f -p iphoneos -a i386
- $ xmake p
- $ xmake f -p iphoneos -a x86_64
- $ xmake p
- # stop to record and save as anonymous macro
- xmake macro --end
- </code></pre>
- <h3 id="playback-macro">Playback Macro</h3>
- <pre><code class="lang-bash"># playback the previous anonymous macro
- $ xmake macro .
- </code></pre>
- <h3 id="named-macro">Named Macro</h3>
- <pre><code class="lang-bash">$ xmake macro --begin
- $ ...
- $ xmake macro --end macroname
- $ xmake macro macroname
- </code></pre>
- <h3 id="import-and-export-macro">Import and Export Macro</h3>
- <p>Import the given macro file or directory.</p>
- <pre><code class="lang-bash">$ xmake macro --import=/xxx/macro.lua macroname
- $ xmake macro --import=/xxx/macrodir
- </code></pre>
- <p>Export the given macro to file or directory.</p>
- <pre><code class="lang-bash">$ xmake macro --export=/xxx/macro.lua macroname
- $ xmake macro --export=/xxx/macrodir
- </code></pre>
- <h3 id="list-and-show-macro">List and Show Macro</h3>
- <p>List all builtin macros.</p>
- <pre><code class="lang-bash">$ xmake macro --list
- </code></pre>
- <p>Show the given macro script content.</p>
- <pre><code class="lang-bash">$ xmake macro --show macroname
- </code></pre>
- <h3 id="custom-macro-script">Custom Macro Script</h3>
- <p>Create and write a <code>macro.lua</code> script first.</p>
- <pre><code class="lang-lua">function main()
- os.exec("xmake f -p android --ndk=/xxx/ndk -a arm64-v8a")
- os.exec("xmake p")
- os.exec("xmake f -p mingw --sdk=/mingwsdk")
- os.exec("xmake p")
- os.exec("xmake f -p linux --sdk=/toolsdk --toolchains=/xxxx/bin")
- os.exec("xmake p")
- os.exec("xmake f -p iphoneos -a armv7")
- os.exec("xmake p")
- os.exec("xmake f -p iphoneos -a arm64")
- os.exec("xmake p")
- os.exec("xmake f -p iphoneos -a armv7s")
- os.exec("xmake p")
- os.exec("xmake f -p iphoneos -a i386")
- os.exec("xmake p")
- os.exec("xmake f -p iphoneos -a x86_64")
- os.exec("xmake p")
- end
- </code></pre>
- <p>Import this macro script to xmake.</p>
- <pre><code class="lang-bash">$ xmake macro --import=/xxx/macro.lua [macroname]
- </code></pre>
- <p>Playback this macro script.</p>
- <pre><code class="lang-bash">$ xmake macro [.|macroname]
- </code></pre>
- <h3 id="builtin-macros">Builtin Macros</h3>
- <p>XMake supports some builtins macros to simplify our jobs.</p>
- <p>For example, we use <code>package</code> macro to package all architectures of the iphoneos platform just for once.</p>
- <pre><code class="lang-bash">$ xmake macro package -p iphoneos
- </code></pre>
- <h3 id="advance-macro-script">Advance Macro Script</h3>
- <p>Let's see the <code>package</code> macro script:</p>
- <pre><code class="lang-lua">-- imports
- import("core.base.option")
- import("core.project.config")
- import("core.project.project")
- import("core.platform.platform")
- -- the options
- local options =
- {
- {'p', "plat", "kv", os.host(), "Set the platform." }
- , {'f', "config", "kv", nil, "Pass the config arguments to \"xmake config\" .." }
- , {'o', "outputdir", "kv", nil, "Set the output directory of the package." }
- }
- -- package all
- --
- -- .e.g
- -- xmake m package
- -- xmake m package -f "-m debug"
- -- xmake m package -p linux
- -- xmake m package -p iphoneos -f "-m debug --xxx ..." -o /tmp/xxx
- -- xmake m package -f \"--mode=debug\"
- --
- function main(argv)
- -- parse arguments
- local args = option.parse(argv, options, "Package all architectures for the given the platform."
- , ""
- , "Usage: xmake macro package [options]")
- -- package all archs
- local plat = args.plat
- for _, arch in ipairs(platform.archs(plat)) do
- -- config it
- os.exec("xmake f -p %s -a %s %s -c %s", plat, arch, args.config or "", (option.get("verbose") and "-v" or ""))
- -- package it
- if args.outputdir then
- os.exec("xmake p -o %s %s", args.outputdir, (option.get("verbose") and "-v" or ""))
- else
- os.exec("xmake p %s", (option.get("verbose") and "-v" or ""))
- end
- end
- -- package universal for iphoneos, watchos ...
- if plat == "iphoneos" or plat == "watchos" then
- -- load configure
- config.load()
- -- load project
- project.load()
- -- enter the project directory
- os.cd(project.directory())
- -- the outputdir directory
- local outputdir = args.outputdir or config.get("buildir")
- -- package all targets
- for _, target in pairs(project.targets()) do
- -- get all modes
- local modedirs = os.match(format("%s/%s.pkg/lib/*", outputdir, target:name()), true)
- for _, modedir in ipairs(modedirs) do
- -- get mode
- local mode = path.basename(modedir)
- -- make lipo arguments
- local lipoargs = nil
- for _, arch in ipairs(platform.archs(plat)) do
- local archfile = format("%s/%s.pkg/lib/%s/%s/%s/%s", outputdir, target:name(), mode, plat, arch, path.filename(target:targetfile()))
- if os.isfile(archfile) then
- lipoargs = format("%s -arch %s %s", lipoargs or "", arch, archfile)
- end
- end
- if lipoargs then
- -- make full lipo arguments
- lipoargs = format("-create %s -output %s/%s.pkg/lib/%s/%s/universal/%s", lipoargs, outputdir, target:name(), mode, plat, path.filename(target:targetfile()))
- -- make universal directory
- os.mkdir(format("%s/%s.pkg/lib/%s/%s/universal", outputdir, target:name(), mode, plat))
- -- package all archs
- os.execv("xmake", {"l", "lipo", lipoargs})
- end
- end
- end
- end
- end
- </code></pre>
- <p><p class="tip"><br> If you want to known more options, please run: <code>xmake macro --help</code><br></p>
- </p>
- <h2 id="generate-doxygen-document">Generate Doxygen Document</h2>
- <p>Please ensure that the doxygen tool has been installed first.</p>
- <pre><code class="lang-bash">$ xmake doxygen
- </code></pre>
- </article>
- </body>
- </html>
|