John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 1 | project( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 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 | ) |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 14 | |
Ed Tanous | 358c7e1 | 2024-07-15 13:54:57 -0700 | [diff] [blame^] | 15 | add_global_arguments( |
| 16 | '-DLIBCPER_JSON_SPEC="' |
| 17 | + meson.current_source_dir() |
| 18 | + '/specification/json/cper-json.json"', |
| 19 | language: ['c', 'cpp'], |
| 20 | ) |
| 21 | |
Andrew Adriance | 1a90898 | 2024-07-02 14:26:10 -0700 | [diff] [blame] | 22 | library_is_share = get_option('default_library') == 'shared' |
| 23 | |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 24 | project_description = 'libcper library' |
| 25 | |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 26 | section_sources = files( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 27 | 'sections/cper-section-arm.c', |
| 28 | 'sections/cper-section-ccix-per.c', |
| 29 | 'sections/cper-section-cxl-component.c', |
| 30 | 'sections/cper-section-cxl-protocol.c', |
| 31 | 'sections/cper-section-dmar-generic.c', |
| 32 | 'sections/cper-section-dmar-iommu.c', |
| 33 | 'sections/cper-section-dmar-vtd.c', |
| 34 | 'sections/cper-section-firmware.c', |
| 35 | 'sections/cper-section-generic.c', |
| 36 | 'sections/cper-section-ia32x64.c', |
| 37 | 'sections/cper-section-ipf.c', |
| 38 | 'sections/cper-section-memory.c', |
| 39 | 'sections/cper-section-pci-bus.c', |
| 40 | 'sections/cper-section-pci-dev.c', |
| 41 | 'sections/cper-section-pcie.c', |
| 42 | 'sections/cper-section.c', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 43 | ) |
| 44 | |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 45 | edk_sources = files('edk/Cper.c') |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 46 | |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 47 | generator_section_sources = files( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 48 | 'generator/sections/gen-section-arm.c', |
| 49 | 'generator/sections/gen-section-ccix-per.c', |
| 50 | 'generator/sections/gen-section-cxl-component.c', |
| 51 | 'generator/sections/gen-section-cxl-protocol.c', |
| 52 | 'generator/sections/gen-section-dmar.c', |
| 53 | 'generator/sections/gen-section-firmware.c', |
| 54 | 'generator/sections/gen-section-generic.c', |
| 55 | 'generator/sections/gen-section-ia32x64.c', |
| 56 | 'generator/sections/gen-section-memory.c', |
| 57 | 'generator/sections/gen-section-pci-bus.c', |
| 58 | 'generator/sections/gen-section-pci-dev.c', |
| 59 | 'generator/sections/gen-section-pcie.c', |
| 60 | 'generator/sections/gen-section.c', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 61 | ) |
| 62 | |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 63 | cc = meson.get_compiler('c') |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 64 | |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 65 | json_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep']) |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 66 | |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 67 | libcper_parse_sources = [ |
Ed Tanous | a7d2cdd | 2024-07-15 11:07:27 -0700 | [diff] [blame] | 68 | 'base64.c', |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 69 | 'cper-parse.c', |
| 70 | 'ir-parse.c', |
| 71 | 'cper-utils.c', |
| 72 | 'common-utils.c', |
| 73 | 'json-schema.c', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 74 | ] |
| 75 | |
| 76 | libcper_include = ['.'] |
| 77 | |
| 78 | libcper_parse = library( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 79 | 'cper-parse', |
| 80 | libcper_parse_sources, |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 81 | section_sources, |
| 82 | edk_sources, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 83 | version: meson.project_version(), |
| 84 | include_directories: include_directories(libcper_include), |
| 85 | c_args: '-Wno-address-of-packed-member', |
| 86 | dependencies: [ |
| 87 | json_c_dep, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 88 | ], |
| 89 | install: true, |
| 90 | install_dir: get_option('libdir'), |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 91 | ) |
| 92 | libcper_parse = declare_dependency( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 93 | include_directories: include_directories(libcper_include), |
| 94 | link_with: libcper_parse, |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 95 | ) |
| 96 | |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 97 | libcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c'] |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 98 | |
| 99 | libcper_generate = library( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 100 | 'cper-generate', |
| 101 | libcper_generate_sources, |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 102 | generator_section_sources, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 103 | version: meson.project_version(), |
| 104 | include_directories: include_directories(libcper_include), |
| 105 | dependencies: [ |
| 106 | libcper_parse, |
| 107 | json_c_dep, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 108 | ], |
| 109 | install: true, |
| 110 | install_dir: get_option('libdir'), |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 111 | ) |
| 112 | libcper_generate = declare_dependency( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 113 | include_directories: include_directories(libcper_include), |
| 114 | link_with: libcper_generate, |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 115 | ) |
| 116 | |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 117 | install_headers('cper-parse.h') |
| 118 | install_headers('cper-utils.h') |
| 119 | install_headers('common-utils.h') |
| 120 | install_headers('generator/cper-generate.h', subdir: 'generator') |
| 121 | install_headers('edk/Cper.h', subdir: 'edk') |
| 122 | install_headers('edk/BaseTypes.h', subdir: 'edk') |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 123 | |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 124 | if get_option('utility').allowed() |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 125 | executable( |
| 126 | 'cper-convert', |
| 127 | 'cli-app/cper-convert.c', |
| 128 | include_directories: include_directories(libcper_include), |
| 129 | dependencies: [ |
| 130 | libcper_parse, |
| 131 | json_c_dep, |
| 132 | ], |
| 133 | install: true, |
| 134 | install_dir: get_option('bindir'), |
| 135 | ) |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 136 | |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 137 | executable( |
| 138 | 'cper-generate', |
| 139 | 'generator/cper-generate-cli.c', |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 140 | edk_sources, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 141 | include_directories: include_directories(libcper_include), |
| 142 | dependencies: [ |
| 143 | libcper_generate, |
| 144 | ], |
| 145 | install: true, |
| 146 | install_dir: get_option('bindir'), |
| 147 | ) |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 148 | endif |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 149 | |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 150 | if get_option('tests').allowed() |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 151 | subdir('tests') |
Ed Tanous | 358c7e1 | 2024-07-15 13:54:57 -0700 | [diff] [blame^] | 152 | endif |