This version does not have much new features. It mainly provides experimental support for c 20 modules. It currently supports the clang/msvc compiler. In addition, it improves a lot of user experience and improves some stability.
In addition, this version adds socket.io support and scheduling support for the corresponding coroutine io, preparing for the next version of remote compilation and subsequent distributed compilation.
Introduction of new features
c 20 modules
c modules has been officially included in the c 20 draft, msvc and clang have basically realized the support for modules-ts , as the footsteps of c 20 are getting closer and closer to us, xmake has also begun to support c modules in advance.
At present, xmake has fully supported the implementation of modules-ts of msvc/clang. For gcc, since its cxx-modules branch is still under development, it has not officially entered the master. I checked the changelog inside, and the relevant flags are still there. It is constantly changing, and I feel that it has not stabilized yet, so there is no support for it for the time being.
For the related progress of xmake to c modules, please see: https://github.com/xmake-io/xmake/pull/569
Hello Module
I won’t say much about the related introduction of c modules. Here we will mainly introduce how to build c modules project under xmake. Let’s first look at a simple example:
target("hello")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")
The above is a description of xmake.lua that supports the construction of c modules files, among which hello.mpp
is the module file:
#include <cstdio>
export module hello;
using namespace std;
export namespace hello {
void say(const char* str) {
printf("%s\n", str);
}
}
And main.cpp is the main program that uses the hello module:
import hello;
int main() {
hello::say("hello module!");
return 0;
}
Next, we execute xmake to build this program:
ruki:hello ruki$ xmake
[ 0%]: ccache compiling.release src/hello.mpp
[ 50%]: ccache compiling.release src/main.cpp
[100%]: linking.release hello
build ok!
Is it very simple, xmake will handle all the detailed logic internally. For developers, it is just adding the module file *.mpp
as a source file.
Module interface file
The above *.mpp
is the module interface file naming recommended by xmake. In fact, the default suffixes of the module files are not unified by various compilers. It is under clang and under *.cppm
msvc *.ixx
. This is for writing modules that are unified across compilers. The project is very unfriendly, so here we refer to the recommended method in build2 and use a unified *.mpp
suffix to standardize the command of the module project interface under xmake.
Of course, this also supports xmake recommended naming, and for *.ixx
, *.cppm
such as extension, xmake is also fully compatible with support, can also be added directly to add_files
go.
Other examples
There are also many project examples related to c modules built in the xmake project. Those who are interested can refer to: c module examples
set_toolchain interface changes
The set toolchain interface is mainly used to set up different compilation toolchains for the target. Versions before 2.2.9 actually have two interfaces `add tools 和
set tools` to handle the same thing, but the naming and usage of these two interfaces are not consistent with the specifications It is very consistent, so some adjustments and changes have been made to better set up the toolchain with this new interface of set toolchain.
For add_files("*.c")
added source code files, by default, the compiler tool that best matches the system will be invoked to compile, or xmake f --cc=clang
manually modified through commands, but these will affect all target targets globally.
If you have some special requirements, you need to specify a different compiler, linker, or a specific version of the compiler for a specific target under the current project. At this time, this interface can be used, for example:
target("test1")
add_files("*.c")
target("test2")
add_files("*.c")
set_toolchain("cc", "$(projectdir)/tools/bin/clang-5.0")
The above description only makes special settings for the compiler of the test2 target. Use a specific clang-5.0 compiler to compile test2, and test1 still uses the default settings.
For some compiler file names that are irregular and cause xmake to not be recognized and processed as a known compiler name, we can also add a tool name prompt, for example:
set_toolchain("cc", "gcc@$(projectdir)/tools/bin/mipscc.exe")
The above description sets mipscc.exe as the c compiler, and prompts xmake to compile as the parameter passing method of gcc.
socket io
This interface has been implemented initially, supports the io scheduling of lua coroutines, and realizes high-concurrency io read and write (the later will also support the scheduling support of processes and pipes). It is currently mainly used for xmake itself for subsequent To prepare for remote compilation and distributed compilation, it is temporarily not open to users for their own use, but after subsequent improvements, they will be opened, and users can also do some service programs through socket io in their own plug-ins.
However, there may not be many scenarios used by users. After all, xmake is just a build tool and rarely allows users to do io communication by themselves.
update content
New features
- #569 : Add experimental support for the c module
- Add
xmake project -k xmakefile
generator - 620 : Add a global
~/.xmakerc.lua
configuration file, effective for all local projects. - 593 : Add
core.base.socket
modules to prepare for the next step of remote compilation and distributed compilation.
Improve
- #563 : Refactor the construction logic to separate the construction of specific languages into independent rules
- # 570 : Construction of improved Qt, the
qt.application
splitting intoqt.widgetapp
andqt.quickapp
two construction rules - # 576 : the use of
set_toolchain
alternativeadd_tools
andset_tools
solve the old ambiguous interface, setting provides a more understandable way - Improve the
xmake create
creation of template projects - #589 : Improve the default number of build tasks and make full use of cpu core to speed up the overall compilation speed
- #598 : Improve
find_package
support for searching for .tbd system library files on macOS - #615 : Support the installation and use of other arch and ios conan packages
- #629 : Improve hash.uuid and implement uuid v4
- #639 : Improve parameter parser to support
-jN
style parameter passing
Bugs fixed
- #567 : Fix the memory overflow problem when serializing objects
- #566 : Fix the link order problem of installing remote dependencies
- #565 : Fix the issue of running PATH setting of vcpkg package
- #597 : Fix the problem that the xmake require installation package takes too long
- #634 : Repair mode.coverage construction rules, and improve flags detection
https://tboox.org/cn/2019/12/21/xmake-update-v2.2.9/