1197ea120SJohn Chungproject( 2*a5b3d49bSEd Tanous 'libcper', 3*a5b3d49bSEd 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 'werror=true', 11197ea120SJohn Chung 'warning_level=2', 12*a5b3d49bSEd Tanous ], 13*a5b3d49bSEd Tanous) 14197ea120SJohn Chung 15197ea120SJohn Chungproject_description = 'libcper library' 16197ea120SJohn Chung 17197ea120SJohn ChungSectionSources = files( 18197ea120SJohn Chung 'sections/cper-section-arm.c', 19197ea120SJohn Chung 'sections/cper-section-ccix-per.c', 20197ea120SJohn Chung 'sections/cper-section-cxl-component.c', 21197ea120SJohn Chung 'sections/cper-section-cxl-protocol.c', 22197ea120SJohn Chung 'sections/cper-section-dmar-generic.c', 23197ea120SJohn Chung 'sections/cper-section-dmar-iommu.c', 24197ea120SJohn Chung 'sections/cper-section-dmar-vtd.c', 25197ea120SJohn Chung 'sections/cper-section-firmware.c', 26197ea120SJohn Chung 'sections/cper-section-generic.c', 27197ea120SJohn Chung 'sections/cper-section-ia32x64.c', 28197ea120SJohn Chung 'sections/cper-section-ipf.c', 29197ea120SJohn Chung 'sections/cper-section-memory.c', 30197ea120SJohn Chung 'sections/cper-section-pci-bus.c', 31197ea120SJohn Chung 'sections/cper-section-pci-dev.c', 32*a5b3d49bSEd Tanous 'sections/cper-section-pcie.c', 33*a5b3d49bSEd Tanous 'sections/cper-section.c', 34197ea120SJohn Chung) 35197ea120SJohn Chung 36*a5b3d49bSEd TanousEDKSources = files('edk/Cper.c') 37197ea120SJohn Chung 38197ea120SJohn ChungGeneratorSectionSources = files( 39197ea120SJohn Chung 'generator/sections/gen-section-arm.c', 40197ea120SJohn Chung 'generator/sections/gen-section-ccix-per.c', 41197ea120SJohn Chung 'generator/sections/gen-section-cxl-component.c', 42197ea120SJohn Chung 'generator/sections/gen-section-cxl-protocol.c', 43197ea120SJohn Chung 'generator/sections/gen-section-dmar.c', 44197ea120SJohn Chung 'generator/sections/gen-section-firmware.c', 45197ea120SJohn Chung 'generator/sections/gen-section-generic.c', 46197ea120SJohn Chung 'generator/sections/gen-section-ia32x64.c', 47197ea120SJohn Chung 'generator/sections/gen-section-memory.c', 48197ea120SJohn Chung 'generator/sections/gen-section-pci-bus.c', 49197ea120SJohn Chung 'generator/sections/gen-section-pci-dev.c', 50*a5b3d49bSEd Tanous 'generator/sections/gen-section-pcie.c', 51*a5b3d49bSEd Tanous 'generator/sections/gen-section.c', 52197ea120SJohn Chung) 53197ea120SJohn Chung 54197ea120SJohn Chungcmake = import('cmake') 55abc62b89SJohn Chungcc = meson.get_compiler('c') 56197ea120SJohn Chung 57*a5b3d49bSEd Tanousjson_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep']) 58197ea120SJohn Chung 59abc62b89SJohn Chunglibb64 = cc.find_library('base64', has_headers: 'libbase64.h', required: false) 60197ea120SJohn Chungif not libb64.found() 61197ea120SJohn Chung opt_var = cmake.subproject_options() 62*a5b3d49bSEd Tanous opt_var.add_cmake_defines( 63*a5b3d49bSEd Tanous { 64197ea120SJohn Chung 'BUILD_SHARED_LIBS': true, 65abc62b89SJohn Chung 'BASE64_BUILD_CLI': false, 66197ea120SJohn Chung 'BASE64_WITH_AVX': false, 67197ea120SJohn Chung 'BASE64_WITH_AVX2': false, 68197ea120SJohn Chung 'BASE64_WITH_AVX512': false, 69197ea120SJohn Chung 'BASE64_WITH_SSSE3': false, 70197ea120SJohn Chung 'BASE64_WITH_SSE41': false, 71*a5b3d49bSEd Tanous 'BASE64_WITH_SSE42': false, 72*a5b3d49bSEd Tanous }, 73*a5b3d49bSEd Tanous ) 74*a5b3d49bSEd Tanous 75197ea120SJohn Chung 76197ea120SJohn Chung libb64_ex = cmake.subproject('libb64', options: opt_var) 77197ea120SJohn Chung libb64 = libb64_ex.dependency('base64') 78197ea120SJohn Chungendif 79197ea120SJohn Chung 80197ea120SJohn Chunglibcper_parse_sources = [ 81197ea120SJohn Chung 'cper-parse.c', 82197ea120SJohn Chung 'ir-parse.c', 83197ea120SJohn Chung 'cper-utils.c', 84197ea120SJohn Chung 'common-utils.c', 85*a5b3d49bSEd Tanous 'json-schema.c', 86197ea120SJohn Chung] 87197ea120SJohn Chung 88197ea120SJohn Chunglibcper_include = ['.'] 89197ea120SJohn Chung 90197ea120SJohn Chunglibcper_parse = library( 91197ea120SJohn Chung 'cper-parse', 92197ea120SJohn Chung libcper_parse_sources, 93197ea120SJohn Chung SectionSources, 94197ea120SJohn Chung EDKSources, 95197ea120SJohn Chung version: meson.project_version(), 96197ea120SJohn Chung include_directories: include_directories(libcper_include), 97197ea120SJohn Chung c_args: '-Wno-address-of-packed-member', 98197ea120SJohn Chung dependencies: [ 99197ea120SJohn Chung json_c_dep, 100197ea120SJohn Chung libb64, 101197ea120SJohn Chung ], 102197ea120SJohn Chung install: true, 103*a5b3d49bSEd Tanous install_dir: get_option('libdir'), 104197ea120SJohn Chung) 105197ea120SJohn Chunglibcper_parse = declare_dependency( 106197ea120SJohn Chung include_directories: include_directories(libcper_include), 107*a5b3d49bSEd Tanous link_with: libcper_parse, 108197ea120SJohn Chung) 109197ea120SJohn Chung 110*a5b3d49bSEd Tanouslibcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c'] 111197ea120SJohn Chung 112197ea120SJohn Chunglibcper_generate = library( 113197ea120SJohn Chung 'cper-generate', 114197ea120SJohn Chung libcper_generate_sources, 115197ea120SJohn Chung GeneratorSectionSources, 116197ea120SJohn Chung version: meson.project_version(), 117197ea120SJohn Chung include_directories: include_directories(libcper_include), 118197ea120SJohn Chung dependencies: [ 119197ea120SJohn Chung libcper_parse, 120197ea120SJohn Chung json_c_dep, 121197ea120SJohn Chung libb64, 122197ea120SJohn Chung ], 123197ea120SJohn Chung install: true, 124*a5b3d49bSEd Tanous install_dir: get_option('libdir'), 125197ea120SJohn Chung) 126197ea120SJohn Chunglibcper_generate = declare_dependency( 127197ea120SJohn Chung include_directories: include_directories(libcper_include), 128*a5b3d49bSEd Tanous link_with: libcper_generate, 129197ea120SJohn Chung) 130197ea120SJohn Chung 131abc62b89SJohn Chunginstall_headers('cper-parse.h') 132abc62b89SJohn Chunginstall_headers('cper-utils.h') 133abc62b89SJohn Chunginstall_headers('common-utils.h') 134abc62b89SJohn Chunginstall_headers('generator/cper-generate.h', subdir: 'generator') 135abc62b89SJohn Chunginstall_headers('edk/Cper.h', subdir: 'edk') 136abc62b89SJohn Chunginstall_headers('edk/BaseTypes.h', subdir: 'edk') 137abc62b89SJohn Chung 138abc62b89SJohn Chungif get_option('utility').allowed() 139197ea120SJohn Chung executable( 140197ea120SJohn Chung 'cper-convert', 141197ea120SJohn Chung 'cli-app/cper-convert.c', 142197ea120SJohn Chung include_directories: include_directories(libcper_include), 143197ea120SJohn Chung dependencies: [ 144197ea120SJohn Chung libcper_parse, 145197ea120SJohn Chung json_c_dep, 146197ea120SJohn Chung ], 147abc62b89SJohn Chung install: true, 148*a5b3d49bSEd Tanous install_dir: get_option('bindir'), 149197ea120SJohn Chung ) 150197ea120SJohn Chung 151197ea120SJohn Chung executable( 152197ea120SJohn Chung 'cper-generate', 153197ea120SJohn Chung 'generator/cper-generate-cli.c', 154197ea120SJohn Chung EDKSources, 155197ea120SJohn Chung include_directories: include_directories(libcper_include), 156197ea120SJohn Chung dependencies: [ 157197ea120SJohn Chung libcper_generate, 158197ea120SJohn Chung ], 159abc62b89SJohn Chung install: true, 160*a5b3d49bSEd Tanous install_dir: get_option('bindir'), 161197ea120SJohn Chung ) 162abc62b89SJohn Chungendif 163197ea120SJohn Chung 1641e267b64SEd Tanousrun_command('cp', '-r', 'specification/json/', meson.current_build_dir(), check: true) 165*a5b3d49bSEd Tanousrun_command( 166*a5b3d49bSEd Tanous 'mv', 167*a5b3d49bSEd Tanous meson.current_build_dir() / 'json', 168*a5b3d49bSEd Tanous meson.current_build_dir() / 'specification', 169*a5b3d49bSEd Tanous) 170197ea120SJohn Chung 171197ea120SJohn Chungif get_option('tests').allowed() 172197ea120SJohn Chung subdir('tests') 173197ea120SJohn Chungendif 174