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 | 4bd6eef | 2023-06-01 07:25:18 +0930 | [diff] [blame^] | 85 | if test_abi_compliance |
| 86 | current_dump = custom_target('abi-dump', |
| 87 | input: libpldm, |
| 88 | output: 'current.dump', |
| 89 | command: [ abi_dumper, |
| 90 | '-public-headers', |
| 91 | meson.project_source_root() / 'include', |
| 92 | '@INPUT@', |
| 93 | '-o', |
| 94 | '@OUTPUT@', |
| 95 | '-lver', |
| 96 | meson.project_version()]) |
| 97 | abi_compliance = custom_target('abi-compliance', |
| 98 | input: [baseline_dump, current_dump], |
| 99 | output: 'abi-compliance', |
| 100 | command: [ abi_compliance_checker, |
| 101 | '-l', |
| 102 | meson.project_name(), |
| 103 | '-old', |
| 104 | '@INPUT0@', |
| 105 | '-new', |
| 106 | '@INPUT1@' ], |
| 107 | build_by_default: true) |
| 108 | endif |
Andrew Jeffery | 953bc8c | 2023-05-22 15:24:17 +0930 | [diff] [blame] | 109 | endif |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 110 | endif |
Rashmica Gupta | 6af2a29 | 2023-04-27 14:20:17 +1000 | [diff] [blame] | 111 | |
| 112 | install_subdir('instance-db', |
| 113 | install_mode: 'r--r--r--', |
| 114 | install_dir: get_option('datadir') / meson.project_name()) |