[transfer]: Lua based cross platform building tool: xmake v2.0.2 release!


Update content

This release mainly fixes some bugs and compatibility issues..


  • Modify the action handling of installation and uninstall

  • Update project template

  • Enhancement function detection

Bugs repair

  • #7: Fixed the wrong target name after creating a project with a template: ‘[targetname]’

  • #9: Fixed clang does not support c + + 11

  • Fix API scope leaks

  • Fix some path problems on Windows

  • Fixed failed detection of macro functions

  • Fix detection tool chain failure

  • Fix Android version compilation failure on Windows

brief introduction

Xmake is a lightweight cross platform automatic building tool based on Lua, which supports building projects on various mainstream platforms

The goal of xmake is that developers pay more attention to the development of the project itself, simplify the description and construction of the project, and provide platform independence, so that it can be written once and built everywhere

It is similar to cmake, automake and premake, but the mechanism is different. It does not generate ide related project files by default. It adopts direct compilation and is more convenient and easy to use
Lua’s engineering description syntax is more concise and intuitive. It supports building on most common platforms and cross compiling

And xmake provides some actions such as create, configure, compile, package, install, unload, run, which makes the development and construction more convenient and process oriented.

In addition, it also provides many more advanced features, such as plug-in extensions, script macro recording, batch packaging, automatic document generation, and so on..

If you want to know more, please refer to:

  • Project Homepage

  • Online documentation

  • Online source code

Support features

  • Support windows, MAC, Linux, IOS, Android and other platforms, automatically detect the compiler tool chain on different platforms (can also be manually configured)
    Compile windows project using native vs tool chain, do not need to use cygwin, MinGW (of course, these are also supported)

  • Support custom platform compilation configuration, which can easily extend the support of third-party platform

  • Lua script syntax is used to describe the project, the description rules are simple and efficient, the logic rules can be flexibly modified, and the related platform engineering files will not be generated, which makes the project more simple and clear

  • Support to create template project, configuration project, compile project, run, package, install and uninstall and other common functions (the following will be added: automatic document generation, debugging and other modules)

  • Support compiling C / C + + / objc / swift into static library, dynamic library and command line executable program

  • It provides rich project description API, which is simple and flexible to use. For example, to add a compiled file, you only need to (also support filtering and exclusion)

add_files("src/*.c", "src/asm/**.S", "src/*.m")

  • It supports automatic detection of header file, interface, link library dependency and type, and can automatically generate configuration header file config. H

  • Support custom compilation configuration switch, for example, if theenable_xxxWhen the configuration is compiled, you can manually configure it to enable it

xmake config --enable_xxx=y

  • It provides one key packaging function. No matter which platform you want to package, you only need to execute the same command, which is very convenient

  • Global configuration is supported. Some common project configurations, such as tool chain, rule description, etc., can be configured globally. In this way, it is not necessary to configure every time different projects are compiled

  • In addition to automatic detection of dependent modules, it also supports manual mandatory configuration of modules, as well as various compilation flags.

  • Support plug-in extension, platform extension, template extension, option customization and other advanced functions

  • Provide some built-in common plug-ins (for example: automatic generation of Doxygen document plug-in, macro script recording and running plug-in)

  • The macro record plug-in provides some built-in macro scripts (for example, batch package all archs of a platform, etc.), and you can also manually record the macro in the command line and replay the execution

  • Provide powerful task task mechanism

  • It does not rely on makefile and make to achieve direct compilation and built-in automatic multi task accelerated compilation. Xmake is a real architecture tool, not just a project file generator

  • Automatic detection of ccache, automatic caching to improve the construction speed

Common actions

  • Config: compile parameter configuration before build

  • Global: configure some global parameters

  • Build: build a project

  • Clean: clean up some binary files and temporary files

  • Create: create a new project using a template

  • Package: package the specified target

  • Install: install the compiled target file

  • Uninstall: uninstall all files installed

  • Run: running executable project goals

Some built-in plug-ins

  • Doxygen document generation plug-in: generates Doxygen documents from the specified source code directory

  • Macro record script plug-in: record and replay macro scripts, simplify repeated command operations (e.g. batch packaging)

  • Hello plug in: plug in development demo

  • Project file generation plug-in: create ide project files (currently support: Makefile, follow-up support: vs, Xcode, etc.)

Support for compiled languages

  • C/C++

  • Objc/Objc++

  • Swift

  • Assembly

Supported construction platform

  • Windows (x86, x64, amd64, x86_amd64)

  • Macosx (i386, x86_64)

  • Linux (i386, x86_64, cross-toolchains …)

  • Android (armv5te, armv6, armv7-a, armv8-a, arm64-v8a)

  • iPhoneos (armv7, armv7s, arm64, i386, x86_64)

  • Watchos (armv7k, i386)

  • Mingw (i386, x86_64)

Follow up plan

  • Automatic package dependency management and download

  • Create a migration warehouse, implementOne person transplant, many people share

  • More plug-in development

  • Automatic generation of VS, Xcode and other engineering files

Simple example

Create a C + + console project:

    xmake create -l c++ -t 1 console
 or xmake create --language=c++ --template=1 console

Project description document: xmake.lua


Configuration Engineering:

This is an optional step. If you only want to compile the project of the current host platform, you can not configure it. The release version is compiled by default.

   xmake f -p iphoneos -m debug
or xmake f --plat=macosx --arch=x86_64
or xmake f -p windows
or xmake config --plat=iphoneos --mode=debug
or xmake config --plat=android --arch=armv7-a --ndk=xxxxx
or xmake config -p linux -a i386
or xmake config -p mingw --cross=i386-mingw32- --toolchains=/xxx/bin
or xmake config -p mingw --sdk=/mingwsdk
or xmake config --help

Compilation project:

or xmake -r
or xmake --rebuild

Operation target:

   xmake r console
or xmake run console

Package all:

   xmake p
or xmake package
or xmake package console
or xmake package -o /tmp
or xmake package --output=/tmp

Package all architectures with macro scripts:

   xmake m package 
or xmake m package -p iphoneos
or xmake m package -p macosx -f "-m debug" -o /tmp/
or xmake m package --help

Installation target:

   xmake i
or xmake install
or xmake install console
or xmake install -o /tmp
or xmake install --output=/tmp

Please refer to the document for detailed usage and parameter description
Or run:

   xmake -h
or xmake --help
or xmake config --help
or xmake package --help
or xmake macro --help

Some projects using xmake:

  • tbox

  • gbox

  • libsvx

  • More projects

Simple example

-- the debug mode
if is_mode("debug") then
    -- enable the debug symbols

    -- disable optimization

-- the release mode
if is_mode("release") then

    -- set the symbols visibility: hidden

    -- enable fastest optimization

    -- strip all symbols

-- add target

    -- set kind

    -- add files

  • Source of the original text: http://tboox.org/cn/2016/07/06/update-v2.0.2/