1project( 2 'libcper', ['c', 'cpp'], 3 version: '0.1', 4 meson_version: '>=1.1.1', 5 default_options: [ 6 'c_std=c18', 7 'cpp_std=c++23', 8 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), 9 'werror=true', 10 'warning_level=2', 11 ]) 12 13project_description = 'libcper library' 14 15SectionSources = files( 16 'sections/cper-section-arm.c', 17 'sections/cper-section.c', 18 'sections/cper-section-ccix-per.c', 19 'sections/cper-section-cxl-component.c', 20 'sections/cper-section-cxl-protocol.c', 21 'sections/cper-section-dmar-generic.c', 22 'sections/cper-section-dmar-iommu.c', 23 'sections/cper-section-dmar-vtd.c', 24 'sections/cper-section-firmware.c', 25 'sections/cper-section-generic.c', 26 'sections/cper-section-ia32x64.c', 27 'sections/cper-section-ipf.c', 28 'sections/cper-section-memory.c', 29 'sections/cper-section-pci-bus.c', 30 'sections/cper-section-pci-dev.c', 31 'sections/cper-section-pcie.c' 32) 33 34EDKSources = files( 35 'edk/Cper.c' 36) 37 38GeneratorSectionSources = files( 39 'generator/sections/gen-section-arm.c', 40 'generator/sections/gen-section.c', 41 'generator/sections/gen-section-ccix-per.c', 42 'generator/sections/gen-section-cxl-component.c', 43 'generator/sections/gen-section-cxl-protocol.c', 44 'generator/sections/gen-section-dmar.c', 45 'generator/sections/gen-section-firmware.c', 46 'generator/sections/gen-section-generic.c', 47 'generator/sections/gen-section-ia32x64.c', 48 'generator/sections/gen-section-memory.c', 49 'generator/sections/gen-section-pci-bus.c', 50 'generator/sections/gen-section-pci-dev.c', 51 'generator/sections/gen-section-pcie.c' 52) 53 54cmake = import('cmake') 55 56json_c_dep = dependency( 57 'json-c', 58 required: true, 59 fallback : ['json-c', 'json_c_dep']) 60 61libb64 = dependency('base64', required: false) 62if not libb64.found() 63 opt_var = cmake.subproject_options() 64 opt_var.add_cmake_defines({ 65 'BUILD_SHARED_LIBS': true, 66 'BASE64_WITH_AVX': false, 67 'BASE64_WITH_AVX2': false, 68 'BASE64_WITH_AVX512': false, 69 'BASE64_WITH_SSSE3': false, 70 'BASE64_WITH_SSE41': false, 71 'BASE64_WITH_SSE42': false}) 72 73 libb64_ex = cmake.subproject('libb64', options: opt_var) 74 libb64 = libb64_ex.dependency('base64') 75endif 76 77libcper_parse_sources = [ 78 'cper-parse.c', 79 'ir-parse.c', 80 'cper-utils.c', 81 'common-utils.c', 82 'json-schema.c' 83] 84 85libcper_include = ['.'] 86 87libcper_parse = library( 88 'cper-parse', 89 libcper_parse_sources, 90 SectionSources, 91 EDKSources, 92 version: meson.project_version(), 93 include_directories:include_directories(libcper_include), 94 c_args: '-Wno-address-of-packed-member', 95 dependencies: [ 96 json_c_dep, 97 libb64, 98 ], 99 install: true, 100 install_dir: get_option('libdir') 101) 102libcper_parse = declare_dependency( 103 include_directories: include_directories(libcper_include), 104 link_with: libcper_parse 105) 106 107 108libcper_generate_sources = [ 109 'generator/cper-generate.c', 110 'generator/gen-utils.c', 111 'common-utils.c' 112] 113 114libcper_generate = library( 115 'cper-generate', 116 libcper_generate_sources, 117 GeneratorSectionSources, 118 version: meson.project_version(), 119 include_directories:include_directories(libcper_include), 120 dependencies: [ 121 libcper_parse, 122 json_c_dep, 123 libb64, 124 ], 125 install: true, 126 install_dir: get_option('libdir') 127) 128libcper_generate = declare_dependency( 129 include_directories: include_directories(libcper_include), 130 link_with: libcper_generate 131) 132 133executable( 134 'cper-convert', 135 'cli-app/cper-convert.c', 136 include_directories:include_directories(libcper_include), 137 dependencies: [ 138 libcper_parse, 139 json_c_dep, 140 ], 141 install: true 142) 143 144executable( 145 'cper-generate', 146 'generator/cper-generate-cli.c', 147 EDKSources, 148 include_directories:include_directories(libcper_include), 149 dependencies: [ 150 libcper_generate, 151 ], 152 install: true 153) 154 155run_command('cp', '-r', 'specification/json/', meson.current_build_dir()) 156run_command('mv', meson.current_build_dir() / 'json', meson.current_build_dir() / 'specification') 157 158if get_option('tests').allowed() 159 subdir('tests') 160endif 161 162