| 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', | 
| Ed Tanous | 5464029 | 2025-03-17 20:55:20 -0700 | [diff] [blame] | 3 |     'c', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 4 |     version: '0.1', | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 5 |     meson_version: '>=1.2.0', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 6 |     default_options: [ | 
 | 7 |         'c_std=c18', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 8 |         'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 9 |         'warning_level=2', | 
| Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 10 |         'werror=true', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 11 |     ], | 
 | 12 | ) | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 13 |  | 
| Ed Tanous | 5464029 | 2025-03-17 20:55:20 -0700 | [diff] [blame] | 14 | spec_dir = meson.current_source_dir() + '/specification/json' | 
 | 15 | example_dir = meson.current_source_dir() + '/examples' | 
| Karthik Rajagopalan | 45e7332 | 2024-07-26 14:27:24 -0700 | [diff] [blame] | 16 | add_project_arguments( | 
| Ed Tanous | 5464029 | 2025-03-17 20:55:20 -0700 | [diff] [blame] | 17 |     [ | 
 | 18 |         '-DLIBCPER_EXAMPLES="' + example_dir + '"', | 
 | 19 |         '-DLIBCPER_JSON_SPEC="' + spec_dir + '"', | 
 | 20 |         '-D_POSIX_C_SOURCE=200809L', | 
 | 21 |     ], | 
 | 22 |     language: 'c', | 
| Ed Tanous | 358c7e1 | 2024-07-15 13:54:57 -0700 | [diff] [blame] | 23 | ) | 
 | 24 |  | 
| Andrew Adriance | 1a90898 | 2024-07-02 14:26:10 -0700 | [diff] [blame] | 25 | library_is_share = get_option('default_library') == 'shared' | 
 | 26 |  | 
| Aushim Nagarkatti | dd9e8d9 | 2025-02-28 11:20:45 -0800 | [diff] [blame] | 27 | if get_option('output-all-properties').enabled() | 
| Ed Tanous | 5464029 | 2025-03-17 20:55:20 -0700 | [diff] [blame] | 28 |     add_project_arguments('-DOUTPUT_ALL_PROPERTIES', language: 'c') | 
| Aushim Nagarkatti | dd9e8d9 | 2025-02-28 11:20:45 -0800 | [diff] [blame] | 29 | endif | 
 | 30 |  | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 31 | project_description = 'libcper library' | 
 | 32 |  | 
| Ed Tanous | 8121f7e | 2025-03-06 14:39:07 -0800 | [diff] [blame] | 33 | libcper_parse_sources = files( | 
| Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 34 |     'sections/cper-section-ampere.c', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 35 |     'sections/cper-section-arm.c', | 
 | 36 |     'sections/cper-section-ccix-per.c', | 
 | 37 |     'sections/cper-section-cxl-component.c', | 
 | 38 |     'sections/cper-section-cxl-protocol.c', | 
 | 39 |     'sections/cper-section-dmar-generic.c', | 
 | 40 |     'sections/cper-section-dmar-iommu.c', | 
 | 41 |     'sections/cper-section-dmar-vtd.c', | 
 | 42 |     'sections/cper-section-firmware.c', | 
 | 43 |     'sections/cper-section-generic.c', | 
 | 44 |     'sections/cper-section-ia32x64.c', | 
 | 45 |     'sections/cper-section-ipf.c', | 
 | 46 |     'sections/cper-section-memory.c', | 
| Karthik Rajagopalan | 683e055 | 2024-03-07 12:30:43 -0800 | [diff] [blame] | 47 |     'sections/cper-section-nvidia.c', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 48 |     'sections/cper-section-pci-bus.c', | 
 | 49 |     'sections/cper-section-pci-dev.c', | 
 | 50 |     'sections/cper-section-pcie.c', | 
 | 51 |     'sections/cper-section.c', | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 52 | ) | 
 | 53 |  | 
