blob: 6316995c7fe7c2351234ae597a06bb3184685808 [file] [log] [blame]
John Chung197ea122024-05-03 19:57:55 +08001project(
Ed Tanousa5b3d492024-06-18 13:24:05 -07002 'libcper',
Ed Tanous54640292025-03-17 20:55:20 -07003 'c',
Ed Tanousa5b3d492024-06-18 13:24:05 -07004 version: '0.1',
Ed Tanouscd9b1c52025-04-22 08:59:45 -07005 meson_version: '>=1.2.0',
Ed Tanousa5b3d492024-06-18 13:24:05 -07006 default_options: [
7 'c_std=c18',
Ed Tanousa5b3d492024-06-18 13:24:05 -07008 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
Ed Tanousa5b3d492024-06-18 13:24:05 -07009 'warning_level=2',
Ed Tanous0df69a82024-10-03 17:35:11 -070010 'werror=true',
Ed Tanousa5b3d492024-06-18 13:24:05 -070011 ],
12)
John Chung197ea122024-05-03 19:57:55 +080013
Ed Tanous54640292025-03-17 20:55:20 -070014spec_dir = meson.current_source_dir() + '/specification/json'
15example_dir = meson.current_source_dir() + '/examples'
Karthik Rajagopalan45e73322024-07-26 14:27:24 -070016add_project_arguments(
Ed Tanous54640292025-03-17 20:55:20 -070017 [
18 '-DLIBCPER_EXAMPLES="' + example_dir + '"',
19 '-DLIBCPER_JSON_SPEC="' + spec_dir + '"',
20 '-D_POSIX_C_SOURCE=200809L',
Ed Tanous398899a2025-07-25 11:07:32 -070021 '-Wno-gnu-statement-expression-from-macro-expansion',
Ed Tanous54640292025-03-17 20:55:20 -070022 ],
23 language: 'c',
Ed Tanous358c7e12024-07-15 13:54:57 -070024)
25
Andrew Adriance1a908982024-07-02 14:26:10 -070026library_is_share = get_option('default_library') == 'shared'
27
Aushim Nagarkattidd9e8d92025-02-28 11:20:45 -080028if get_option('output-all-properties').enabled()
Ed Tanous54640292025-03-17 20:55:20 -070029 add_project_arguments('-DOUTPUT_ALL_PROPERTIES', language: 'c')
Aushim Nagarkattidd9e8d92025-02-28 11:20:45 -080030endif
31
John Chung197ea122024-05-03 19:57:55 +080032project_description = 'libcper library'
33
Ed Tanous8121f7e2025-03-06 14:39:07 -080034libcper_parse_sources = files(
Ed Tanous10eb6de2024-10-03 17:23:12 -070035 'sections/cper-section-ampere.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070036 'sections/cper-section-arm.c',
37 'sections/cper-section-ccix-per.c',
38 'sections/cper-section-cxl-component.c',
39 'sections/cper-section-cxl-protocol.c',
40 'sections/cper-section-dmar-generic.c',
41 'sections/cper-section-dmar-iommu.c',
42 'sections/cper-section-dmar-vtd.c',
43 'sections/cper-section-firmware.c',
44 'sections/cper-section-generic.c',
45 'sections/cper-section-ia32x64.c',
46 'sections/cper-section-ipf.c',
47 'sections/cper-section-memory.c',
Karthik Rajagopalan683e0552024-03-07 12:30:43 -080048 'sections/cper-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070049 'sections/cper-section-pci-bus.c',
50 'sections/cper-section-pci-dev.c',
51 'sections/cper-section-pcie.c',
52 'sections/cper-section.c',
John Chung197ea122024-05-03 19:57:55 +080053)
54
Ed Tanousa3b7f8a2024-11-04 16:38:59 -080055edk_sources = files('Cper.c')
John Chung197ea122024-05-03 19:57:55 +080056
Ed Tanousd6b62632025-03-14 15:30:07 -070057libcper_generate_sources = files(
Ed Tanous10eb6de2024-10-03 17:23:12 -070058 'generator/sections/gen-section-ampere.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070059 'generator/sections/gen-section-arm.c',
60 'generator/sections/gen-section-ccix-per.c',
61 'generator/sections/gen-section-cxl-component.c',
62 'generator/sections/gen-section-cxl-protocol.c',
63 'generator/sections/gen-section-dmar.c',
64 'generator/sections/gen-section-firmware.c',
65 'generator/sections/gen-section-generic.c',
66 'generator/sections/gen-section-ia32x64.c',
67 'generator/sections/gen-section-memory.c',
Karthik Rajagopalan683e0552024-03-07 12:30:43 -080068 'generator/sections/gen-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070069 'generator/sections/gen-section-pci-bus.c',
70 'generator/sections/gen-section-pci-dev.c',
71 'generator/sections/gen-section-pcie.c',
72 'generator/sections/gen-section.c',
John Chung197ea122024-05-03 19:57:55 +080073)
74
John Chungabc62b82024-05-22 22:45:36 +080075cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080076
Ed Tanouscd9b1c52025-04-22 08:59:45 -070077json_c = dependency('json-c', default_options: {'warning_level': '0'})
78json_c_dep = declare_dependency(
79 include_directories: include_directories('subprojects'),
80 dependencies: json_c,
81)
Ed Tanous50b966f2025-03-11 09:06:19 -070082libcper_include = ['include']
83libcper_include_dir = include_directories(libcper_include, is_system: true)
84
Ed Tanous8121f7e2025-03-06 14:39:07 -080085libcper_parse_sources += files(
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070086 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070087 'common-utils.c',
Ed Tanous0df69a82024-10-03 17:35:11 -070088 'cper-parse.c',
89 'cper-utils.c',
90 'ir-parse.c',
Ed Tanous50b966f2025-03-11 09:06:19 -070091 'log.c',
Ed Tanous0df69a82024-10-03 17:35:11 -070092)
John Chung197ea122024-05-03 19:57:55 +080093
Thu Nguyene42fb482024-10-15 14:43:11 +000094subdir('include')
John Chung197ea122024-05-03 19:57:55 +080095
Ed Tanouscd9b1c52025-04-22 08:59:45 -070096install = get_option('install').allowed()
97
John Chung197ea122024-05-03 19:57:55 +080098libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070099 'cper-parse',
100 libcper_parse_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -0700101 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700102 version: meson.project_version(),
Thu Nguyene42fb482024-10-15 14:43:11 +0000103 include_directories: libcper_include_dir,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700104 c_args: '-Wno-address-of-packed-member',
Ed Tanous10eb6de2024-10-03 17:23:12 -0700105 dependencies: [json_c_dep],
Ed Tanouscd9b1c52025-04-22 08:59:45 -0700106 install: install,
John Chung197ea122024-05-03 19:57:55 +0800107)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700108libcper_parse_dep = declare_dependency(
Thu Nguyene42fb482024-10-15 14:43:11 +0000109 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700110 link_with: [libcper_parse],
John Chung197ea122024-05-03 19:57:55 +0800111)
112
Ed Tanousd6b62632025-03-14 15:30:07 -0700113libcper_generate_sources += files(
Ed Tanous10eb6de2024-10-03 17:23:12 -0700114 'generator/cper-generate.c',
115 'generator/gen-utils.c',
Ed Tanousd6b62632025-03-14 15:30:07 -0700116)
John Chung197ea122024-05-03 19:57:55 +0800117
118libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700119 'cper-generate',
120 libcper_generate_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700121 version: meson.project_version(),
Thu Nguyene42fb482024-10-15 14:43:11 +0000122 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700123 dependencies: [json_c_dep],
124 link_with: [libcper_parse],
Ed Tanouscd9b1c52025-04-22 08:59:45 -0700125 install: install,
John Chung197ea122024-05-03 19:57:55 +0800126)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700127libcper_generate_dep = declare_dependency(
Thu Nguyene42fb482024-10-15 14:43:11 +0000128 include_directories: libcper_include_dir,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700129 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800130)
131
Ed Tanouscd9b1c52025-04-22 08:59:45 -0700132if get_option('pkgconfig').allowed()
133 import('pkgconfig').generate(
134 libcper_parse,
135 name: meson.project_name(),
136 version: meson.project_version(),
137 description: 'C bindings for parsing CPER',
138 )
139endif
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700140
John Chungabc62b82024-05-22 22:45:36 +0800141if get_option('utility').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700142 executable(
143 'cper-convert',
144 'cli-app/cper-convert.c',
Thu Nguyene42fb482024-10-15 14:43:11 +0000145 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700146 dependencies: [json_c_dep],
147 link_with: [libcper_parse, libcper_generate],
Ed Tanouscd9b1c52025-04-22 08:59:45 -0700148 install: install,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700149 install_dir: get_option('bindir'),
150 )
John Chungabc62b82024-05-22 22:45:36 +0800151
Ed Tanousa5b3d492024-06-18 13:24:05 -0700152 executable(
153 'cper-generate',
154 'generator/cper-generate-cli.c',
Ed Tanousa84fc932024-07-15 13:48:35 -0700155 edk_sources,
Thu Nguyene42fb482024-10-15 14:43:11 +0000156 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700157 link_with: [libcper_parse, libcper_generate],
Ed Tanouscd9b1c52025-04-22 08:59:45 -0700158 install: install,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700159 install_dir: get_option('bindir'),
160 )
John Chungabc62b82024-05-22 22:45:36 +0800161endif
John Chung197ea122024-05-03 19:57:55 +0800162
Aushim Nagarkattidd9e8d92025-02-28 11:20:45 -0800163# Disable unit tests when output-all-properties is enabled
164# because it changes CPER-IR output format.
165if get_option('output-all-properties').disabled()
166 if get_option('tests').allowed()
167 subdir('tests')
168 endif
Karthik Rajagopalan5220c9b2024-08-08 00:24:44 -0700169endif
Ed Tanouscd9b1c52025-04-22 08:59:45 -0700170
171if get_option('python').allowed()
172 py = import('python').find_installation(pure: false)
173 py.extension_module(
174 'cper',
175 'pycper.c',
176 c_args: ['-DLIBCPER_PYTHON'],
177 dependencies: [libcper_parse_dep, json_c_dep],
178 install: true,
179 )
180endif