blob: 1eee4ec53232e723cd945f1e01067bfac155cc23 [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',
Dung Cao04f57712024-08-29 08:03:59 +000045 'sections/cper-section-ampere.c',
John Chung197ea122024-05-03 19:57:55 +080046)
47
Ed Tanousa84fc932024-07-15 13:48:35 -070048edk_sources = files('edk/Cper.c')
John Chung197ea122024-05-03 19:57:55 +080049
Ed Tanousa84fc932024-07-15 13:48:35 -070050generator_section_sources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070051 '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 Rajagopalan683e0552024-03-07 12:30:43 -080060 'generator/sections/gen-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070061 '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 Cao04f57712024-08-29 08:03:59 +000065 'generator/sections/gen-section-ampere.c',
John Chung197ea122024-05-03 19:57:55 +080066)
67
John Chungabc62b82024-05-22 22:45:36 +080068cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080069
Ed Tanousa5b3d492024-06-18 13:24:05 -070070json_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
John Chung197ea122024-05-03 19:57:55 +080071
John Chung197ea122024-05-03 19:57:55 +080072libcper_parse_sources = [
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070073 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070074 'cper-parse.c',
75 'ir-parse.c',
76 'cper-utils.c',
77 'common-utils.c',
78 'json-schema.c',
John Chung197ea122024-05-03 19:57:55 +080079]
80
81libcper_include = ['.']
82
83libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070084 'cper-parse',
85 libcper_parse_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -070086 section_sources,
87 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -070088 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 Tanousa5b3d492024-06-18 13:24:05 -070093 ],
94 install: true,
95 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +080096)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -070097libcper_parse_dep = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -070098 include_directories: include_directories(libcper_include),
99 link_with: libcper_parse,
John Chung197ea122024-05-03 19:57:55 +0800100)
101
Ed Tanousa5b3d492024-06-18 13:24:05 -0700102libcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
John Chung197ea122024-05-03 19:57:55 +0800103
104libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700105 'cper-generate',
106 libcper_generate_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -0700107 generator_section_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700108 version: meson.project_version(),
109 include_directories: include_directories(libcper_include),
110 dependencies: [
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700111 libcper_parse_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700112 json_c_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700113 ],
114 install: true,
115 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800116)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700117libcper_generate_dep = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700118 include_directories: include_directories(libcper_include),
119 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800120)
121
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700122import('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 Chungabc62b82024-05-22 22:45:36 +0800129install_headers('cper-parse.h')
Karthik Rajagopalan5220c9b2024-08-08 00:24:44 -0700130install_headers('cper-parse-str.h')
John Chungabc62b82024-05-22 22:45:36 +0800131install_headers('cper-utils.h')
132install_headers('common-utils.h')
133install_headers('generator/cper-generate.h', subdir: 'generator')
134install_headers('edk/Cper.h', subdir: 'edk')
135install_headers('edk/BaseTypes.h', subdir: 'edk')
John Chung197ea122024-05-03 19:57:55 +0800136
John Chungabc62b82024-05-22 22:45:36 +0800137if get_option('utility').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700138 executable(
139 'cper-convert',
140 'cli-app/cper-convert.c',
141 include_directories: include_directories(libcper_include),
142 dependencies: [
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700143 libcper_parse_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700144 json_c_dep,
145 ],
146 install: true,
147 install_dir: get_option('bindir'),
148 )
John Chungabc62b82024-05-22 22:45:36 +0800149
Ed Tanousa5b3d492024-06-18 13:24:05 -0700150 executable(
151 'cper-generate',
152 'generator/cper-generate-cli.c',
Ed Tanousa84fc932024-07-15 13:48:35 -0700153 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700154 include_directories: include_directories(libcper_include),
155 dependencies: [
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700156 libcper_generate_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700157 ],
158 install: true,
159 install_dir: get_option('bindir'),
160 )
John Chungabc62b82024-05-22 22:45:36 +0800161endif
John Chung197ea122024-05-03 19:57:55 +0800162
John Chung197ea122024-05-03 19:57:55 +0800163if get_option('tests').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700164 subdir('tests')
Karthik Rajagopalan5220c9b2024-08-08 00:24:44 -0700165endif