2 ms·
>project('tutorial', 'c') >gtkdep = dependency('gtk+-3.0') >executable('demo', 'main.c', dependencies : gtkdep) This is a snippet from meson tutorial, and that
by wruza 6y ago
>project('tutorial', 'c')
>gtkdep = dependency('gtk+-3.0')
>executable('demo', 'main.c', dependencies : gtkdep)
This is a snippet from meson tutorial, and that’s why I’m still using make (and not cmake) in all my personal C projects. I have no idea what flags will be passed to gcc and how to change them (-mmsbitfields was required on windows for gtk). Second, I may have no pkg-config environment when I link windows executable against msys2-installed libs in plain cmd. These shorthands may be a long-term win for a regular project in strict unixlike or msvc-env.bat, but it is not a build system. It is a fixed recipe book (as seen from the tutorial page, don’t take it as a criticism). It substitutes a simple knowledge on -I, -L and -l with a cryptic set of directives. You spoke gcc very good, now you have to speak meson’s local dialect and be able to catch and fix subtle errors in translation.
The problem is, one has to investigate into seemingly-easy build system to tune it to their needs. It is much harder than just fixing CFLAGS+= or LDFLAGS+= in a Makefile.
For me, a better build system would look like a set of rules, but not in a Makefile, but in a general-purpose language, like:
var all_srcs = qw('a.c b.c')
if_(files_changed(all_srcs)).do_(changed_srcs => {
changed_srcs.forEach(src => compile(src))
})
fn compile(src) {
exec('gcc', CFLAGS, '-o', to_o(src), src)
}
if_...
This simple process would cover 99% of common cases and you’re still in control of everything. Just prepend:
if (os == 'msys2') {
CFLAGS += ' ...'
}
And that’s it. It is a long-term usability, because you may open this file a year later and still figure out what needs to be done in few seconds.
- wwright 6y agoI'd recommend you take a look at how Bazel works (Meson may be similar if you look further, but I haven't used it much myself). The default interface you get is relatively "high-level", but everything behind the scenes is a general-purpose system like what you describe, and you can customize it pretty deeply. What makes it really great IMO is that the language and tool are designed for best practices. For example, your scripts can't actually execute anything: they can tell the build system what command would be used to build the file and what the dependencies would be. The sandboxing allows the build system to be pretty hermetic without much effort. This means that it can always parallelize your build, and incremental builds are always fast and correct.