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'), |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 10 | 'warning_level=2', |
Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 11 | 'werror=true', |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 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="' |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 17 | + meson.current_source_dir() + '/specification/json/cper-json.json"', |
Ed Tanous | 358c7e1 | 2024-07-15 13:54:57 -0700 | [diff] [blame] | 18 | language: ['c', 'cpp'], |
| 19 | ) |
| 20 | |
Andrew Adriance | 1a90898 | 2024-07-02 14:26:10 -0700 | [diff] [blame] | 21 | library_is_share = get_option('default_library') == 'shared' |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 22 | add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c') |
Andrew Adriance | 1a90898 | 2024-07-02 14:26:10 -0700 | [diff] [blame] | 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 | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 27 | 'sections/cper-section-ampere.c', |
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 | a3b7f8a | 2024-11-04 16:38:59 -0800 | [diff] [blame] | 47 | edk_sources = files('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 | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 50 | 'generator/sections/gen-section-ampere.c', |
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', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 65 | ) |
| 66 | |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 67 | cc = meson.get_compiler('c') |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 68 | |
Ed Tanous | eed88bb | 2024-10-03 17:18:20 -0700 | [diff] [blame] | 69 | json_c_dep = dependency('json-c', required: false) |
| 70 | if not json_c_dep.found() |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 71 | json_c = subproject( |
| 72 | 'json-c', |
| 73 | required: true, |
| 74 | default_options: ['warning_level=0'], |
| 75 | ) |
Ed Tanous | eed88bb | 2024-10-03 17:18:20 -0700 | [diff] [blame] | 76 | json_c_dep = json_c.get_variable('json_c_dep') |
| 77 | endif |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 78 | |
Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 79 | libcper_parse_sources = files( |
Ed Tanous | a7d2cdd | 2024-07-15 11:07:27 -0700 | [diff] [blame] | 80 | 'base64.c', |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 81 | 'common-utils.c', |
Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 82 | 'cper-parse.c', |
| 83 | 'cper-utils.c', |
| 84 | 'ir-parse.c', |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 85 | 'json-schema.c', |
Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 86 | ) |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 87 | |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 88 | libcper_include = ['include'] |
| 89 | libcper_include_dir = include_directories(libcper_include, is_system: true) |
| 90 | subdir('include') |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 91 | |
| 92 | libcper_parse = library( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 93 | 'cper-parse', |
| 94 | libcper_parse_sources, |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 95 | section_sources, |
| 96 | edk_sources, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 97 | version: meson.project_version(), |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 98 | include_directories: libcper_include_dir, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 99 | c_args: '-Wno-address-of-packed-member', |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 100 | dependencies: [json_c_dep], |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 101 | install: true, |
| 102 | install_dir: get_option('libdir'), |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 103 | ) |
Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 104 | libcper_parse_dep = declare_dependency( |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 105 | include_directories: libcper_include_dir, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 106 | link_with: libcper_parse, |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 107 | ) |
| 108 | |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 109 | libcper_generate_sources = [ |
Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 110 | 'common-utils.c', |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 111 | 'generator/cper-generate.c', |
| 112 | 'generator/gen-utils.c', |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 113 | ] |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 114 | |
| 115 | libcper_generate = library( |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 116 | 'cper-generate', |
| 117 | libcper_generate_sources, |
Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 118 | generator_section_sources, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 119 | version: meson.project_version(), |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 120 | include_directories: libcper_include_dir, |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 121 | dependencies: [libcper_parse_dep, json_c_dep], |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 122 | install: true, |
| 123 | install_dir: get_option('libdir'), |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 124 | ) |
Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 125 | libcper_generate_dep = declare_dependency( |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 126 | include_directories: libcper_include_dir, |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 127 | link_with: libcper_generate, |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 128 | ) |
| 129 | |
Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 130 | import('pkgconfig').generate( |
| 131 | libcper_parse, |
| 132 | name: meson.project_name(), |
| 133 | version: meson.project_version(), |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 134 | description: 'C bindings for parsing CPER', |
Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 135 | ) |
| 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', |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 141 | include_directories: libcper_include_dir, |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 142 | dependencies: [libcper_parse_dep, json_c_dep], |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 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, |
Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 151 | include_directories: libcper_include_dir, |
Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 152 | dependencies: [libcper_generate_dep], |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 153 | install: true, |
| 154 | install_dir: get_option('bindir'), |
| 155 | ) |
John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 156 | endif |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 157 | |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 158 | if get_option('tests').allowed() |
Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 159 | subdir('tests') |
Karthik Rajagopalan | 5220c9b | 2024-08-08 00:24:44 -0700 | [diff] [blame] | 160 | endif |