Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 1 | project('libpldm', ['c','cpp'], |
| 2 | default_options: [ |
Andrew Jeffery | 953bc8c | 2023-05-22 15:24:17 +0930 | [diff] [blame] | 3 | 'debug=true', |
| 4 | 'optimization=g', |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 5 | 'warning_level=3', |
| 6 | 'werror=true', |
| 7 | 'cpp_std=c++20', |
| 8 | 'c_std=c17', |
| 9 | 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), |
| 10 | ], |
Andrew Jeffery | 8a4b533 | 2023-07-14 13:26:12 +0930 | [diff] [blame^] | 11 | version: '0.4.0', |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 12 | meson_version: '>=0.63.0', |
| 13 | ) |
| 14 | |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 15 | add_project_arguments('-D_DEFAULT_SOURCE', language: ['c']) |
| 16 | |
| 17 | compiler = meson.get_compiler('c') |
| 18 | conf = configuration_data() |
| 19 | if compiler.has_header('poll.h') |
| 20 | conf.set('PLDM_HAS_POLL', 1) |
| 21 | endif |
| 22 | |
| 23 | # ABI control |
| 24 | visible = '__attribute__((visibility("default")))' |
| 25 | if get_option('abi').contains('deprecated') |
| 26 | conf.set('LIBPLDM_ABI_DEPRECATED', visible) |
| 27 | add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp']) |
| 28 | else |
| 29 | conf.set('LIBPLDM_ABI_DEPRECATED', '') |
| 30 | endif |
| 31 | conf.set('LIBPLDM_ABI_STABLE', visible) # Always expose the stable symbols |
| 32 | if get_option('abi').contains('testing') |
| 33 | conf.set('LIBPLDM_ABI_TESTING', visible) |
| 34 | add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp']) |
| 35 | else |
| 36 | conf.set('LIBPLDM_ABI_TESTING', '') |
| 37 | endif |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 38 | |
Andrew Jeffery | f89befe | 2023-06-16 13:02:09 +0930 | [diff] [blame] | 39 | config = configure_file(output: 'config.h', |
| 40 | configuration: conf |
| 41 | ) |
| 42 | |
| 43 | add_project_arguments('-include', '@0@'.format(config), language: 'c') |
| 44 | |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 45 | libpldm_sources = files() |
| 46 | subdir('src') |
| 47 | |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 48 | libpldm_include_dir = ['.', 'include', 'src'] |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 49 | libpldm_headers = files() |
Rashmica Gupta | c1b66f4 | 2022-12-09 16:24:45 +1100 | [diff] [blame] | 50 | libpldm_transport_headers = files() |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 51 | |
| 52 | subdir('include/libpldm') |
| 53 | |
| 54 | libpldm = library( |
| 55 | 'pldm', |
| 56 | libpldm_sources, |
| 57 | implicit_include_directories: false, |
| 58 | include_directories: libpldm_include_dir, |
| 59 | version: meson.project_version(), |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 60 | gnu_symbol_visibility: 'hidden', |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 61 | install: true |
| 62 | ) |
| 63 | |
| 64 | install_headers( |
| 65 | libpldm_headers, |
| 66 | subdir:'libpldm' |
| 67 | ) |
| 68 | |
Rashmica Gupta | c1b66f4 | 2022-12-09 16:24:45 +1100 | [diff] [blame] | 69 | install_headers( |
| 70 | libpldm_transport_headers, |
| 71 | subdir:'libpldm/transport' |
| 72 | ) |
| 73 | |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 74 | libpldm_dep = declare_dependency( |
| 75 | include_directories: libpldm_include_dir, |
| 76 | link_with: libpldm) |
| 77 | |
| 78 | import('pkgconfig').generate( |
| 79 | name: 'libpldm', |
| 80 | description: 'PLDM protocol encode/decode C lib', |
| 81 | version: meson.project_version(), |
| 82 | libraries: libpldm) |
| 83 | |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 84 | if get_option('tests').enabled() |
| 85 | subdir('tests') |
Andrew Jeffery | 953bc8c | 2023-05-22 15:24:17 +0930 | [diff] [blame] | 86 | |
Andrew Jeffery | 33e21a2 | 2023-05-29 12:12:36 +0930 | [diff] [blame] | 87 | c_suite = meson.get_compiler('c').get_id() |
| 88 | cpp_suite = meson.get_compiler('cpp').get_id() |
| 89 | |
| 90 | if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc' |
| 91 | host = host_machine.cpu_family() |
| 92 | baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite) |
| 93 | |
Andrew Jeffery | 953bc8c | 2023-05-22 15:24:17 +0930 | [diff] [blame] | 94 | abi_dumper = find_program('abi-dumper', |
| 95 | native: true, |
| 96 | required: get_option('abi-compliance-check')) |
| 97 | abi_compliance_checker = find_program('abi-compliance-checker', |
| 98 | native: true, |
| 99 | required: get_option('abi-compliance-check')) |
Andrew Jeffery | 33e21a2 | 2023-05-29 12:12:36 +0930 | [diff] [blame] | 100 | |
| 101 | test_abi_compliance = abi_dumper.found() and \ |
| 102 | abi_compliance_checker.found() and \ |
| 103 | import('fs').is_file(baseline_dump) |
| 104 | |
Andrew Jeffery | 4bd6eef | 2023-06-01 07:25:18 +0930 | [diff] [blame] | 105 | if test_abi_compliance |
| 106 | current_dump = custom_target('abi-dump', |
| 107 | input: libpldm, |
| 108 | output: 'current.dump', |
| 109 | command: [ abi_dumper, |
| 110 | '-public-headers', |
| 111 | meson.project_source_root() / 'include', |
| 112 | '@INPUT@', |
| 113 | '-o', |
| 114 | '@OUTPUT@', |
| 115 | '-lver', |
| 116 | meson.project_version()]) |
| 117 | abi_compliance = custom_target('abi-compliance', |
| 118 | input: [baseline_dump, current_dump], |
| 119 | output: 'abi-compliance', |
| 120 | command: [ abi_compliance_checker, |
| 121 | '-l', |
| 122 | meson.project_name(), |
| 123 | '-old', |
| 124 | '@INPUT0@', |
| 125 | '-new', |
| 126 | '@INPUT1@' ], |
| 127 | build_by_default: true) |
| 128 | endif |
Andrew Jeffery | 953bc8c | 2023-05-22 15:24:17 +0930 | [diff] [blame] | 129 | endif |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 130 | endif |
Rashmica Gupta | 6af2a29 | 2023-04-27 14:20:17 +1000 | [diff] [blame] | 131 | |
| 132 | install_subdir('instance-db', |
| 133 | install_mode: 'r--r--r--', |
| 134 | install_dir: get_option('datadir') / meson.project_name()) |