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