build: use cat instead of more

Message ID 20190401103551.28909-1-alialnu@mellanox.com (mailing list archive)
State Superseded, archived
Headers
Series build: use cat instead of more |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Ali Alnubani April 1, 2019, 10:36 a.m. UTC
  This is to fix a build error with meson that is caused
by using the 'more' command to read the VERSION file. The error:

    config/meson.build:10:10: ERROR:  String
    '::::::::::::::\n<RTE_SDK_PATH>VERSION\n::::::::::::::\n19' cannot be
    converted to int

The command 'more' prints the file name before the actual
contents of the file when it's being run without a controlling terminal.
This could happen in CI environments.

Please refer to:
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/text-utils/more.c

The cat command can still be found on Windows if the ports of GNU
utilities are installed.

Fixes: c04172b5f031 ("build: add single source of DPDK version number")
Fixes: d320fe56bd51 ("build: use version number from config file")

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
---
 meson.build | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Thomas Monjalon April 1, 2019, 11:24 a.m. UTC | #1
01/04/2019 12:36, Ali Alnubani:
> This is to fix a build error with meson that is caused
> by using the 'more' command to read the VERSION file. The error:
> 
>     config/meson.build:10:10: ERROR:  String
>     '::::::::::::::\n<RTE_SDK_PATH>VERSION\n::::::::::::::\n19' cannot be
>     converted to int
> 
> The command 'more' prints the file name before the actual
> contents of the file when it's being run without a controlling terminal.
> This could happen in CI environments.
> 
> Please refer to:
> https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/text-utils/more.c
> 
> The cat command can still be found on Windows if the ports of GNU
> utilities are installed.
> 
> Fixes: c04172b5f031 ("build: add single source of DPDK version number")
> Fixes: d320fe56bd51 ("build: use version number from config file")
> 
> Signed-off-by: Ali Alnubani <alialnu@mellanox.com>

Acked-by: Thomas Monjalon <thomas@monjalon.net>

It is fixing a regression on Linux.
I think we should take this fix urgently
and think about Windows in a next step.

"more" is an interactive command, we should not use it.
As suggested by Ali, we may require an extra dependency on Windows
to get some GNU utilities. Or if no other tools are required,
may we have a meson builtin to read a file?
  
Bruce Richardson April 1, 2019, 2:47 p.m. UTC | #2
On Mon, Apr 01, 2019 at 01:24:20PM +0200, Thomas Monjalon wrote:
> 01/04/2019 12:36, Ali Alnubani:
> > This is to fix a build error with meson that is caused
> > by using the 'more' command to read the VERSION file. The error:
> > 
> >     config/meson.build:10:10: ERROR:  String
> >     '::::::::::::::\n<RTE_SDK_PATH>VERSION\n::::::::::::::\n19' cannot be
> >     converted to int
> > 
> > The command 'more' prints the file name before the actual
> > contents of the file when it's being run without a controlling terminal.
> > This could happen in CI environments.
> > 
> > Please refer to:
> > https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/text-utils/more.c
> > 
> > The cat command can still be found on Windows if the ports of GNU
> > utilities are installed.
> > 
> > Fixes: c04172b5f031 ("build: add single source of DPDK version number")
> > Fixes: d320fe56bd51 ("build: use version number from config file")
> > 
> > Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
> 
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
> 
> It is fixing a regression on Linux.
> I think we should take this fix urgently
> and think about Windows in a next step.
> 
> "more" is an interactive command, we should not use it.
> As suggested by Ali, we may require an extra dependency on Windows
> to get some GNU utilities. Or if no other tools are required,
> may we have a meson builtin to read a file?
> 
Should not need to do so. May I suggest using "find_program" function
instead of hard-coding the command. That allows a list of programs to be
specified and the first one found is used. Unfortunately, on windows the
direct equivalent of "cat" is "type" which is a built-in rather than
command as far as I can see, so find_program doesn't work for it. However,
the following should do:

version: run_command(find_program('cat', 'more'), files('VERSION')).stdout().strip()
  

Patch

diff --git a/meson.build b/meson.build
index fa6bf3d07..55aa7c46d 100644
--- a/meson.build
+++ b/meson.build
@@ -3,8 +3,7 @@ 
 
 project('DPDK', 'C',
 	# Get version number from file.
-	# Use "more" rather than "cat" for windows compatibility.
-	version: run_command('more', files('VERSION')).stdout().strip(),
+	version: run_command('cat', files('VERSION')).stdout().strip(),
 	license: 'BSD',
 	default_options: ['buildtype=release', 'default_library=static'],
 	meson_version: '>= 0.47.1'