Thomas Heijligen has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/72656 )
Change subject: meson: use cfg_data for to evaluate cflags ......................................................................
meson: use cfg_data for to evaluate cflags
Change-Id: Ie91b4e1377b9d6d347511d4727c0a26a314b1e57 Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.com --- M doc/meson.build M meson.build 2 files changed, 30 insertions(+), 77 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/56/72656/1
diff --git a/doc/meson.build b/doc/meson.build index d59727a..3e4b3c4 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -16,7 +16,7 @@ custom_target( 'man-pages', command : [sphinx, '-b', 'man', '-q', '-d', '@PRIVATE_DIR@', '@CURRENT_SOURCE_DIR@', '@OUTDIR@'], - env : {'FLASHROM_VERSION' : meson.project_version() }, + env : {'FLASHROM_VERSION' : config.get('FLASHROM_VERSION') }, build_always_stale : true, # sphinx handles rebuilds output : man_outputs, install : true, @@ -28,7 +28,7 @@ custom_target( 'documentation', command : [sphinx, '-b', 'html', '-q', '-d', '@PRIVATE_DIR@', '@CURRENT_SOURCE_DIR@', '@OUTDIR@/doc/flashrom'], - env : {'FLASHROM_VERSION' : meson.project_version() }, + env : {'FLASHROM_VERSION' : config.get('FLASHROM_VERSION') }, build_always_stale : true, # sphinx handles rebuilds output : 'doc', install : true, diff --git a/meson.build b/meson.build index 41fe04a..42695c7 100644 --- a/meson.build +++ b/meson.build @@ -11,13 +11,12 @@ ], )
-subdir('doc') +config = configuration_data()
-# libtool versioning -lt_current = '1' -lt_revision = '0' -lt_age = '0' -lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) +config.set_quoted('FLASHROM_VERSION', meson.project_version()) +config.set('FLASHROM_LIBVERSION', '1.0.0') + +subdir('doc')
# hide/enable some warnings warning_flags = [ @@ -39,12 +38,6 @@ add_project_arguments('-D__XSI_VISIBLE', language : 'c') # required for gettimeofday() on FreeBSD add_project_arguments('-D_NETBSD_SOURCE', language : 'c') # required for indirect include of strings.h on NetBSD add_project_arguments('-D_DARWIN_C_SOURCE', language : 'c') # required for indirect include of strings.h on MacOS -add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c') - -# get defaults from configure -config_print_wiki= get_option('classic_cli_print_wiki') -config_default_programmer_name = get_option('default_programmer_name') -config_default_programmer_args = get_option('default_programmer_args')
cargs = [] link_args = [] @@ -86,21 +79,10 @@ 'writeprotect_ranges.c', )
-# check for required symbols -if cc.has_function('clock_gettime') - add_project_arguments('-DHAVE_CLOCK_GETTIME=1', language : 'c') -endif -if cc.has_function('strnlen') - add_project_arguments('-DHAVE_STRNLEN=1', language : 'c') -endif -if cc.check_header('sys/utsname.h') - add_project_arguments('-DHAVE_UTSNAME=1', language : 'c') -endif -if host_machine.system() in ['cygwin', 'windows'] - add_project_arguments('-DIS_WINDOWS=1', language : 'c') -else - add_project_arguments('-DIS_WINDOWS=0', language : 'c') -endif +config.set10('HAVE_CLOCK_GETTIME', cc.has_function('clock_gettime')) +config.set10('HAVE_STRNLEN', cc.has_function('strnlen')) +config.set10('HAVE_UTSNAME', cc.check_header('sys/utsname.h')) +config.set10('IS_WINDOWS', ['cygwin', 'windows'].contains(host_machine.system()))
systems_hwaccess = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd' ] systems_serial = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd', 'darwin' ] @@ -154,7 +136,6 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('atahpt.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_ATAHPT=1' ], 'default' : false, # not yet working }, 'atapromise' : { @@ -163,7 +144,6 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('atapromise.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_ATAPROMISE=1' ], 'default' : false, }, 'atavia' : { @@ -171,70 +151,59 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('atavia.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_ATAVIA=1' ], }, 'buspirate_spi' : { 'systems' : systems_serial, 'groups' : [ group_serial, group_external ], 'srcs' : files('buspirate_spi.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')), - 'flags' : [ '-DCONFIG_BUSPIRATE_SPI=1' ], }, 'ch341a_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('ch341a_spi.c'), 'test_srcs' : files('tests/ch341a_spi.c'), - 'flags' : [ '-DCONFIG_CH341A_SPI=1' ], }, 'dediprog' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('dediprog.c', 'usbdev.c'), 'test_srcs' : files('tests/dediprog.c'), - 'flags' : [ '-DCONFIG_DEDIPROG=1' ], }, 'developerbox_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('developerbox_spi.c', 'usbdev.c'), - 'flags' : [ '-DCONFIG_DEVELOPERBOX_SPI=1' ], }, 'digilent_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('digilent_spi.c'), - 'flags' : [ '-DCONFIG_DIGILENT_SPI=1' ], }, 'dirtyjtag_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('dirtyjtag_spi.c'), - 'flags' : [ '-DCONFIG_DIRTYJTAG_SPI=1' ], }, 'drkaiser' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('drkaiser.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_DRKAISER=1' ], }, 'dummy' : { 'srcs' : files('dummyflasher.c'), 'test_srcs' : files('tests/dummyflasher.c'), - 'flags' : [ '-DCONFIG_DUMMY=1' ], }, 'ft2232_spi' : { 'deps' : [ libftdi1 ], 'groups' : [ group_ftdi, group_external ], 'srcs' : files('ft2232_spi.c' ), - 'flags' : [ '-DCONFIG_FT2232_SPI=1' ], }, 'gfxnvidia' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('gfxnvidia.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_GFXNVIDIA=1' ], }, 'internal' : { 'systems' : systems_hwaccess + ['linux'], @@ -266,7 +235,6 @@ 'known_boards.c', )), 'flags' : [ - '-DCONFIG_INTERNAL=1', '-DCONFIG_INTERNAL_DMI=' + (get_option('use_internal_dmi') ? '1' : '0'), ] }, @@ -275,13 +243,11 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('it8212.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_IT8212=1' ], }, 'jlink_spi' : { 'deps' : [ libjaylink ], 'groups' : [ group_jlink, group_external ], 'srcs' : files('jlink_spi.c'), - 'flags' : [ '-DCONFIG_JLINK_SPI=1' ], 'default' : false, }, 'linux_mtd' : { @@ -290,7 +256,6 @@ 'groups' : [ group_internal ], 'srcs' : files('linux_mtd.c'), 'test_srcs' : files('tests/linux_mtd.c'), - 'flags' : [ '-DCONFIG_LINUX_MTD=1' ], }, 'linux_spi' : { 'systems' : [ 'linux' ], @@ -298,7 +263,6 @@ # internal / external? 'srcs' : files('linux_spi.c'), 'test_srcs' : files('tests/linux_spi.c'), - 'flags' : [ '-DCONFIG_LINUX_SPI=1' ], }, 'parade_lspcon' : { 'systems' : [ 'linux' ], @@ -306,7 +270,6 @@ 'groups' : [ group_i2c ], 'srcs' : files('parade_lspcon.c', 'i2c_helper_linux.c'), 'test_srcs' : files('tests/parade_lspcon.c'), - 'flags' : [ '-DCONFIG_PARADE_LSPCON=1' ], 'default' : false }, 'mediatek_i2c_spi' : { @@ -315,7 +278,6 @@ 'groups' : [ group_i2c ], 'srcs' : files('mediatek_i2c_spi.c', 'i2c_helper_linux.c'), 'test_srcs' : files('tests/mediatek_i2c_spi.c'), - 'flags' : [ '-DCONFIG_MEDIATEK_I2C_SPI=1' ], 'default' : false, }, 'mstarddc_spi' : { @@ -323,7 +285,6 @@ 'deps' : [ linux_headers ], 'groups' : [ group_i2c ], 'srcs' : files('mstarddc_spi.c', 'i2c_helper_linux.c'), - 'flags' : [ '-DCONFIG_MSTARDDC_SPI=1' ], 'default' : false }, 'nic3com' : { @@ -332,28 +293,24 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('nic3com.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_NIC3COM=1' ], }, 'nicintel' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('nicintel.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_NICINTEL=1' ], }, 'nicintel_eeprom' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('nicintel_eeprom.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_NICINTEL_EEPROM=1' ], }, 'nicintel_spi' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('nicintel_spi.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_NICINTEL_SPI=1' ], }, 'nicnatsemi' : { 'systems' : systems_hwaccess, @@ -361,7 +318,6 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('nicnatsemi.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_NICNATSEMI=1' ], 'default' : false, # not complete nor tested }, 'nicrealtek' : { @@ -371,40 +327,34 @@ 'groups' : [ group_pci, group_internal ], 'srcs' : files('nicrealtek.c', 'pcidev.c'), 'test_srcs' : files('tests/nicrealtek.c'), - 'flags' : [ '-DCONFIG_NICREALTEK=1' ], }, 'ogp_spi' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('ogp_spi.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_OGP_SPI=1' ], }, 'pickit2_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('pickit2_spi.c'), - 'flags' : [ '-DCONFIG_PICKIT2_SPI=1' ], }, 'pony_spi' : { 'systems' : systems_serial, 'groups' : [ group_serial, group_external ], 'srcs' : files('pony_spi.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')), - 'flags' : [ '-DCONFIG_PONY_SPI=1' ], }, 'raiden_debug_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('raiden_debug_spi.c', 'usb_device.c'), 'test_srcs' : files('tests/raiden_debug_spi.c'), - 'flags' : [ '-DCONFIG_RAIDEN_DEBUG_SPI=1' ], }, 'rayer_spi' : { 'systems' : systems_hwaccess, 'cpu_families' : cpus_port_io, 'groups' : [ group_internal ], 'srcs' : files('rayer_spi.c'), - 'flags' : [ '-DCONFIG_RAYER_SPI=1' ], }, 'realtek_mst_i2c_spi' : { 'systems' : [ 'linux' ], @@ -412,7 +362,6 @@ 'groups' : [ group_i2c ], 'srcs' : files('realtek_mst_i2c_spi.c', 'i2c_helper_linux.c'), 'test_srcs' : files('tests/realtek_mst_i2c_spi.c'), - 'flags' : [ '-DCONFIG_REALTEK_MST_I2C_SPI=1' ], 'default' : false, }, 'satamv' : { @@ -421,32 +370,27 @@ 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('satamv.c', 'pcidev.c'), - 'flags' : ['-DCONFIG_SATAMV=1'], }, 'satasii' : { 'systems' : systems_hwaccess, 'deps' : [ libpci ], 'groups' : [ group_pci, group_internal ], 'srcs' : files('satasii.c', 'pcidev.c'), - 'flags' : [ '-DCONFIG_SATASII=1' ], }, 'serprog' : { 'systems' : systems_serial, 'groups' : [ group_serial, group_external ], 'srcs' : files('serprog.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')), - 'flags' : [ '-DCONFIG_SERPROG=1' ], }, 'stlinkv3_spi' : { 'deps' : [ libusb1 ], 'groups' : [ group_usb, group_external ], 'srcs' : files('stlinkv3_spi.c', 'usbdev.c'), - 'flags' : [ '-DCONFIG_STLINKV3_SPI=1' ], }, 'usbblaster_spi' : { 'deps' : [ libftdi1 ], 'groups' : [ group_ftdi, group_external ], 'srcs' : files('usbblaster_spi.c'), - 'flags' : [ '-DCONFIG_USBBLASTER_SPI=1' ], }, }
@@ -518,6 +462,7 @@
# add srcs, cargs & deps from active programmer to global srcs, cargs & deps foreach p_name, p_data : programmer + config.set10('CONFIG_' + p_name.to_upper(), p_data.get('active')) if p_data.get('active') srcs += p_data.get('srcs') cargs += p_data.get('flags') @@ -525,7 +470,7 @@ endif endforeach
-if config_print_wiki.enabled() +if get_option('classic_cli_print_wiki').enabled() if get_option('classic_cli').disabled() error('`classic_cli_print_wiki` can not be enabled without `classic_cli`') else @@ -534,13 +479,8 @@ endif endif
-if config_default_programmer_name != '' - cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name -else - cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL' -endif - -cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"' +config.set('CONFIG_DEFAULT_PROGRAMMER_NAME', get_option('default_programmer_name') != '' ? '&programmer_' + get_option('default_programmer_name') : 'NULL') +config.set_quoted('CONFIG_DEFAULT_PROGRAMMER_ARGS', get_option('default_programmer_args'))
if get_option('llvm_cov').enabled() cargs += ['-fprofile-instr-generate', '-fcoverage-mapping'] @@ -552,6 +492,10 @@ ], )
+foreach key : config.keys() + cargs += '-D@0@=@1@'.format(key, config.get(key)) +endforeach + include_dir = include_directories('include')
mapfile = 'libflashrom.map' @@ -566,8 +510,7 @@ srcs, ], include_directories : include_dir, - soversion : lt_current, - version : lt_version, + version : config.get('FLASHROM_LIBVERSION'), dependencies : [ deps, ],