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 'werror=true', 11197ea120SJohn Chung 'warning_level=2', 12a5b3d49bSEd Tanous ], 13a5b3d49bSEd Tanous) 14197ea120SJohn Chung 15*1a908984SAndrew Adriancelibrary_is_share = get_option('default_library') == 'shared' 16*1a908984SAndrew Adriance 17197ea120SJohn Chungproject_description = 'libcper library' 18197ea120SJohn Chung 19197ea120SJohn ChungSectionSources = files( 20197ea120SJohn Chung 'sections/cper-section-arm.c', 21197ea120SJohn Chung 'sections/cper-section-ccix-per.c', 22197ea120SJohn Chung 'sections/cper-section-cxl-component.c', 23197ea120SJohn Chung 'sections/cper-section-cxl-protocol.c', 24197ea120SJohn Chung 'sections/cper-section-dmar-generic.c', 25197ea120SJohn Chung 'sections/cper-section-dmar-iommu.c', 26197ea120SJohn Chung 'sections/cper-section-dmar-vtd.c', 27197ea120SJohn Chung 'sections/cper-section-firmware.c', 28197ea120SJohn Chung 'sections/cper-section-generic.c', 29197ea120SJohn Chung 'sections/cper-section-ia32x64.c', 30197ea120SJohn Chung 'sections/cper-section-ipf.c', 31197ea120SJohn Chung 'sections/cper-section-memory.c', 32197ea120SJohn Chung 'sections/cper-section-pci-bus.c', 33197ea120SJohn Chung 'sections/cper-section-pci-dev.c', 34a5b3d49bSEd Tanous 'sections/cper-section-pcie.c', 35a5b3d49bSEd Tanous 'sections/cper-section.c', 36197ea120SJohn Chung) 37197ea120SJohn Chung 38a5b3d49bSEd TanousEDKSources = files('edk/Cper.c') 39197ea120SJohn Chung 40197ea120SJohn ChungGeneratorSectionSources = files( 41197ea120SJohn Chung 'generator/sections/gen-section-arm.c', 42197ea120SJohn Chung 'generator/sections/gen-section-ccix-per.c', 43197ea120SJohn Chung 'generator/sections/gen-section-cxl-component.c', 44197ea120SJohn Chung 'generator/sections/gen-section-cxl-protocol.c', 45197ea120SJohn Chung 'generator/sections/gen-section-dmar.c', 46197ea120SJohn Chung 'generator/sections/gen-section-firmware.c', 47197ea120SJohn Chung 'generator/sections/gen-section-generic.c', 48197ea120SJohn Chung 'generator/sections/gen-section-ia32x64.c', 49197ea120SJohn Chung 'generator/sections/gen-section-memory.c', 50197ea120SJohn Chung 'generator/sections/gen-section-pci-bus.c', 51197ea120SJohn Chung 'generator/sections/gen-section-pci-dev.c', 52a5b3d49bSEd Tanous 'generator/sections/gen-section-pcie.c', 53a5b3d49bSEd Tanous 'generator/sections/gen-section.c', 54197ea120SJohn Chung) 55197ea120SJohn Chung 56197ea120SJohn Chungcmake = import('cmake') 57abc62b89SJohn Chungcc = meson.get_compiler('c') 58197ea120SJohn Chung 59a5b3d49bSEd Tanousjson_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep']) 60197ea120SJohn Chung 61abc62b89SJohn Chunglibb64 = cc.find_library('base64', has_headers: 'libbase64.h', required: false) 62197ea120SJohn Chungif not libb64.found() 63197ea120SJohn Chung opt_var = cmake.subproject_options() 64a5b3d49bSEd Tanous opt_var.add_cmake_defines( 65a5b3d49bSEd Tanous { 66*1a908984SAndrew Adriance 'BUILD_SHARED_LIBS': library_is_share, 67abc62b89SJohn Chung 'BASE64_BUILD_CLI': false, 68197ea120SJohn Chung 'BASE64_WITH_AVX': false, 69197ea120SJohn Chung 'BASE64_WITH_AVX2': false, 70197ea120SJohn Chung 'BASE64_WITH_AVX512': false, 71197ea120SJohn Chung 'BASE64_WITH_SSSE3': false, 72197ea120SJohn Chung 'BASE64_WITH_SSE41': false, 73a5b3d49bSEd Tanous 'BASE64_WITH_SSE42': false, 74a5b3d49bSEd Tanous }, 75a5b3d49bSEd Tanous ) 76a5b3d49bSEd Tanous 77197ea120SJohn Chung libb64_ex = cmake.subproject('libb64', options: opt_var) 78197ea120SJohn Chung libb64 = libb64_ex.dependency('base64') 79197ea120SJohn Chungendif 80197ea120SJohn Chung 81197ea120SJohn Chunglibcper_parse_sources = [ 82197ea120SJohn Chung 'cper-parse.c', 83197ea120SJohn Chung 'ir-parse.c', 84197ea120SJohn Chung 'cper-utils.c', 85197ea120SJohn Chung 'common-utils.c', 86a5b3d49bSEd Tanous 'json-schema.c', 87197ea120SJohn Chung] 88197ea120SJohn Chung 89197ea120SJohn Chunglibcper_include = ['.'] 90197ea120SJohn Chung 91197ea120SJohn Chunglibcper_parse = library( 92197ea120SJohn Chung 'cper-parse', 93197ea120SJohn Chung libcper_parse_sources, 94197ea120SJohn Chung SectionSources, 95197ea120SJohn Chung EDKSources, 96197ea120SJohn Chung version: meson.project_version(), 97197ea120SJohn Chung include_directories: include_directories(libcper_include), 98197ea120SJohn Chung c_args: '-Wno-address-of-packed-member', 99197ea120SJohn Chung dependencies: [ 100197ea120SJohn Chung json_c_dep, 101197ea120SJohn Chung libb64, 102197ea120SJohn Chung ], 103197ea120SJohn Chung install: true, 104a5b3d49bSEd Tanous install_dir: get_option('libdir'), 105197ea120SJohn Chung) 106197ea120SJohn Chunglibcper_parse = declare_dependency( 107197ea120SJohn Chung include_directories: include_directories(libcper_include), 108a5b3d49bSEd Tanous link_with: libcper_parse, 109197ea120SJohn Chung) 110197ea120SJohn Chung 111a5b3d49bSEd Tanouslibcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c'] 112197ea120SJohn Chung 113197ea120SJohn Chunglibcper_generate = library( 114197ea120SJohn Chung 'cper-generate', 115197ea120SJohn Chung libcper_generate_sources, 116197ea120SJohn Chung GeneratorSectionSources, 117197ea120SJohn Chung version: meson.project_version(), 118197ea120SJohn Chung include_directories: include_directories(libcper_include), 119197ea120SJohn Chung dependencies: [ 120197ea120SJohn Chung libcper_parse, 121197ea120SJohn Chung json_c_dep, 122197ea120SJohn Chung libb64, 123197ea120SJohn Chung ], 124197ea120SJohn Chung install: true, 125a5b3d49bSEd Tanous install_dir: get_option('libdir'), 126197ea120SJohn Chung) 127197ea120SJohn Chunglibcper_generate = declare_dependency( 128197ea120SJohn Chung include_directories: include_directories(libcper_include), 129a5b3d49bSEd Tanous link_with: libcper_generate, 130197ea120SJohn Chung) 131197ea120SJohn Chung 132abc62b89SJohn Chunginstall_headers('cper-parse.h') 133abc62b89SJohn Chunginstall_headers('cper-utils.h') 134abc62b89SJohn Chunginstall_headers('common-utils.h') 135abc62b89SJohn Chunginstall_headers('generator/cper-generate.h', subdir: 'generator') 136abc62b89SJohn Chunginstall_headers('edk/Cper.h', subdir: 'edk') 137abc62b89SJohn Chunginstall_headers('edk/BaseTypes.h', subdir: 'edk') 138abc62b89SJohn Chung 139abc62b89SJohn Chungif get_option('utility').allowed() 140197ea120SJohn Chung executable( 141197ea120SJohn Chung 'cper-convert', 142197ea120SJohn Chung 'cli-app/cper-convert.c', 143197ea120SJohn Chung include_directories: include_directories(libcper_include), 144197ea120SJohn Chung dependencies: [ 145197ea120SJohn Chung libcper_parse, 146197ea120SJohn Chung json_c_dep, 147197ea120SJohn Chung ], 148abc62b89SJohn Chung install: true, 149a5b3d49bSEd Tanous install_dir: get_option('bindir'), 150197ea120SJohn Chung ) 151197ea120SJohn Chung 152197ea120SJohn Chung executable( 153197ea120SJohn Chung 'cper-generate', 154197ea120SJohn Chung 'generator/cper-generate-cli.c', 155197ea120SJohn Chung EDKSources, 156197ea120SJohn Chung include_directories: include_directories(libcper_include), 157197ea120SJohn Chung dependencies: [ 158197ea120SJohn Chung libcper_generate, 159197ea120SJohn Chung ], 160abc62b89SJohn Chung install: true, 161a5b3d49bSEd Tanous install_dir: get_option('bindir'), 162197ea120SJohn Chung ) 163abc62b89SJohn Chungendif 164197ea120SJohn Chung 1651e267b64SEd Tanousrun_command('cp', '-r', 'specification/json/', meson.current_build_dir(), check: true) 166a5b3d49bSEd Tanousrun_command( 167a5b3d49bSEd Tanous 'mv', 168a5b3d49bSEd Tanous meson.current_build_dir() / 'json', 169a5b3d49bSEd Tanous meson.current_build_dir() / 'specification', 170a5b3d49bSEd Tanous) 171197ea120SJohn Chung 172197ea120SJohn Chungif get_option('tests').allowed() 173197ea120SJohn Chung subdir('tests') 174197ea120SJohn Chungendif 175