[1/2] build: add extra cflags ldflags to meson option

Message ID 7812af2267017898332783e934bef9478814ae96.1535361299.git.nelio.laranjeiro@6wind.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers
Series [1/2] build: add extra cflags ldflags to meson option |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Nélio Laranjeiro Aug. 27, 2018, 11:10 a.m. UTC
  Almost equivalent to the make system build which uses those options
through environment variables (EXTRA_{CFLAGS,LDFLAGS}).

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/meson.build | 2 +-
 meson_options.txt   | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
  

Comments

Bruce Richardson Aug. 27, 2018, 11:24 a.m. UTC | #1
On Mon, Aug 27, 2018 at 01:10:52PM +0200, Nelio Laranjeiro wrote:
> Almost equivalent to the make system build which uses those options
> through environment variables (EXTRA_{CFLAGS,LDFLAGS}).
> 
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> ---
>  drivers/meson.build | 2 +-
>  meson_options.txt   | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/meson.build b/drivers/meson.build
> index f94e2fe67..008aac62c 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -11,7 +11,7 @@ driver_classes = ['common',
>  	       'event',   # depends on common, bus, mempool and net.
>  	       'raw']     # depends on common, bus, mempool, net and event.
>  
> -default_cflags = machine_args
> +default_cflags = machine_args + [get_option('extra_cflags'), get_option('extra_ldflags')]
>  if cc.has_argument('-Wno-format-truncation')
>  	default_cflags += '-Wno-format-truncation'
>  endif
> diff --git a/meson_options.txt b/meson_options.txt
> index c84327858..da6373a2c 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -22,3 +22,5 @@ option('use_hpet', type: 'boolean', value: false,
>  	description: 'use HPET timer in EAL')
>  option('tests', type: 'boolean', value: true,
>  	description: 'build unit tests')
> +option('extra_cflags', type: 'string', description: 'Extra compiler flags')
> +option('extra_ldflags', type: 'string', description: 'Extra linker flags')

This should not be needed. Meson should pick up CFLAGS and LDFLAGS from the
environment without having to add options for them.

https://mesonbuild.com/howtox.html#set-extra-compiler-and-linker-flags-from-the-outside-when-eg-building-distro-packages

/Bruce
  
Nélio Laranjeiro Aug. 27, 2018, 12:20 p.m. UTC | #2
On Mon, Aug 27, 2018 at 12:24:11PM +0100, Bruce Richardson wrote:
> On Mon, Aug 27, 2018 at 01:10:52PM +0200, Nelio Laranjeiro wrote:
> > Almost equivalent to the make system build which uses those options
> > through environment variables (EXTRA_{CFLAGS,LDFLAGS}).
> > 
> > Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> > ---
> >  drivers/meson.build | 2 +-
> >  meson_options.txt   | 2 ++
> >  2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/meson.build b/drivers/meson.build
> > index f94e2fe67..008aac62c 100644
> > --- a/drivers/meson.build
> > +++ b/drivers/meson.build
> > @@ -11,7 +11,7 @@ driver_classes = ['common',
> >  	       'event',   # depends on common, bus, mempool and net.
> >  	       'raw']     # depends on common, bus, mempool, net and event.
> >  
> > -default_cflags = machine_args
> > +default_cflags = machine_args + [get_option('extra_cflags'), get_option('extra_ldflags')]
> >  if cc.has_argument('-Wno-format-truncation')
> >  	default_cflags += '-Wno-format-truncation'
> >  endif
> > diff --git a/meson_options.txt b/meson_options.txt
> > index c84327858..da6373a2c 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -22,3 +22,5 @@ option('use_hpet', type: 'boolean', value: false,
> >  	description: 'use HPET timer in EAL')
> >  option('tests', type: 'boolean', value: true,
> >  	description: 'build unit tests')
> > +option('extra_cflags', type: 'string', description: 'Extra compiler flags')
> > +option('extra_ldflags', type: 'string', description: 'Extra linker flags')
> 
> This should not be needed. Meson should pick up CFLAGS and LDFLAGS from the
> environment without having to add options for them.
> 
> https://mesonbuild.com/howtox.html#set-extra-compiler-and-linker-flags-from-the-outside-when-eg-building-distro-packages
> 
> /Bruce

Indeed this works with the CLFAGS/LDFLAGS way, but to find correctly the
library dependencies, it also needs to have the LD_LIBRARY_PATH set with
the correct path.

This patch will be discarded in the next version.

Thanks,
  

Patch

diff --git a/drivers/meson.build b/drivers/meson.build
index f94e2fe67..008aac62c 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -11,7 +11,7 @@  driver_classes = ['common',
 	       'event',   # depends on common, bus, mempool and net.
 	       'raw']     # depends on common, bus, mempool, net and event.
 
-default_cflags = machine_args
+default_cflags = machine_args + [get_option('extra_cflags'), get_option('extra_ldflags')]
 if cc.has_argument('-Wno-format-truncation')
 	default_cflags += '-Wno-format-truncation'
 endif
diff --git a/meson_options.txt b/meson_options.txt
index c84327858..da6373a2c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -22,3 +22,5 @@  option('use_hpet', type: 'boolean', value: false,
 	description: 'use HPET timer in EAL')
 option('tests', type: 'boolean', value: true,
 	description: 'build unit tests')
+option('extra_cflags', type: 'string', description: 'Extra compiler flags')
+option('extra_ldflags', type: 'string', description: 'Extra linker flags')