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