Add information about command path and version of flex in meson output

Started by Michael Paquieralmost 3 years ago5 messages
#1Michael Paquier
michael@paquier.xyz
1 attachment(s)

Hi all,

While doing a few things on Windows with meson, I have noticed that,
while we output some information related to bison after a setup step,
there is nothing about flex.

I think that adding something about flex in the "Programs" section
would be pretty useful, particularly for Windows as the command used
could be "flex" as much as "win_flex.exe".

Attached is a patch to show the path to the flex command used, as well
as its version.

Opinions or thoughts?
--
Michael

Attachments:

meson-flex-info.patchtext/x-diff; charset=us-asciiDownload
diff --git a/meson.build b/meson.build
index b69aaddb1f..3615b861c5 100644
--- a/meson.build
+++ b/meson.build
@@ -361,6 +361,10 @@ bison_kw = {
 }
 
 flex_flags = []
+if flex.found()
+  flex_version = run_command(flex, '--version', check: true)
+  flex_version = flex_version.stdout().split(' ')[1].split('\n')[0]
+endif
 flex_wrapper = files('src/tools/pgflex')
 flex_cmd = [python, flex_wrapper,
   '--builddir', '@BUILD_ROOT@',
@@ -3350,6 +3354,7 @@ if meson.version().version_compare('>=0.57')
     {
       'bison': '@0@ @1@'.format(bison.full_path(), bison_version),
       'dtrace': dtrace,
+      'flex': '@0@ @1@'.format(flex.full_path(), flex_version),
     },
     section: 'Programs',
   )
#2Peter Eisentraut
peter@eisentraut.org
In reply to: Michael Paquier (#1)
Re: Add information about command path and version of flex in meson output

On 11.04.23 07:58, Michael Paquier wrote:

While doing a few things on Windows with meson, I have noticed that,
while we output some information related to bison after a setup step,
there is nothing about flex.

I think that adding something about flex in the "Programs" section
would be pretty useful, particularly for Windows as the command used
could be "flex" as much as "win_flex.exe".

I think this would be useful.

+  flex_version = run_command(flex, '--version', check: true)
+  flex_version = flex_version.stdout().split(' ')[1].split('\n')[0]

Maybe this could be combined into one command?

Looks good otherwise.

#3Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#2)
1 attachment(s)
Re: Add information about command path and version of flex in meson output

On Mon, Jul 03, 2023 at 08:34:39AM +0200, Peter Eisentraut wrote:

Maybe this could be combined into one command?

On clarity ground, I am not sure that combining both is a good idea.
Perhaps the use of a different variable, like bison a few lines above,
makes things cleaner?

Looks good otherwise.

Thanks for the review.
--
Michael

Attachments:

meson-flex-info-v2.patchtext/x-diff; charset=us-asciiDownload
diff --git a/meson.build b/meson.build
index aaa9daf266..3ea4b0d72a 100644
--- a/meson.build
+++ b/meson.build
@@ -361,6 +361,10 @@ bison_kw = {
 }
 
 flex_flags = []
+if flex.found()
+  flex_version_c = run_command(flex, '--version', check: true)
+  flex_version = flex_version_c.stdout().split(' ')[1].split('\n')[0]
+endif
 flex_wrapper = files('src/tools/pgflex')
 flex_cmd = [python, flex_wrapper,
   '--builddir', '@BUILD_ROOT@',
@@ -3370,6 +3374,7 @@ if meson.version().version_compare('>=0.57')
     {
       'bison': '@0@ @1@'.format(bison.full_path(), bison_version),
       'dtrace': dtrace,
+      'flex': '@0@ @1@'.format(flex.full_path(), flex_version),
     },
     section: 'Programs',
   )
#4Peter Eisentraut
peter@eisentraut.org
In reply to: Michael Paquier (#3)
Re: Add information about command path and version of flex in meson output

On 03.07.23 09:30, Michael Paquier wrote:

On Mon, Jul 03, 2023 at 08:34:39AM +0200, Peter Eisentraut wrote:

Maybe this could be combined into one command?

On clarity ground, I am not sure that combining both is a good idea.
Perhaps the use of a different variable, like bison a few lines above,
makes things cleaner?

Yes, if you want two separate lines, then doing it like bison makes sense.

#5Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#4)
Re: Add information about command path and version of flex in meson output

On Mon, Jul 03, 2023 at 10:17:40AM +0200, Peter Eisentraut wrote:

Yes, if you want two separate lines, then doing it like bison makes sense.

Okay, I have applied v2 that uses two separate lines and two separate
variables, then, to be like bison.
--
Michael