Xmake is a lightweight cross-platform build tool based on Lua.
It’s very lightweight and doesn’t have any dependencies because it has a built-in Lua runtime.
It uses xmake.lua to maintain project construction. Compared with makefile/CMakeLists.txt, the configuration syntax is more concise and intuitive. It is very friendly to novices. It can be quickly started in a short time, allowing users to focus more on actual project development superior.
We can use it to directly compile projects like Make/Ninja, or generate project files like CMake/Meson, and it also has a built-in package management system to help users solve the problem of integrated use of C/C++ dependent libraries.
At present, Xmake is mainly used to build C/C++ projects, but it also supports the construction of other native languages. It can realize mixed compilation with C/C++, and the compilation speed is also very fast, which can be equal to that of Ninja.
Xmake = Build backend + Project Generator + Package Manager + [Remote|Distributed] Build + Cache
Although not very accurate, we can still understand Xmake in the following way:
Xmake ≈ Make/Ninja + CMake/Meson + Vcpkg/Conan + distcc + ccache/sccache
Introduction of new features
Verilog Simulator Support
iVerilog Simulator
pass add_requires("iverilog")
configuration, we can automatically pull the iverilog toolchain package, and then use set_toolchains("@iverilog")
Automatically bind the toolchain to compile the project.
add_requires("iverilog")
target("hello")
add_rules("iverilog.binary")
set_toolchains("@iverilog")
add_files("src/*.v")
Set abstract configuration
add_requires("iverilog")
target("hello")
add_rules("iverilog.binary")
set_toolchains("@iverilog")
add_files("src/*.v")
add_defines("TEST")
add_includedirs("inc")
set_languages("v1800-2009")
we can pass set_languages("v1800-2009")
To set the language standard for switching Verilog.
Currently supported values and mappings are as follows:
["v1364-1995"] = "-g1995"
["v1364-2001"] = "-g2001"
["v1364-2005"] = "-g2005"
["v1800-2005"] = "-g2005-sv"
["v1800-2009"] = "-g2009"
["v1800-2012"] = "-g2012"
Set custom flags
add_requires("iverilog")
target("hello")
add_rules("iverilog.binary")
set_toolchains("@iverilog")
add_files("src/*.v")
add_values("iverilogs.flags", "-DTEST")
construction project
$ xmake
checking for iverilog ... iverilog
checking for vvp ... vvp
[ 50%]: linking.iverilog hello.vvp
[100%]: build ok!
run the program
$ xmake run
hello world!
LXT2 info: dumpfile hello.vcd opened for output.
src/main.v:6: $finish called at 0 (1s)
More complete examples: iVerilog Examples
Verilator emulator
pass add_requires("verilator")
configuration, we can automatically pull the verilator toolchain package, and then use set_toolchains("@verilator")
Automatically bind to the toolchain to compile the project.
add_requires("verilator")
target("hello")
add_rules("verilator.binary")
set_toolchains("@verilator")
add_files("src/*.v")
add_files("src/*.cpp")
verilator works, we need an additional sim_main.cpp
The file participates in compilation and serves as the entry code of the program.
#include "hello.h"
#include "verilated.h"
int main(int argc, char** argv) {
VerilatedContext* contextp = new VerilatedContext;
contextp->commandArgs(argc, argv);
hello* top = new hello{contextp};
while (!contextp->gotFinish()) { top->eval(); }
delete top;
delete contextp;
return 0;
}
Set abstract configuration
add_requires("verilator")
target("hello")
add_rules("verilator.binary")
set_toolchains("@verilator")
add_files("src/*.v")
add_defines("TEST")
add_includedirs("inc")
set_languages("v1800-2009")
we can pass set_languages("v1800-2009")
To set the language standard for switching Verilog.
Currently supported values and mappings are as follows:
-- Verilog
["v1364-1995"] = "+1364-1995ext+v",
["v1364-2001"] = "+1364-2001ext+v",
["v1364-2005"] = "+1364-2005ext+v",
-- SystemVerilog
["v1800-2005"] = "+1800-2005ext+v",
["v1800-2009"] = "+1800-2009ext+v",
["v1800-2012"] = "+1800-2012ext+v",
["v1800-2017"] = "+1800-2017ext+v",
Set custom flags
add_requires("verilator")
target("hello")
add_rules("verilator.binary")
set_toolchains("@verilator")
add_files("src/*.v")
add_files("src/*.cpp")
add_values("verilator.flags", "--trace", "--timing")
construction project
$ xmake
[ 0%]: compiling.verilog src/main.v
[ 15%]: cache compiling.release /Users/ruki/.xmake/packages/v/verilator/2023.1.10/cd2268409c1d44799288c7759b3cbd56/share/verilator/include/verilated.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__Slow.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__DepSet_h9053a130__0__Slow.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello.cpp
[ 15%]: cache compiling.release /Users/ruki/.xmake/packages/v/verilator/2023.1.10/cd2268409c1d44799288c7759b3cbd56/share/verilator/include/verilated_threads.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello__Syms.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__DepSet_h07139e86__0.cpp
[ 15%]: cache compiling.release src/sim_main.cpp
[ 15%]: cache compiling.release build/.gens/hello/macosx/x86_64/release/rules/verilator/hello___024root__DepSet_h9053a130__0.cpp
[ 84%]: linking.release hello
[100%]: build ok!
run the program
$ xmake run
ruki-2:hello ruki$ xmake run
hello world!
- src/main.v:4: Verilog $finish
More complete examples: Verilator
Support for C++ Module distribution
thank you very much Arthapz Continue to help improve xmake’s support for C++ Modules in the new version.
Now, we can distribute C++ Modules as packages, and then quickly integrate and reuse them in other projects.
it is based on p2473r1 A prototype implementation of the draft design for module distribution in .
Make distribution C++ Modules package
We first use xmake.lua to build the maintenance module, and specify {install = true}
to tell xmake which module files need to be installed for external distribution.
add_rules("mode.release", "mode.debug")
set_languages("c++20")
target("foo")
set_kind("static")
add_files("*.cpp")
add_files("*.mpp", { install = true })
Then, we make it into a package that can be submitted to xmake-repo The warehouse, of course, can also be directly made into a local package, or a private warehouse package.
Here, in order to facilitate test verification, we only pass set_sourcedir
Make it a local package.
package("foo")
set_sourcedir(path.join(os.scriptdir(), "src"))
on_install(function(package)
import("package.tools.xmake").install(package, {})
end)
Integrated C++ Modules package
Then, we pass add_requires("foo")
Package integration interface for fast integration and use of C++ Modules packages.
Since foo’s module package is defined in a private repository, we pass add_repositories("my-repo my-repo")
Introduce your own package repository.
If the package has been submitted to the xmake-repo official warehouse, there is no need to configure it additionally.
add_rules("mode.release", "mode.debug")
set_languages("c++20")
add_repositories("my-repo my-repo")
add_requires("foo", "bar")
target("packages")
set_kind("binary")
add_files("src/*.cpp")
add_packages("foo", "bar")
set_policy("build.c++.modules", true)
After integrating the package, we can execute xmake
Command, one-click download, compile, and integrate C++ Modules package to use.
$ xmake
checking for platform ... linux
checking for architecture ... x86_64
note: install or modify (m) these packages (pass -y to skip confirm)?
in my-repo:
-> foo latest
-> bar latest
please input: y (y/n/m)
=> install bar latest .. ok
=> install foo latest .. ok
[ 0%]: generating.module.deps src/main.cpp
[ 0%]: generating.module.deps /mnt/xmake/tests/projects/c++/modules/packages/build/.packages/b/bar/latest/4e0143c97b65425b855ad5fd03038b6a/modules/bar/bar.mpp
[ 0%]: generating.module.deps /mnt/xmake/tests/projects/c++/modules/packages/build/.packages/f/foo/latest/4e0143c97b65425b855ad5fd03038b6a/modules/foo/foo.mpp
[ 14%]: compiling.module.release bar
[ 14%]: compiling.module.release foo
[ 57%]: compiling.release src/main.cpp
[ 71%]: linking.release packages
[100%]: build ok!
Note: After each package is installed, the meta-info file of the maintenance module will be stored in the package path, which is p2473r1.pdf
A format specification agreed in , maybe it is not the final standard, but this does not affect us to use the module distribution now.
$ cat ./build/.packages/f/foo/latest/4e0143c97b65425b855ad5fd03038b6a/modules/foo/foo.mpp.meta-info
{"_VENDOR_extension":{"xmake":{"name":"foo","file":"foo.mpp"}},"definitions":{},"include_paths":{}}
For a complete example project see: C++ Modules Package Distribution Example Project
Support C++23 Std Modules
Arthapz Also helped improve support for C++23 Std Modules.
The current progress of the three compilers supporting it:
Msvc
The latest Visual Studio 17.5 preview already supports it, and the non-standard ifc std modules will be deprecated.
For the standard C++23 std modules, we introduced it like this.
And for ifc std modules, we need to write:
It is not a C++23 standard, it is only provided by msvc, and it is not compatible with other compilers, and it will be gradually discarded in new versions of msvc in the future. Therefore, the new version of Xmake will only support C++23 std modules and no longer support the obsolete ifc std modules.
Clang
At present, the latest clang does not seem to fully support C++23 std modules, and it is still in the draft patch state, #D135507.
However, Xmake also supports it. If you want to try it out, you can integrate this patch by yourself, and then use xmake to test it.
In addition, lower versions of clang also have experimental support for non-standard std modules.
We can still try to use xmake to build std modules in lower versions of clang, although it may still be a toy (and will encounter many problems).
See related discussion: #3255
gcc
Not yet supported.
Xrepo autocompletion support
Before, we only supported incomplete xmake commands. In the new version, we also support xrepo install
Incomplete commands can be automatically searched xmake-repo The package in the warehouse does not come with our installation command.
Many thanks to @glcraft for his contribution.
$ xrepo install libp
libpaper libpfm libpng libpqxx libpthread-stubs
libpcap libplist libpq libpsl
update content
new features
- #3228: Install release of C++ modules, and import C++ modules support from packages
- #3257: Add support for iverilog and verilator
- Support xp and vc6.0
- #3214: Autocompletion support for xrepo install
Improve
- #3255: Improve clang libc++ module support
- Support compiling xmake with mingw
- Improve the compatibility of xmake on win xp
- If external dependencies are enabled, switch the json module to a pure lua implementation and remove the dependency on lua-cjson
Bug fixes
- #3229: Fix the problem that rc.exe cannot be found under vs2015
- #3271: Fix support for macro definitions with spaces
- #3273: Fix nim linking error
- #3286: Fix compile_commands support for clangd
#Xmake #v276 #Released #Added #Verilog #Modules #Distribution #Support #News Fast Delivery