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