blob: 1ef4da0891979126c2d250cbc1bd3a12f1d1d4fa [file] [log] [blame]
John Chung197ea122024-05-03 19:57:55 +08001project(
Ed Tanousa5b3d492024-06-18 13:24:05 -07002 '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 Chung197ea122024-05-03 19:57:55 +080014
Karthik Rajagopalan45e73322024-07-26 14:27:24 -070015add_project_arguments(
Ed Tanous358c7e12024-07-15 13:54:57 -070016 '-DLIBCPER_JSON_SPEC="'
17 + meson.current_source_dir()
18 + '/specification/json/cper-json.json"',
19 language: ['c', 'cpp'],
20)
21
Andrew Adriance1a908982024-07-02 14:26:10 -070022library_is_share = get_option('default_library') == 'shared'
Karthik Rajagopalan45e73322024-07-26 14:27:24 -070023add_project_arguments('-D_POSIX_C_SOURCE=200809L', language : 'c')
Andrew Adriance1a908982024-07-02 14:26:10 -070024
John Chung197ea122024-05-03 19:57:55 +080025project_description = 'libcper library'
26
Ed Tanousa84fc932024-07-15 13:48:35 -070027section_sources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070028 '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 Rajagopalan683e0552024-03-07 12:30:43 -080040 'sections/cper-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070041 '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 Chung197ea122024-05-03 19:57:55 +080045)
46
Ed Tanousa84fc932024-07-15 13:48:35 -070047edk_sources = files('edk/Cper.c')
John Chung197ea122024-05-03 19:57:55 +080048
Ed Tanousa84fc932024-07-15 13:48:35 -070049generator_section_sources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070050 '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 Rajagopalan683e0552024-03-07 12:30:43 -080059 'generator/sections/gen-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070060 '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 Chung197ea122024-05-03 19:57:55 +080064)
65
John Chungabc62b82024-05-22 22:45:36 +080066cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080067
Ed Tanousa5b3d492024-06-18 13:24:05 -070068json_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
John Chung197ea122024-05-03 19:57:55 +080069
John Chung197ea122024-05-03 19:57:55 +080070libcper_parse_sources = [
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070071 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070072 'cper-parse.c',
73 'ir-parse.c',
74 'cper-utils.c',
75 'common-utils.c',
76 'json-schema.c',
John Chung197ea122024-05-03 19:57:55 +080077]
78
79libcper_include = ['.']
80
81libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070082 'cper-parse',
83 libcper_parse_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -070084 section_sources,
85 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -070086 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 Tanousa5b3d492024-06-18 13:24:05 -070091 ],
92 install: true,
93 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +080094)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -070095libcper_parse_dep = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -070096 include_directories: include_directories(libcper_include),
97 link_with: libcper_parse,
John Chung197ea122024-05-03 19:57:55 +080098)
99
Ed Tanousa5b3d492024-06-18 13:24:05 -0700100libcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
John Chung197ea122024-05-03 19:57:55 +0800101
102libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700103 'cper-generate',
104 libcper_generate_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -0700105 generator_section_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700106 version: meson.project_version(),
107 include_directories: include_directories(libcper_include),
108 dependencies: [
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700109 libcper_parse_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700110 json_c_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700111 ],
112 install: true,
113 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800114)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700115libcper_generate_dep = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700116 include_directories: include_directories(libcper_include),
117 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800118)
119
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700120import('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 Chungabc62b82024-05-22 22:45:36 +0800127install_headers('cper-parse.h')
128install_headers('cper-utils.h')
129install_headers('common-utils.h')
130install_headers('generator/cper-generate.h', subdir: 'generator')
131install_headers('edk/Cper.h', subdir: 'edk')
132install_headers('edk/BaseTypes.h', subdir: 'edk')
John Chung197ea122024-05-03 19:57:55 +0800133
John Chungabc62b82024-05-22 22:45:36 +0800134if get_option('utility').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700135 executable(
136 'cper-convert',
137 'cli-app/cper-convert.c',
138 include_directories: include_directories(libcper_include),
139 dependencies: [
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700140 libcper_parse_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700141 json_c_dep,
142 ],
143 install: true,
144 install_dir: get_option('bindir'),
145 )
John Chungabc62b82024-05-22 22:45:36 +0800146
Ed Tanousa5b3d492024-06-18 13:24:05 -0700147 executable(
148 'cper-generate',
149 'generator/cper-generate-cli.c',
Ed Tanousa84fc932024-07-15 13:48:35 -0700150 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700151 include_directories: include_directories(libcper_include),
152 dependencies: [
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700153 libcper_generate_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700154 ],
155 install: true,
156 install_dir: get_option('bindir'),
157 )
John Chungabc62b82024-05-22 22:45:36 +0800158endif
John Chung197ea122024-05-03 19:57:55 +0800159
John Chung197ea122024-05-03 19:57:55 +0800160if get_option('tests').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700161 subdir('tests')
Ed Tanous358c7e12024-07-15 13:54:57 -0700162endif