1197ea120SJohn Chungproject( 2a5b3d49bSEd Tanous 'libcper', 3a5b3d49bSEd Tanous ['c', 'cpp'], 4197ea120SJohn Chung version: '0.1', 5197ea120SJohn Chung meson_version: '>=1.1.1', 6197ea120SJohn Chung default_options: [ 7197ea120SJohn Chung 'c_std=c18', 8197ea120SJohn Chung 'cpp_std=c++23', 9197ea120SJohn Chung 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), 10197ea120SJohn Chung 'warning_level=2', 110df69a8bSEd Tanous 'werror=true', 12a5b3d49bSEd Tanous ], 13a5b3d49bSEd Tanous) 14197ea120SJohn Chung 1545e7332fSKarthik Rajagopalanadd_project_arguments( 16358c7e16SEd Tanous '-DLIBCPER_JSON_SPEC="' 1710eb6de3SEd Tanous + meson.current_source_dir() + '/specification/json/cper-json.json"', 18358c7e16SEd Tanous language: ['c', 'cpp'], 19358c7e16SEd Tanous) 20358c7e16SEd Tanous 21517282ffSAushim Nagarkattiadd_project_arguments('-DLIBCPER_EXAMPLES="' 22517282ffSAushim Nagarkatti + meson.current_source_dir() + '/examples"', language: ['c', 'cpp']) 23ae8f6d9aSAushim Nagarkatti 241a908984SAndrew Adriancelibrary_is_share = get_option('default_library') == 'shared' 2545e7332fSKarthik Rajagopalanadd_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c') 261a908984SAndrew Adriance 27*dd9e8d98SAushim Nagarkattiif get_option('output-all-properties').enabled() 28*dd9e8d98SAushim Nagarkatti add_project_arguments('-DOUTPUT_ALL_PROPERTIES', language: ['c', 'cpp']) 29*dd9e8d98SAushim Nagarkattiendif 30*dd9e8d98SAushim Nagarkatti 31197ea120SJohn Chungproject_description = 'libcper library' 32197ea120SJohn Chung 33a84fc937SEd Tanoussection_sources = files( 3410eb6de3SEd Tanous 'sections/cper-section-ampere.c', 35197ea120SJohn Chung 'sections/cper-section-arm.c', 36197ea120SJohn Chung 'sections/cper-section-ccix-per.c', 37197ea120SJohn Chung 'sections/cper-section-cxl-component.c', 38197ea120SJohn Chung 'sections/cper-section-cxl-protocol.c', 39197ea120SJohn Chung 'sections/cper-section-dmar-generic.c', 40197ea120SJohn Chung 'sections/cper-section-dmar-iommu.c', 41197ea120SJohn Chung 'sections/cper-section-dmar-vtd.c', 42197ea120SJohn Chung 'sections/cper-section-firmware.c', 43197ea120SJohn Chung 'sections/cper-section-generic.c', 44197ea120SJohn Chung 'sections/cper-section-ia32x64.c', 45197ea120SJohn Chung 'sections/cper-section-ipf.c', 46197ea120SJohn Chung 'sections/cper-section-memory.c', 47683e0550SKarthik Rajagopalan 'sections/cper-section-nvidia.c', 48197ea120SJohn Chung 'sections/cper-section-pci-bus.c', 49197ea120SJohn Chung 'sections/cper-section-pci-dev.c', 50a5b3d49bSEd Tanous 'sections/cper-section-pcie.c', 51a5b3d49bSEd Tanous 'sections/cper-section.c', 52197ea120SJohn Chung) 53197ea120SJohn Chung 54a3b7f8a2SEd Tanousedk_sources = files('Cper.c') 55197ea120SJohn Chung 56a84fc937SEd Tanousgenerator_section_sources = files( 5710eb6de3SEd Tanous 'generator/sections/gen-section-ampere.c', 58197ea120SJohn Chung 'generator/sections/gen-section-arm.c', 59197ea120SJohn Chung 'generator/sections/gen-section-ccix-per.c', 60197ea120SJohn Chung 'generator/sections/gen-section-cxl-component.c', 61197ea120SJohn Chung 'generator/sections/gen-section-cxl-protocol.c', 62197ea120SJohn Chung 'generator/sections/gen-section-dmar.c', 63197ea120SJohn Chung 'generator/sections/gen-section-firmware.c', 64197ea120SJohn Chung 'generator/sections/gen-section-generic.c', 65197ea120SJohn Chung 'generator/sections/gen-section-ia32x64.c', 66197ea120SJohn Chung 'generator/sections/gen-section-memory.c', 67683e0550SKarthik Rajagopalan 'generator/sections/gen-section-nvidia.c', 68197ea120SJohn Chung 'generator/sections/gen-section-pci-bus.c', 69197ea120SJohn Chung 'generator/sections/gen-section-pci-dev.c', 70a5b3d49bSEd Tanous 'generator/sections/gen-section-pcie.c', 71a5b3d49bSEd Tanous 'generator/sections/gen-section.c', 72197ea120SJohn Chung) 73197ea120SJohn Chung 74abc62b89SJohn Chungcc = meson.get_compiler('c') 75197ea120SJohn Chung 76eed88bbfSEd Tanousjson_c_dep = dependency('json-c', required: false) 77eed88bbfSEd Tanousif not json_c_dep.found() 7810eb6de3SEd Tanous json_c = subproject( 7910eb6de3SEd Tanous 'json-c', 8010eb6de3SEd Tanous required: true, 8110eb6de3SEd Tanous default_options: ['warning_level=0'], 8210eb6de3SEd Tanous ) 83eed88bbfSEd Tanous json_c_dep = json_c.get_variable('json_c_dep') 84eed88bbfSEd Tanousendif 85197ea120SJohn Chung 860df69a8bSEd Tanouslibcper_parse_sources = files( 87a7d2cdddSEd Tanous 'base64.c', 88197ea120SJohn Chung 'common-utils.c', 890df69a8bSEd Tanous 'cper-parse.c', 900df69a8bSEd Tanous 'cper-utils.c', 910df69a8bSEd Tanous 'ir-parse.c', 92a5b3d49bSEd Tanous 'json-schema.c', 930df69a8bSEd Tanous) 94197ea120SJohn Chung 95e42fb487SThu Nguyenlibcper_include = ['include'] 96e42fb487SThu Nguyenlibcper_include_dir = include_directories(libcper_include, is_system: true) 97e42fb487SThu Nguyensubdir('include') 98197ea120SJohn Chung 99197ea120SJohn Chunglibcper_parse = library( 100197ea120SJohn Chung 'cper-parse', 101197ea120SJohn Chung libcper_parse_sources, 102a84fc937SEd Tanous section_sources, 103a84fc937SEd Tanous edk_sources, 104197ea120SJohn Chung version: meson.project_version(), 105e42fb487SThu Nguyen include_directories: libcper_include_dir, 106197ea120SJohn Chung c_args: '-Wno-address-of-packed-member', 10710eb6de3SEd Tanous dependencies: [json_c_dep], 108197ea120SJohn Chung install: true, 109a5b3d49bSEd Tanous install_dir: get_option('libdir'), 110197ea120SJohn Chung) 1119fe2cb5fSKarthik Rajagopalanlibcper_parse_dep = declare_dependency( 112e42fb487SThu Nguyen include_directories: libcper_include_dir, 113a5b3d49bSEd Tanous link_with: libcper_parse, 114197ea120SJohn Chung) 115197ea120SJohn Chung 11610eb6de3SEd Tanouslibcper_generate_sources = [ 1170df69a8bSEd Tanous 'common-utils.c', 11810eb6de3SEd Tanous 'generator/cper-generate.c', 11910eb6de3SEd Tanous 'generator/gen-utils.c', 12010eb6de3SEd Tanous] 121197ea120SJohn Chung 122197ea120SJohn Chunglibcper_generate = library( 123197ea120SJohn Chung 'cper-generate', 124197ea120SJohn Chung libcper_generate_sources, 125a84fc937SEd Tanous generator_section_sources, 126197ea120SJohn Chung version: meson.project_version(), 127e42fb487SThu Nguyen include_directories: libcper_include_dir, 12810eb6de3SEd Tanous dependencies: [libcper_parse_dep, json_c_dep], 129197ea120SJohn Chung install: true, 130a5b3d49bSEd Tanous install_dir: get_option('libdir'), 131197ea120SJohn Chung) 1329fe2cb5fSKarthik Rajagopalanlibcper_generate_dep = declare_dependency( 133e42fb487SThu Nguyen include_directories: libcper_include_dir, 134a5b3d49bSEd Tanous link_with: libcper_generate, 135197ea120SJohn Chung) 136197ea120SJohn Chung 1379fe2cb5fSKarthik Rajagopalanimport('pkgconfig').generate( 1389fe2cb5fSKarthik Rajagopalan libcper_parse, 1399fe2cb5fSKarthik Rajagopalan name: meson.project_name(), 1409fe2cb5fSKarthik Rajagopalan version: meson.project_version(), 14110eb6de3SEd Tanous description: 'C bindings for parsing CPER', 1429fe2cb5fSKarthik Rajagopalan) 1439fe2cb5fSKarthik Rajagopalan 144abc62b89SJohn Chungif get_option('utility').allowed() 145197ea120SJohn Chung executable( 146197ea120SJohn Chung 'cper-convert', 147197ea120SJohn Chung 'cli-app/cper-convert.c', 148e42fb487SThu Nguyen include_directories: libcper_include_dir, 14910eb6de3SEd Tanous dependencies: [libcper_parse_dep, json_c_dep], 150abc62b89SJohn Chung install: true, 151a5b3d49bSEd Tanous install_dir: get_option('bindir'), 152197ea120SJohn Chung ) 153197ea120SJohn Chung 154197ea120SJohn Chung executable( 155197ea120SJohn Chung 'cper-generate', 156197ea120SJohn Chung 'generator/cper-generate-cli.c', 157a84fc937SEd Tanous edk_sources, 158e42fb487SThu Nguyen include_directories: libcper_include_dir, 15910eb6de3SEd Tanous dependencies: [libcper_generate_dep], 160abc62b89SJohn Chung install: true, 161a5b3d49bSEd Tanous install_dir: get_option('bindir'), 162197ea120SJohn Chung ) 163abc62b89SJohn Chungendif 164197ea120SJohn Chung 165*dd9e8d98SAushim Nagarkatti# Disable unit tests when output-all-properties is enabled 166*dd9e8d98SAushim Nagarkatti# because it changes CPER-IR output format. 167*dd9e8d98SAushim Nagarkattiif get_option('output-all-properties').disabled() 168197ea120SJohn Chung if get_option('tests').allowed() 169197ea120SJohn Chung subdir('tests') 170197ea120SJohn Chung endif 171*dd9e8d98SAushim Nagarkattiendif 172