Xmake: A cross-platform build utility based on Lua

Posted by phmx 4 days ago

Counter85Comment35OpenOriginal

Comments

Comment by Rochus 36 minutes ago

This is an interesting system that I studied closely a few years ago, along with a few others based on Lua or Python.

What surprises me enormously about all these systems is the fact that, in builds that can become enormously large and complex systems in themselves, we voluntarily forego most of the advantages we have learned over sixty years of software engineering. I am thinking, for example, of strong typing and type checking by the compiler, which then also enables better support from IDEs and analysis or visualization tools.

It's kind of like other scripting languages. For small applications, it all looks practical and efficient, but woe betide it if it becomes as big as Qt or other systems with several hundred thousand lines of code.

Comment by MobiusHorizons 11 hours ago

I think a syntax example on the homepage would be a good idea. Also comparison charts for things like cmake, ninja, meson, and bazel. If you have a dependency finding strategy, highlight the pros and cons of that. Basically the only reason states for why I should use this is lua, and that’s not inherently compelling to me for build tooling.

Comment by lazypenguin 6 hours ago

A teammate evaluated this and the experience was night and day compared to cmake + vcpkg. However, there wasn’t a lot of motivation to cutover our existing large project over because of the unknown unknowns. I think projects like these looking to dethrone the status quo definitely need some case studies or examples of larger projects using it to increase confidence because I’d much rather use xmake over cmake if it can get the job done

Comment by warmwaffles 3 hours ago

I use it for personal projects and I find it substantially easier to mess around with compiling shaders to SPIRV, processing assets, etc... But some of my gripes are, although it _is_ lua, there is some magic fuckery going on. When you specify targets, things for that target need to be close to the definition, and it feels very odd in a lua language to not have `target("name", function (ctx) ... end)`.

Anyways, not going to die on that hill and I'll keep using it because it's simple and works well for my needs. One thing I do like is that I am not having to constantly keep a skeleton CMake project around to copy paste and setup.

Comment by danny0z 3 hours ago

> not have `target("name", function (ctx) ... end)`.

It supports this syntax.

https://xmake.io/guide/project-configuration/syntax-descript...

  target("foo", function ()
      set_kind("binary")
      add_files("src/*.cpp")
      add_defines("FOO")
  end)

Comment by numeromancer 1 hour ago

I think the creators did it a disservice to xmake when they tried to unluaize the syntax. You can also do:

    target("foo", {
      kind = "binary",
      files = { "src/*.cpp" },
      includedirs = { "src" },
      defines = { "FOO", "BAR=BAZ" },
    })
which suits Lua better. Unfortunately you cannot do

    target {
      name = "foo",
      kind = "binary",
      files = { "src/*.cpp" },
      includedirs = { "src" },
      defines = { "FOO", "BAR=BAZ" },
    }
which would be the lua-est lua of all.

Comment by danny0z 1 hour ago

It also supports this syntax.

    target("foo", {
      kind = "binary",
      files = { "src/*.cpp" },
      includedirs = { "src" },
      defines = { "FOO", "BAR=BAZ" },
    })
https://xmake.io/guide/project-configuration/syntax-descript...

Comment by numeromancer 1 hour ago

That's what I meant: the first you can do, the second, not.

Comment by warmwaffles 2 hours ago

I did not spot those in the docs. Thanks a ton. This will help my autoformatter not completely wreck my files.

Comment by skavi 9 hours ago

Just yesterday someone was telling me xmake does a lot of what bazel can do (hermetic, deterministic, optionally remote builds) while being easier to use.

I took a look at the docs later and couldn’t find a direct comparison. But there does seem to be a remote build system. And there were a few mentions of sandboxing.

Can anyone provide a head to head comparison?

Does xmake strictly enforce declared dependencies? Do actions run in their own sandboxes?

Can you define a target whose dependency tree is multi language, multi toolchain, multi target platform and which is built across multiple remote execution servers?

Comment by rienbdj 7 hours ago

Can anyone explain xmake in terms of Build Systems a la Carte?

Comment by richrichardsson 8 hours ago

I apologise for this:

What's wrong with premake which is also Lua based?

when I meant:

What advantage does this have over premake which is also Lua based?

