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