DEV Community

ruki
ruki

Posted on

xmake v2.3.6 released, Support fortran compilation and go dlang package dependences

This version focuses on some improvements to the support of other languages, such as fortran compilation support, experimental support for zig language, and third-party dependency package support and cross-compilation support for golang/dlang.

Although, xmake focuses on c/c++ build support, other languages support xmake will also make some improvements from time to time. Its main purpose is not to replace their official build system, but only to support mixed compilation with c/c++ , To better serve c/c++ projects,
After all, some c/c++ projects still occasionally call code interfaces of other languages, such as mixed calls with languages such as cuda, dlang, objc, swift, asm, etc., so xmake still provides some basic compilation support for them.

In addition, regarding c/c++, we also support the header file dependency format of the new /sourceDependencies xxx.json output in the vs preview version (this is more reliable and stable for multi-language header file dependency detection).

Introduction of New Features

Fortran language compilation support

Starting from this version, we have fully supported the use of the gfortran compiler to compile fortran projects, we can quickly create an empty project based on fortran by using the following command:

$ xmake create -l fortran -t console test
Enter fullscreen mode Exit fullscreen mode

Its xmake.lua content is as follows:

add_rules("mode.debug", "mode.release")

target("test")
    set_kind("binary")
    add_files("src/*.f90")
Enter fullscreen mode Exit fullscreen mode

More code examples can be viewed here: Fortran Examples

Zig language experimental support

Note: At present, this language xmake is still in the experimental support stage, and it is not perfect. For example, it is not supported on windows, and dynamic library compilation under linux/macOS is not yet supported. Please evaluate and use it yourself.

We can use the following configuration method to try and experience, at least the console and static library programs under linux/macOS can still run.

add_rules("mode.debug", "mode.release")

target("test")
    set_kind("binary")
    add_files("src/*.zig")
Enter fullscreen mode Exit fullscreen mode

As for why windows does not support it, please refer to the issues I mentioned to zig earlier, #5825

The dynamic library does not support it because I have some pitfalls (the dynamic library generated by zig will automatically append .0.0.0), see: issue 5827

In addition, I lay down in other pits. I personally feel that there are a lot of pits, so I'm still in the experimental stage for the time being, and I will look at it later.

For more examples, see: Zig Examples

Go dependency package and cross compilation support

The new version of xmake continues to make some improvements to the go build support, such as cross-compilation of go. For example, we can compile windows programs on macOS and linux:

$ xmake f -p windows -a x86
Enter fullscreen mode Exit fullscreen mode

In addition, the new version also initially supports the third-party dependency package management of go:

add_rules("mode.debug", "mode.release")

add_requires("go::github.com/sirupsen/logrus", {alias = "logrus"})
add_requires("go::golang.org/x/sys/internal/unsafeheader", {alias = "unsafeheader"})
if is_plat("windows") then
    add_requires("go::golang.org/x/sys/windows", {alias = "syshost"})
else
    add_requires("go::golang.org/x/sys/unix", {alias = "syshost"})
end

target("test")
    set_kind("binary")
    add_files("src/*.go")
    add_packages("logrus", "syshost", "unsafeheader")
Enter fullscreen mode Exit fullscreen mode

However, there are still some imperfections. For example, all cascading dependency packages must be manually configured at present, which will be a bit more cumbersome and needs to be improved in the future.

For more examples, see: Go Examples

Dlang/Dub dependency package support

xmake also supports dlang's dub package management, which can quickly integrate dlang's third-party dependency packages:


lua
add_rules("mode.debug", "mode.release")

add_requires("dub::log 0.4.3", {alias = "log"})
add_requires("dub::dateparser", {alias = "dateparser"})
add_requires("dub::emsi_containers", {alias = "emsi_containers"})
add_requires("dub::stdx-allocator", {alias = "stdx-allocator"})
add_requires("dub::mir-core", {alias = "mir-core"})

target("test")
    set_kind("binary")
    add_files("src/*.d")
    add_packages("log", "dateparser", "emsi_containers", "stdx-allocator", "mir-cor
Enter fullscreen mode Exit fullscreen mode

Top comments (0)