Comment by fsw 7 hours ago

For one, the last official stable release of premake is from 2010.

Comment by rienbdj 8 hours ago

What’s wrong with xmake which is also Lua based?

Comment by gjvc 7 hours ago

Comment by richrichardsson 7 hours ago

I honestly didn't mean it like that, but I can understand that it comes across that way.

A better wording would be "what advantage does this have over premake which is also Lua based".

Comment by nottorp 5 hours ago

Tbh, why does it matter what it's written in? Does it do the job?

Comment by MobiusHorizons 3 hours ago

Lua is the syntax in the build configuration file, not how the tool is implemented internally. It’s part of the developer experience.

Comment by einpoklum 1 hour ago

So, digging through the website git repo a bit, some basic facts:

* The project started almost 11 years ago, in 2015.

* It can be both a build-system generator like CMake, or a 'builder' like Make or ninja.

* Code is almost exclusively by one person, waruqi: https://github.com/waruqi , with several other people making a few contribution.

* Prima facie, the API seems to be less flexible/rich than CMake's, but I'm not sure.

* It supports quite a few languages, despite saying "C/C++" on the website.

* It has a built-in REPL.

As @MobiusHorizons points out, a comparison with other build system generators would be appropriate, mostly CMake, but I did not find it.

Comment by wsve 11 hours ago

At my work we use MSBuild and vcpkg. What would a transition from that to XMake be like?

Comment by janjones 10 hours ago

Then you are already using XMake (albeit a different one than OP), it's the original codename for MSBuild, still present in the code: https://github.com/dotnet/msbuild/blob/main/src/MSBuild/XMak... :)

Comment by debugnik 9 hours ago

Your phrasing could confuse readers: MSBuild happened to historically have XMake as a codename but is entirely unrelated to the build system known as XMake.

Comment by janjones 9 hours ago

Clarified my comment a bit, thanks

Comment by 9 hours ago

Comment by pjmlp 9 hours ago

As far as I am aware, there no integrations available with Visual Studio, and not sure about C++20 modules and import std support.

Comment by danny0z 8 hours ago

It can generate a Visual Studio project, then use the xmake CLI to integrate and compile the project, and supports debugging and IntelliSense.

https://xmake.io/guide/extensions/builtin-plugins.html#gener...

C++ Modules examples:

https://xmake.io/examples/cpp/cxx-modules.html

https://github.com/xmake-io/xmake/tree/dev/tests/projects/c%...

Comment by pjmlp 5 hours ago

Thanks for the information.

Comment by ziotom78 3 hours ago

A few weeks ago I decided to test C++ modules, but I had a hard time to figure out how to make them accepted by CMake. After a few days of struggle with `set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")` (it was so hard to find the right UUID that worked with my version) and errors on `import std;`, I decided to give XMake a chance.

It took just a couple of minutes to have a working example that fully supported C++ modules and `import std`:

    set_languages("c++23")

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

    target("mytest")
        set_kind("static")
        add_files("src/*.cpp")
        add_files("src/*.cppm", {public = true})
        set_policy("build.c++.modules", true)

Comment by delta_p_delta_x 9 hours ago

> not sure about C++20 modules and import std support

XMake supports both.

Comment by IshKebab 10 hours ago

My work uses this and it's slooooooow. Would not recommend.

Comment by elitepleb 9 hours ago

the command file generator is usually last to blame for a slow compile, making it output a cmake/ninja/make project would not speed up a poorly structured compilation tree at all

Comment by junon 9 hours ago

I don't believe xmake is a command file generator, is it?

Comment by elitepleb 9 hours ago

it has a feature to output such files, see https://github.com/xmake-io/xmake?tab=readme-ov-file#generat...

Comment by willaaaaaaa 7 hours ago

is that so? my experience's quite good

Comment by rhet0rica 4 hours ago

I am deeply distressed that this doesn't require Xlib.

Comment by nvlled 1 hour ago

Why? I'm so confused why would you expect a build tool to depend on a x11 client library, besides the fact that both starts with the letter x. Does it also upset you that xamarin and xaml has nothing to do with xlib, xmake, or to each other?

Comment by roman_soldier 9 hours ago

[dead]