OS: Windows 10 64-bit
Environment: MSYS2/MinGW-w64 Meson version: 1.0.1 Geany source: f0e3ee273e67387f85506ea629b9dbe34d47b8ca
Trying to build the Geany source code, meson complains "meson.build:440:9: ERROR: The `==` operator of bool does not accept objects of type int (1)". I am wondering if it is a bug in my meson build as I did not have this issue compiling a recent commit on Linux, and no changes have been made to `meson.build` between that build and this one.
Attached is meson log: [meson-log.txt](https://github.com/geany/geany/files/11047944/meson-log.txt)
Meson has made an incompatible change at [0.60](https://mesonbuild.com/Release-notes-for-0-60-0.html#comparing-two-objects-w...) so can't compare bool and int. And since `cdata.get()` returns no change is needed any more, so your suggested change is fine, care to make a PR?
Won't that break backward compatibility?
I'm not a great expert on meson, but I can't see where `cdata.get()` would have returned other than bool, but if you can find it between about 0.54 (Ubuntu 20.04 LTS IIRC) then yeah that will be a problem.
Oh, okay. I understand what you are saying. Sure, I will make a PR.
Done.
Our CI runs Meson 0.53 so if there is a backward compatibility problem it will show up on the PR hopefully.
Oh dear!!!!
I wonder what version that changed on, I didn't notice it in release notes but might have missed it.
"If clause 1 does not evaluate to true or false". I guess `cdata.get()` does return int in older versions.
Yeah, that was the "Oh dear" :(
Perhaps it's possible meson version can be checked within `meson.build`?
Probably, and those compares will need to be guarded pre/post 0.60.
`meson.version()` but its a string, so value comparisons might be difficult
Oh! I was *just* looking at meson's docs. I think there is a `version_compare` method.
https://mesonbuild.com/Syntax.html#version_compare
Neat
I'll test it out and update the PR.
Thanks, sorry for the ytpos and edits above, I'm on a tablet with screen keyboard and no Geany access.
meson support is still experimental. I would be OK to only support version 0.60+.
meson support is still experimental. I would be OK to only support version 0.60+.
Well, that would make my life easier. 🙂 Meson seems like a nice build system, but I'm struggling finding when the change happened. And it doesn't appear that variables can be type checked.
Want me to update the workflow to build on Jammy and add it to my pull request? https://packages.ubuntu.com/search?keywords=meson&searchon=names&sui...
Package version says `0.61.2`.
Want me to update the workflow to build on Jammy and add it to my pull request.
Done.
Fixed workflow run by changing Ubuntu version from `22.04.2` to `22.04`. But, now Meson reports this error: ``` meson.build:440:9: ERROR: Object <[IntegerHolder] holds [int]: 1> of type int does not support the `bool()` operator. ```
So it appears meson version somewhere newer than `0.61.2` is required.
Based on the bug report submitted to meson, I've analyzed the geany build.
The problem is here: https://github.com/geany/geany/blob/f0e3ee273e67387f85506ea629b9dbe34d47b8ca...
All `HAVE_` cdatas are defined to be either integer 1 or boolean false. This means it's impossible to refer back to them.
The purpose of the cdata is to generate config.h, so the consequence of this looks like this:
meson.build: ```meson cdata.set('HAVE_BOOL', true) cdata.set('HAVE_NO_BOOL', false) cdata.set('HAVE_INT', 1) cdata.set('HAVE_NO_INT', 0) ``` produced config.h: ```h #define HAVE_BOOL
#define HAVE_INT 1
#undef HAVE_NO_BOOL
#define HAVE_NO_INT 0 ```
The logic you are using assumes that if you have a feature, the code is using `#if HAVE_THING` and the value must be 1, defining it without setting a value is not sufficient. Conversely, that if you don't have a feature, the code is using `#ifdef HAVE_THING` and the value is irrelevant, so setting the value to 0 would erroneously report the feature as available.
These states can't both be true, though... it is either or. Alternatively, it could be "either or, but on a per define basis".
However, grepping through the codebase quickly I can only find cases where `#ifdef` / `#if defined()` are used, plus scintilla/gtk/ScintillaGTKAccessible.cxx which is only using its own defines set at the top of that file. Can you just use true instead of 1?
...
Unfortunately, doing a version check will not accomplish anything whatsoever, the value isn't different depending on the version of meson -- the value is different depending on what headers and functions your system has.
Thank you. That clears things up for me.
Going to close the PR. I will open a new one with the recommendation by @eli-schwartz when I get a chance.
@eli-schwartz thanks for that, yeah, looks like all should be true/false.
I guess the intention was to replicate the olde timey idiom of not defining `THING` or `#define THING 1` if it was defined.
As you say most of the actual tests just look for "defined" and don't care what value, so hopefully true/false will work just fine.
github-comments@lists.geany.org