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