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