1project( 2 'libcper', 3 ['c', 'cpp'], 4 version: '0.1', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'c_std=c18', 8 'cpp_std=c++23', 9 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), 10 'warning_level=2', 11 'werror=true', 12 ], 13) 14 15add_project_arguments( 16 '-DLIBCPER_JSON_SPEC="' 17 + meson.current_source_dir() + '/specification/json"', 18 language: ['c', 'cpp'], 19) 20 21add_project_arguments('-DLIBCPER_EXAMPLES="' 22 + meson.current_source_dir() + '/examples"', language: ['c', 'cpp']) 23 24library_is_share = get_option('default_library') == 'shared' 25add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c') 26 27if get_option('output-all-properties').enabled() 28 add_project_arguments('-DOUTPUT_ALL_PROPERTIES', language: ['c', 'cpp']) 29endif 30 31project_description = 'libcper library' 32 33libcper_parse_sources = files( 34 'sections/cper-section-ampere.c', 35 'sections/cper-section-arm.c', 36 'sections/cper-section-ccix-per.c', 37 'sections/cper-section-cxl-component.c', 38 'sections/cper-section-cxl-protocol.c', 39 'sections/cper-section-dmar-generic.c', 40 'sections/cper-section-dmar-iommu.c', 41 'sections/cper-section-dmar-vtd.c', 42 'sections/cper-section-firmware.c', 43 'sections/cper-section-generic.c', 44 'sections/cper-section-ia32x64.c', 45 'sections/cper-section-ipf.c', 46 'sections/cper-section-memory.c', 47 'sections/cper-section-nvidia.c', 48 'sections/cper-section-pci-bus.c', 49 'sections/cper-section-pci-dev.c', 50 'sections/cper-section-pcie.c', 51 'sections/cper-section.c', 52) 53 54edk_sources = files('Cper.c') 55 56libcper_generate_sources = files( 57 'generator/sections/gen-section-ampere.c', 58 'generator/sections/gen-section-arm.c', 59 'generator/sections/gen-section-ccix-per.c', 60 'generator/sections/gen-section-cxl-component.c', 61 'generator/sections/gen-section-cxl-protocol.c', 62 'generator/sections/gen-section-dmar.c', 63 'generator/sections/gen-section-firmware.c', 64 'generator/sections/gen-section-generic.c', 65 'generator/sections/gen-section-ia32x64.c', 66 'generator/sections/gen-section-memory.c', 67 'generator/sections/gen-section-nvidia.c', 68 'generator/sections/gen-section-pci-bus.c', 69 'generator/sections/gen-section-pci-dev.c', 70 'generator/sections/gen-section-pcie.c', 71 'generator/sections/gen-section.c', 72) 73 74cc = meson.get_compiler('c') 75 76json_c_dep = dependency('json-c', required: false) 77if not json_c_dep.found() 78 json_c = subproject( 79 'json-c', 80 required: true, 81 default_options: ['warning_level=0'], 82 ) 83 json_c_dep = json_c.get_variable('json_c_dep') 84endif 85 86libcper_include = ['include'] 87libcper_include_dir = include_directories(libcper_include, is_system: true) 88 89 90libcper_parse_sources += files( 91 'base64.c', 92 'common-utils.c', 93 'cper-parse.c', 94 'cper-utils.c', 95 'ir-parse.c', 96 'log.c', 97) 98 99subdir('include') 100 101libcper_parse = library( 102 'cper-parse', 103 libcper_parse_sources, 104 edk_sources, 105 version: meson.project_version(), 106 include_directories: libcper_include_dir, 107 c_args: '-Wno-address-of-packed-member', 108 dependencies: [json_c_dep], 109 install: true, 110 install_dir: get_option('libdir'), 111) 112libcper_parse_dep = declare_dependency( 113 include_directories: libcper_include_dir, 114 link_with: [libcper_parse], 115) 116 117libcper_generate_sources += files( 118 'generator/cper-generate.c', 119 'generator/gen-utils.c', 120) 121 122libcper_generate = library( 123 'cper-generate', 124 libcper_generate_sources, 125 version: meson.project_version(), 126 include_directories: libcper_include_dir, 127 dependencies: [json_c_dep], 128 link_with: [libcper_parse], 129 install: true, 130 install_dir: get_option('libdir'), 131) 132libcper_generate_dep = declare_dependency( 133 include_directories: libcper_include_dir, 134 link_with: libcper_generate, 135) 136 137import('pkgconfig').generate( 138 libcper_parse, 139 name: meson.project_name(), 140 version: meson.project_version(), 141 description: 'C bindings for parsing CPER', 142) 143 144if get_option('utility').allowed() 145 executable( 146 'cper-convert', 147 'cli-app/cper-convert.c', 148 include_directories: libcper_include_dir, 149 dependencies: [json_c_dep], 150 link_with: [libcper_parse, libcper_generate], 151 install: true, 152 install_dir: get_option('bindir'), 153 ) 154 155 executable( 156 'cper-generate', 157 'generator/cper-generate-cli.c', 158 edk_sources, 159 include_directories: libcper_include_dir, 160 link_with: [libcper_parse, libcper_generate], 161 install: true, 162 install_dir: get_option('bindir'), 163 ) 164endif 165 166# Disable unit tests when output-all-properties is enabled 167# because it changes CPER-IR output format. 168if get_option('output-all-properties').disabled() 169 if get_option('tests').allowed() 170 subdir('tests') 171 endif 172endif 173