| Ed Tanous | a3b7f8a | 2024-11-04 16:38:59 -0800 | [diff] [blame] | 54 | edk_sources = files('Cper.c') | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 55 |  | 
| Ed Tanous | d6b6263 | 2025-03-14 15:30:07 -0700 | [diff] [blame] | 56 | libcper_generate_sources = files( | 
| Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 57 |     'generator/sections/gen-section-ampere.c', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 58 |     'generator/sections/gen-section-arm.c', | 
 | 59 |     'generator/sections/gen-section-ccix-per.c', | 
 | 60 |     'generator/sections/gen-section-cxl-component.c', | 
 | 61 |     'generator/sections/gen-section-cxl-protocol.c', | 
 | 62 |     'generator/sections/gen-section-dmar.c', | 
 | 63 |     'generator/sections/gen-section-firmware.c', | 
 | 64 |     'generator/sections/gen-section-generic.c', | 
 | 65 |     'generator/sections/gen-section-ia32x64.c', | 
 | 66 |     'generator/sections/gen-section-memory.c', | 
| Karthik Rajagopalan | 683e055 | 2024-03-07 12:30:43 -0800 | [diff] [blame] | 67 |     'generator/sections/gen-section-nvidia.c', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 68 |     'generator/sections/gen-section-pci-bus.c', | 
 | 69 |     'generator/sections/gen-section-pci-dev.c', | 
 | 70 |     'generator/sections/gen-section-pcie.c', | 
 | 71 |     'generator/sections/gen-section.c', | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 72 | ) | 
 | 73 |  | 
| John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 74 | cc = meson.get_compiler('c') | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 75 |  | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 76 | json_c = dependency('json-c', default_options: {'warning_level': '0'}) | 
 | 77 | json_c_dep = declare_dependency( | 
 | 78 |     include_directories: include_directories('subprojects'), | 
 | 79 |     dependencies: json_c, | 
 | 80 | ) | 
| Ed Tanous | 50b966f | 2025-03-11 09:06:19 -0700 | [diff] [blame] | 81 | libcper_include = ['include'] | 
 | 82 | libcper_include_dir = include_directories(libcper_include, is_system: true) | 
 | 83 |  | 
| Ed Tanous | 8121f7e | 2025-03-06 14:39:07 -0800 | [diff] [blame] | 84 | libcper_parse_sources += files( | 
| Ed Tanous | a7d2cdd | 2024-07-15 11:07:27 -0700 | [diff] [blame] | 85 |     'base64.c', | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 86 |     'common-utils.c', | 
| Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 87 |     'cper-parse.c', | 
 | 88 |     'cper-utils.c', | 
 | 89 |     'ir-parse.c', | 
| Ed Tanous | 50b966f | 2025-03-11 09:06:19 -0700 | [diff] [blame] | 90 |     'log.c', | 
| Ed Tanous | 0df69a8 | 2024-10-03 17:35:11 -0700 | [diff] [blame] | 91 | ) | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 92 |  | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 93 | subdir('include') | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 94 |  | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 95 | install = get_option('install').allowed() | 
 | 96 |  | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 97 | libcper_parse = library( | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 98 |     'cper-parse', | 
 | 99 |     libcper_parse_sources, | 
| Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 100 |     edk_sources, | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 101 |     version: meson.project_version(), | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 102 |     include_directories: libcper_include_dir, | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 103 |     c_args: '-Wno-address-of-packed-member', | 
| Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 104 |     dependencies: [json_c_dep], | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 105 |     install: install, | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 106 | ) | 
| Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 107 | libcper_parse_dep = declare_dependency( | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 108 |     include_directories: libcper_include_dir, | 
| Ed Tanous | 50b966f | 2025-03-11 09:06:19 -0700 | [diff] [blame] | 109 |     link_with: [libcper_parse], | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 110 | ) | 
 | 111 |  | 
