14 ms·
Show HN: Xmake, a modern C/C++ build utility
- honey1988 8y agoGreat!
- Iwan-Zotow 8y agocmake is NOT a build utility. It is dependency tracking and configuration utility
- sigzero 8y ago"CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice." They would disagree with you.
- Iwan-Zotow 8y agono, they won't "generate native makefiles" (I prefer Ninja myself) - this is what used to build software
- joshuamorton 8y agoLeveraging compositional abstraction doesn't change what you use the thing for. I use cmake (well I don't often, but when I do) to build my projects. How it accomplishes that is if little concern.
- Iwan-Zotow 8y ago> I use cmake (well I don't often, but when I do) to build my projects. no, you don't remove from your system make (ninja, msbuild, ...) and see how cmake builds your project
- joshuamorton 8y ago>see how cmake builds your project Yes exactly when you remove a piece of the build system the build system stops working. When I use bazel I need python installed or it doesn't work. That doesn't mean my build system is python. It means my build system takes advantage of python. Same for cmake and make.
- Iwan-Zotow 8y agoI'm sorry but make is not part of cmake build system. It predates cmake by decades. It is true build system used in by itself
- joshuamorton 8y agoYes. Make is a build system. Cmake is also a build system that leverages make. This means that from the perspective of a user of cmake, make is a component/dependency/part of cmake. make can be used independently, and is absolutely developed independently, of cmake. But when you remove a dependency of a tool you can expect the tool to stop working. That doesn't mean that the tool doesn't do what it says it does.
- geezerjay 8y agoCmake is a makefile generator. The output of cmake is a series of makefiles. That's it. If you need to build a project and you don't have make, nmake, jmake or whatevermake in your system them cmake does nothing to get your project built.
- kstenerud 8y agoCMake can generate: * Borland Makefiles * MSYS Makefiles * MinGW Makefiles * NMake Makefiles * Unix Makefiles * Watcom WMake * Ninja * Visual Studio projects * Green Hills MULTI * Xcode projects And more: https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html https://cmake.org/cmake/help/latest/manual/cmake-generators....
- waruqi 8y agoBut it still depends on third-party IDE or build tools. It will be limited by their own features. There are still many differences in the behavior of different IDEs.
- geezerjay 8y ago> CMake can generate: Although you're conflating project transcoders with makefiles, nevertheless that's the whole point of cmake: generate makefiles that are used by some third-party program to actually build the software.
- pooya13 8y agoBoth CMake and Make are tools for building binaries just on different levels of abstraction. You wouldn’t say someone didn’t make you coffee if they use a coffee maker!
- waruqi 8y agoYes, xmake is more similar to scons, not cmake.
- unrealhoang 8y agoNow we have N+1 incompatibile build systems.
- mhh__ 8y agoUntil you eventually you have n-k fit for purpose build systems. Having competing standards isn't always a bad thing e.g. if they do slightly different jobs
- seanballais 8y agoWhat does k mean?
- waruqi 8y agoIf the existing tools are really good enough to meet all user needs, there will be no N+1 build systems.
- flukus 8y agoI think half those N's are cmake itself considering the amount of time I see "requires cmake x.x or above" messages. I wouldn't find having many build system such an issue if they'd just add a makefile (and maybe ./configure) to call that build system, giving devs a consistent interface and not having to lookup up how to do a simple build.
- geezerjay 8y ago> if they'd just add a makefile (and maybe ./configure) That's the whole point of cmake. Instead of running autotool's ./configure (which in fact is a whole dance involving autoconf, autoreconf, automake, and whatnot) just run cmake . to get yourself a fancy makefile.
- RcouF1uZ4gsC 8y agoFor better or worse though, CMake has won! Many IDE's including Visual Studio can directly work with CMake files. In addition, even Google which is famous for doing things their own way, has now added official, first-class CMake support to their open source C++ library Abseil https://abseil.io/blog/20190402-cmake-support https://abseil.io/blog/20190402-cmake-support If you are writing an open source C++ library, even if you support some other C++ build system, chances are you will also have CMake support as well. While I have no doubt, xmake is easier to use than CMake (just having Lua over CMake's abomination of a language is a great improvement), the fact that so many libraries and tools already support CMake is going to make adoption an uphill battle.
- kevin_thibedeau 8y agoNow we just need a better DSL that can generate Cmake files.
- usrnm 8y agoAnd CMake itself started as a simple DSL for generating Makefiles. We've gone full circle
- geezerjay 8y agoCMake is still a DSL for generating makefiles.
- YayamiOmate 8y agoYea, but what it's not is simple. Imho dealing with dependencies and making project build in one shot is hard in cmake. Maybe I did things wrong though.
- geezerjay 8y ago> Yea, but what it's not is simple. That really depends on what you're trying to do. Cmake's happy path for building an executable that depends only on libraries that already support cmake is very straight-forward.
- euyyn 8y agoDoes it produce hermetic builds?
- waruqi 8y agoWhat's hermetic builds?
- tele_ski 8y agoHermetic Builds. ... Our builds are hermetic, meaning that they are insensitive to the libraries and other software installed on the build machine. Instead, builds depend on known versions of build tools, such as compilers, and dependencies, such as libraries. Kind of like a container for building? I had to look it up myself.
- waruqi 8y agoGot it, xmake is hermetic Builds. It does not rely on any third-party tools, nor does it rely on make. Unless remote dependencies are used, this is optional.
- shaklee3 8y agoHow would it do that besides building in a container?
- joshuamorton 8y agoLook into bazel, pants, and similar hermetic build systems. You pin all dependencies and manage flags and such but via the build system.
- pfranz 8y agoI don't know if this is what the parent was intending (I'm curious to see other examples), but depending on your definition Nix (nixos.org) seems to fit that need.
- otabdeveloper1 8y ago
- waruqi 8y agoOne of the purposes of xmake is to solve the problem of C/C++ dependency packages.
- waruqi 8y agoHere is an official dependency package repository for xmake. https://github.com/xmake-io/xmake-repo https://github.com/xmake-io/xmake-repo
- 2bluesc 8y agoMeson[0] has been gaining in popularity and has migration tools for cmake projects. Large projects such as systemd and gnome[1] have migrated or have been migrating for years [0] https://mesonbuild.com/ https://mesonbuild.com/ [1] https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting
- waruqi 8y agoBut the meson installation has many dependencies, it is not very lightweight, it needs python, ninja, and xmake has built-in luajit, no third-party dependencies, more lightweight
- shaklee3 8y agoPython is preinstalled on any major Linux distro. Ninja is tiny, so those don't seem that heavyweight.
- waruqi 8y agoPython also has version compatibility issues, such as: python2.x, 3.x. Also need the user to install the specified version of python
- pfranz 8y agoAny new project will very, very likely be using Python3. It appears like that applies to meson. `python3` is the expected binary (`python` is still expected to point to Python 2 for the foreseeable future and `python2` being the explicit binary--some distros have jumped the gun on `python`). Similarly, they have completely different accompanies executables (pip3, wheel3, pydoc3) and completely separate library paths. What sort of compatibility issues have you seen? The requirements say Python 3.5 or newer. That was released in 2015. Outside of major versions, Python has generally been forwards compatible (especially if you're testing). After more than a decade of use, the only grumbles with supporting old Python version is not getting to use new features (or working around fixed bugs). I say this as someone who still uses Python 2 every day.
- kayamon 8y agoDon’t ever install software by piping arbitrary remote scripts into bash.
- bluejekyll 8y agoAssuming the script is hosted on an https site, is a popular tool (like brew or rustup) from a trusted source, why would this be any more dangerous than downloading and installing from a a package manager? What would it take beyond https and a well-known site to make you comfortable doing this?
- flukus 8y ago> why would this be any more dangerous than downloading and installing from a a package manager? Normally the packager and developer are different people so there is a second set of eyes to at least give a cursory glance to the changes. It takes more than a single compromised account to publish malicious changes. There are of course a million exceptions and caveats to this and it's not perfect, but it's better than allowing developers to push code directly.
- adev_ 8y ago> Assuming the script is hosted on an https site, is a popular tool (like brew or rustup) from a trusted source, why would this be any more dangerous than downloading and installing from a a package manager? Most package manager use an offline signature mechanism done at build time (rpm, dpkg, nix) and do not rely on HTTPS security for anything else than eyes-dropping reasons. Relying purely on HTTPS is insecure. Nothing guarantee you that your source / script / package did not get hacked / modified between the time you uploaded it and the time your user downloaded it. This is not hypothetical scenario, it already happened in the past with sites like sourceforge.
- hollerith 8y agoUnless you read and thoroughly understand the script first.
- 8y ago
- Game_Ender 8y agoDoes it have any distributed build or caching support? That is my minimum bar for a C++ build system. ccache and distcc/icecc are too limited, you want something integrated with your build system directly.
- waruqi 8y agoDistributed builds are being planned, but not yet implemented. You can see https://github.com/xmake-io/xmake/issues/274 https://github.com/xmake-io/xmake/issues/274
- je42 8y agommh. cflags and cxxflags are command line options ? i would expect them to be defined as part of build file.
- waruqi 8y agoYou can also define them in build file (xmake.lua) target("test") set_kind("binary") add_files("src/*.c", "src/*.cpp") add_cflags("-fPIC", "-Dxxx") add_cxxflags("-fPIC", "-Dxxx") The command line arguments just give you a quick and easy way to modify cflags.
- geezerjay 8y agoNot even that. Compiler flags are compiler/platform/library options, naturally, as build options need to be propagated from dependencies. The people behind cmake already learned that lesson with their modern cmake approach, but it seems the xmake people didn't do a proper review of the state of the art.
- fxfan 8y agoThis looks thoughtfully created (and so documented!). I haven't gone through the entire doc and am not particularly clear but can you cross-build too? How would you run MSVC linker on Linux?
- waruqi 8y agoSupport cross-build, but you need install mingw for linux, if you want to build win32 program on linux. You can see https://xmake.io/#/home?id=cross-compilation https://xmake.io/#/home?id=cross-compilation and https://xmake.io/#/home?id=mingw https://xmake.io/#/home?id=mingw
- intea 8y agoIm not a fan of LUA. The syntax of XMake.lua reads somewhat like CMake but easier to understand. What I'd really like to see is a build system in Python (3!) utilizing objects and dictionaries for tasks like this should be a breeze.
- nomadluap 8y agoJust out of curiosity, what parts of lua do you not care for?
- intea 8y agoProbably just bad experiences with it in the past and the lacking IDEs. e.g. PyCharm makes writing Python a breeze.
- robmccoll 8y agoDo you consider waf to meet that criteria? https://gitlab.com/ita1024/waf https://gitlab.com/ita1024/waf https://waf.io https://waf.io Or scons? https://scons.org https://scons.org
- intea 8y agoI'll check it out, thanks.
- jcranberry 8y agoDoes waf still force you to be c++11/14?
- peterownen2 8y agoI really love it! When did you start the project?
- _pmf_ 8y agoWhat rubs me the wrong way is that a lot of build systems have a fatal combination of unfamiliar syntax and complete lack of debuggability. Conan and Meson seem so much better in that regard.
- geezerjay 8y agoConan is orthogonal to the choice of build system, as in fact Conan's main choice of build system is cmake.
- deleted 8y ago[deleted]
- claudius 8y agoWhat I miss about these tools is some "relatively" straightforward dependency detection and generation. That is, I have a bunch of .cpp files which need to be compiled into individual executables in a folder bin/. I also have a folder inc/ which contains some headers (.h) and those headers possibly also have some associated TU (.cpp). Now g++ can already generate a dependency graph of headers for an executable. It is then (with a standard Makefile and some supporting bash scripts) quite straightforward to mangle that graph into a list of translation units (namely those files whose name matches a depended-on header) which must be compiled and linked into the executable. That is, I can simply create a new "executable file" .cpp file in bin/, include some headers therein and when I say make, the Makefile automagically figures out which (internal) dependencies it needs to link in when linking the executable. Now that I have these "relatively straightforward" scripts and the corresponding Makefile, the incentive to move to another (nicer) build system which would require me to rebuild this infrastructure to fit into this other build system's view of the world is quite low – unless there is some way to do this directly? Xmake as shown here (and also Meson linked in a sister comment) appear to still require manual selection of dependencies.
- geezerjay 8y agoThere's no way to achieve that with today's standard C++ as it requires metadata to access/infer package version numbers. This will hopefully change with the introduction of C++ modules in C++20 but until them the best option available to C++ programmers is either manually managing third-party libraries or employing dependency management tools such as Conan.
- claudius 8y agoThis is for internal dependencies of a project and indeed outside the scope of the standard which does not say that if a function is declared in file abc.h then it is defined in file abc.cpp and that this file is compiled into an object file abc.o which then must be linked during linking of any file which includes abc.h. However, just because it is (like most build system questions) outside the scope of the standard does not mean that it isn’t possible to define some project-internal rules about what gets compiled and linked into what and that the build system cannot apply those rules to take work away from users. The few external dependencies my project has are installed semiautomatically before any compilation starts.
- biofgg 8y agoFeels really interesting, too bad It has THE code of conduct. I don't support, distribute, endorse, use, and give any kind of publicity to projects using it. inb4: "what's wrong with being decent/nice/inclusive?" it's not about that. The CoC should be neutered with something like including protection for political views, or explicitly putting social media out of the project spaces.
- soapdog 8y agoa developer post a well rounded tool with documentation that was built with a lot of care. The comment thread is mostly about other tools or people dismissing the work done because another available offer is more popular or common. When did "Show HN" threads became shark tank? Can people at least check and post about the tool itself instead of discussing CMake vs Ninja vs Meson?
- fnord123 8y ago>When did "Show HN" threads became shark tank? From the 2007 announcement of Dropbox: https://news.ycombinator.com/item?id=8863 https://news.ycombinator.com/item?id=8863 """ 1. For a Linux user, you can already build such a system yourself quite trivially by getting an FTP account, mounting it locally with curlftpfs, and then using SVN or CVS on the mounted filesystem. From Windows or Mac, this FTP account could be accessed through built-in software. """
- DataWorker 8y agoDoes anybody actually use Dropbox anymore? Feel like it’s a dead product.
- vernie 8y agoDead meaning what, stable? I still use Dropbox on a daily basis and Paper is now my go-to for note-taking.
- Crinus 8y agoI used to, until they blocked the public folder. The sync between my computers was nice, but for me the big feature was copy/pasting (or directly creating) an image or static html page(s) with images (or flash files, at some point) in the public folder, right clicking in Explorer/Finder (depending on the OS i used at the time), copying the URL and pasting it on IRC/IM/Reddit/whatever when discussing stuff. They tried to sell their 'get public URL' wrappers as the replacement for the functionality, but that only covered a tiny aspect (and OneDrive, Google Drive, etc already offered that stuff) - sharing photos - and even that was slower due to them wrapping the files in some sort of viewer instead of giving the raw file data like the public folder did, while using some sort of hash ID to identify the file instead of the actual filename (this was another convenience lost since with the public folder i could guess the URL to share without copy/pasting). I never found anything as convenient as Dropbox's public folder while the rest of their offering wasn't anything i cared much about and even then by that time both Google and Microsoft's offers were better (and with Microsoft's available right out of the box in Windows).
- ensiferum 8y agoWow. Great use of time. Build the 4363th (shitty) build tool. I wish people used the effort in the inverse direction, i.e. finding ways to nuke some of the (shitty) build tools and consolidate efforts into building just one that would just work. If there's a compelling need to write a new build system, I'd like it to have the following features: - If I use C++xy features in my code then automatically (suggest to) turn on the -std=xy flag. - If I include a header in my source tree automatically figure out the include path as much as possible. if failing then as the user and/or confirm - Automatically figure out the linker paths as much as possible, if failing then ask the user and/or confirm. Basically I'd like to have a build tool that would just figure things out by itself as much as possible when given a source tree. So far every single build tool just repeats the same fundamental problems of the user having to program it somehow to deal with all these minute details that are not super interesting.
- godman_8 8y agoIt has an emoji in the title...I'm sold.
- waruqi 8y agoWe can see an example about xmake.lua https://github.com/tboox/tbox/blob/master/src/tbox/xmake.lua https://github.com/tboox/tbox/blob/master/src/tbox/xmake.lua
- jhauris 8y agoThis is really great work, great documentation. It looks like CMake, but with a full featured scripting language.
- waruqi 8y agothanks!
- phaedrus 8y agoI wish CLion supported this as an alternative to CMake for project definitions!
- waruqi 8y agoYou can try clion/idea plugin for xmake. https://github.com/xmake-io/xmake-idea https://github.com/xmake-io/xmake-idea
- caikelun 8y agogreat!!