0

in my project I need to compile a static library, the meson.build for it is the following

# libcustomLog library project.
#



project(
  'customLog',
  'c',
  version : '1.0.0',
  default_options : ['warning_level=3']
)
project_description = 'An example shared library'

project_headers = [
  'libcustomLog.h'
]

project_source_files = [
  'libcustomLog.c',
  'libcustomLogGet.c',
  'libcustomLogStripe.c'
]

build_args = [
]


# ===================================================================

# ======
# Target
# ======

public_headers = include_directories('../',
                                     '../public'
                                     )


build_args = [

  '-DQNXNTO', 
  '-DQNX_VER=7',
  '-DfwPLATFORM_NTO',
  '-Wall',
  '-Werror', 
  '-fsigned-char',
  '-Wno-char-subscripts',
  '-Wno-switch',
  '-Wno-parentheses',
  '-Wno-pointer-sign',
  '-Wredundant-decls',
  '-Wmissing-declarations',
  '-Wmissing-prototypes',
  '-O3',
  '-fno-strict-aliasing',
  '-std=gnu99',
  '-g',
 
]

project_target = static_library(
  meson.project_name(),
  project_source_files,
  install : true,
  c_args : build_args,
  gnu_symbol_visibility : 'hidden',
  include_directories : public_headers,
)


# =======
# Project
# =======

# Make this library usable as a Meson subproject.
project_dep = declare_dependency(
  include_directories: public_headers,
  link_with : project_target
)
set_variable(meson.project_name() + '_dep', project_dep)

# Make this library usable from the system's
# package manager.
install_headers(project_headers, subdir : meson.project_name())

pkg_mod = import('pkgconfig')
pkg_mod.generate(
  name : meson.project_name(),
  filebase : meson.project_name(),
  description : project_description,
  subdirs : meson.project_name(),
  libraries : project_target,
)

the compilation output is

$ meson compile --verbose
Found runner: ['/usr/bin/ninja']
ninja: Entering directory `.'
[1/4] /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc -Isrc/mon/libcustomLog.a.p -Isrc/mon -I../../src/mon -Isrc -I../../src -I../../src/public -fvisibility=hidden -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -fPIC -DQNXNTO -DQNX_VER=7 -DfwPLATFORM_NTO -Wall -Werror -fsigned-char -Wno-char-subscripts -Wno-switch -Wno-parentheses -Wno-pointer-sign -Wredundant-decls -Wmissing-declarations -Wmissing-prototypes -O3 -fno-strict-aliasing -std=gnu99 -g -MD -MQ src/mon/libcustomLog.a.p/libcustomLogStripe.c.o -MF src/mon/libcustomLog.a.p/libcustomLogStripe.c.o.d -o src/mon/libcustomLog.a.p/libcustomLogStripe.c.o -c ../../src/mon/libcustomLogStripe.c
[2/4] /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc -Isrc/mon/libcustomLog.a.p -Isrc/mon -I../../src/mon -Isrc -I../../src -I../../src/public -fvisibility=hidden -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -fPIC -DQNXNTO -DQNX_VER=7 -DfwPLATFORM_NTO -Wall -Werror -fsigned-char -Wno-char-subscripts -Wno-switch -Wno-parentheses -Wno-pointer-sign -Wredundant-decls -Wmissing-declarations -Wmissing-prototypes -O3 -fno-strict-aliasing -std=gnu99 -g -MD -MQ src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o -MF src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o.d -o src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o -c ../../src/mon/libcustomLogGetCode.c
[3/4] /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc -Isrc/mon/libcustomLog.a.p -Isrc/mon -I../../src/mon -Isrc -I../../src -I../../src/public -fvisibility=hidden -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -fPIC -DQNXNTO -DQNX_VER=7 -DfwPLATFORM_NTO -Wall -Werror -fsigned-char -Wno-char-subscripts -Wno-switch -Wno-parentheses -Wno-pointer-sign -Wredundant-decls -Wmissing-declarations -Wmissing-prototypes -O3 -fno-strict-aliasing -std=gnu99 -g -MD -MQ src/mon/libcustomLog.a.p/libcustomLog.c.o -MF src/mon/libcustomLog.a.p/libcustomLog.c.o.d -o src/mon/libcustomLog.a.p/libcustomLog.c.o -c ../../src/mon/libcustomLog.c
[4/4] rm -f src/mon/libcustomLog.a && /opt/qnx700/host/linux/x86_64/usr/bin/ntox86_64-ar csrD src/mon/libcustomLog.a src/mon/libcustomLog.a.p/libcustomLog.c.o src/mon/libcustomLog.a.p/libcustomLogGetCode.c.o src/mon/libcustomLog.a.p/libcustomLogStripe.c.o

now I would change the archive flags

...ntox86_64-ar csrD .....

in

...ntox86_64-ar -ru .....

how can I ovverride the default ones and add the "-ru"

I've tried to modify the meson.build

build_ar_args = [
  '-ru'
]


project_target = static_library(
  meson.project_name(),
  project_source_files,
  install : true,
  c_args : build_args,
  gnu_symbol_visibility : 'hidden',
  include_directories : public_headers,
  link_args: build_ar_args
)

but the output is the same.

Mariano
  • 240
  • 3
  • 15
  • What value is adding `ru` going to give you? meson/ninja will always delete the archive and recreate it from scratch if any of its dependencies have changed, it will never attempt to update the archive. – dcbaker Oct 20 '21 at 19:59
  • Hi I understand that in this case the default flag csrD is not a problem, but why the developer should be forced to use default flag, I would give to meson the possibility to skip any default flag on compilation and linking. – Mariano Oct 22 '21 at 07:07
  • One of Meson's goals is to abstract away details between platforms. Gnu AR accepts the `ru` options, but Meson supports a lot of different static archivers, including ones that don't have a POSIX/Unix lineage, like the visual studio linker. The other goal is to provide reliablility – dcbaker Oct 22 '21 at 14:57

0 Answers0