| Ed Tanous | d6b6263 | 2025-03-14 15:30:07 -0700 | [diff] [blame] | 112 | libcper_generate_sources += files( | 
| Ed Tanous | 10eb6de | 2024-10-03 17:23:12 -0700 | [diff] [blame] | 113 |     'generator/cper-generate.c', | 
 | 114 |     'generator/gen-utils.c', | 
| Ed Tanous | d6b6263 | 2025-03-14 15:30:07 -0700 | [diff] [blame] | 115 | ) | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 116 |  | 
 | 117 | libcper_generate = library( | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 118 |     'cper-generate', | 
 | 119 |     libcper_generate_sources, | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 120 |     version: meson.project_version(), | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 121 |     include_directories: libcper_include_dir, | 
| Ed Tanous | 50b966f | 2025-03-11 09:06:19 -0700 | [diff] [blame] | 122 |     dependencies: [json_c_dep], | 
 | 123 |     link_with: [libcper_parse], | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 124 |     install: install, | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 125 | ) | 
| Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 126 | libcper_generate_dep = declare_dependency( | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 127 |     include_directories: libcper_include_dir, | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 128 |     link_with: libcper_generate, | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 129 | ) | 
 | 130 |  | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 131 | if get_option('pkgconfig').allowed() | 
 | 132 |     import('pkgconfig').generate( | 
 | 133 |         libcper_parse, | 
 | 134 |         name: meson.project_name(), | 
 | 135 |         version: meson.project_version(), | 
 | 136 |         description: 'C bindings for parsing CPER', | 
 | 137 |     ) | 
 | 138 | endif | 
| Karthik Rajagopalan | 9fe2cb5 | 2024-08-08 15:12:29 -0700 | [diff] [blame] | 139 |  | 
| John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 140 | if get_option('utility').allowed() | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 141 |     executable( | 
 | 142 |         'cper-convert', | 
 | 143 |         'cli-app/cper-convert.c', | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 144 |         include_directories: libcper_include_dir, | 
| Ed Tanous | 50b966f | 2025-03-11 09:06:19 -0700 | [diff] [blame] | 145 |         dependencies: [json_c_dep], | 
 | 146 |         link_with: [libcper_parse, libcper_generate], | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 147 |         install: install, | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 148 |         install_dir: get_option('bindir'), | 
 | 149 |     ) | 
| John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 150 |  | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 151 |     executable( | 
 | 152 |         'cper-generate', | 
 | 153 |         'generator/cper-generate-cli.c', | 
| Ed Tanous | a84fc93 | 2024-07-15 13:48:35 -0700 | [diff] [blame] | 154 |         edk_sources, | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 155 |         include_directories: libcper_include_dir, | 
| Ed Tanous | 50b966f | 2025-03-11 09:06:19 -0700 | [diff] [blame] | 156 |         link_with: [libcper_parse, libcper_generate], | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 157 |         install: install, | 
| Ed Tanous | a5b3d49 | 2024-06-18 13:24:05 -0700 | [diff] [blame] | 158 |         install_dir: get_option('bindir'), | 
 | 159 |     ) | 
| John Chung | abc62b8 | 2024-05-22 22:45:36 +0800 | [diff] [blame] | 160 | endif | 
| John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 161 |  | 
| Aushim Nagarkatti | dd9e8d9 | 2025-02-28 11:20:45 -0800 | [diff] [blame] | 162 | # Disable unit tests when output-all-properties is enabled | 
 | 163 | # because it changes CPER-IR output format. | 
 | 164 | if get_option('output-all-properties').disabled() | 
 | 165 |     if get_option('tests').allowed() | 
 | 166 |         subdir('tests') | 
 | 167 |     endif | 
| Karthik Rajagopalan | 5220c9b | 2024-08-08 00:24:44 -0700 | [diff] [blame] | 168 | endif | 
| Ed Tanous | cd9b1c5 | 2025-04-22 08:59:45 -0700 | [diff] [blame] | 169 |  | 
 | 170 | if get_option('python').allowed() | 
 | 171 |     py = import('python').find_installation(pure: false) | 
 | 172 |     py.extension_module( | 
 | 173 |         'cper', | 
 | 174 |         'pycper.c', | 
 | 175 |         c_args: ['-DLIBCPER_PYTHON'], | 
 | 176 |         dependencies: [libcper_parse_dep, json_c_dep], | 
 | 177 |         install: true, | 
 | 178 |     ) | 
 | 179 | endif |