blob: 04b8094d861528db767d50ebe6b59acaf90534f2 [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
Ed Tanous358c7e12024-07-15 13:54:57 -070015add_global_arguments(
16 '-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'
23
John Chung197ea122024-05-03 19:57:55 +080024project_description = 'libcper library'
25
Ed Tanousa84fc932024-07-15 13:48:35 -070026section_sources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070027 'sections/cper-section-arm.c',
28 'sections/cper-section-ccix-per.c',
29 'sections/cper-section-cxl-component.c',
30 'sections/cper-section-cxl-protocol.c',
31 'sections/cper-section-dmar-generic.c',
32 'sections/cper-section-dmar-iommu.c',
33 'sections/cper-section-dmar-vtd.c',
34 'sections/cper-section-firmware.c',
35 'sections/cper-section-generic.c',
36 'sections/cper-section-ia32x64.c',
37 'sections/cper-section-ipf.c',
38 'sections/cper-section-memory.c',
39 'sections/cper-section-pci-bus.c',
40 'sections/cper-section-pci-dev.c',
41 'sections/cper-section-pcie.c',
42 'sections/cper-section.c',
John Chung197ea122024-05-03 19:57:55 +080043)
44
Ed Tanousa84fc932024-07-15 13:48:35 -070045edk_sources = files('edk/Cper.c')
John Chung197ea122024-05-03 19:57:55 +080046
Ed Tanousa84fc932024-07-15 13:48:35 -070047generator_section_sources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070048 'generator/sections/gen-section-arm.c',
49 'generator/sections/gen-section-ccix-per.c',
50 'generator/sections/gen-section-cxl-component.c',
51 'generator/sections/gen-section-cxl-protocol.c',
52 'generator/sections/gen-section-dmar.c',
53 'generator/sections/gen-section-firmware.c',
54 'generator/sections/gen-section-generic.c',
55 'generator/sections/gen-section-ia32x64.c',
56 'generator/sections/gen-section-memory.c',
57 'generator/sections/gen-section-pci-bus.c',
58 'generator/sections/gen-section-pci-dev.c',
59 'generator/sections/gen-section-pcie.c',
60 'generator/sections/gen-section.c',
John Chung197ea122024-05-03 19:57:55 +080061)
62
John Chungabc62b82024-05-22 22:45:36 +080063cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080064
Ed Tanousa5b3d492024-06-18 13:24:05 -070065json_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
John Chung197ea122024-05-03 19:57:55 +080066
John Chung197ea122024-05-03 19:57:55 +080067libcper_parse_sources = [
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070068 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070069 'cper-parse.c',
70 'ir-parse.c',
71 'cper-utils.c',
72 'common-utils.c',
73 'json-schema.c',
John Chung197ea122024-05-03 19:57:55 +080074]
75
76libcper_include = ['.']
77
78libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070079 'cper-parse',
80 libcper_parse_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -070081 section_sources,
82 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -070083 version: meson.project_version(),
84 include_directories: include_directories(libcper_include),
85 c_args: '-Wno-address-of-packed-member',
86 dependencies: [
87 json_c_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -070088 ],
89 install: true,
90 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +080091)
92libcper_parse = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -070093 include_directories: include_directories(libcper_include),
94 link_with: libcper_parse,
John Chung197ea122024-05-03 19:57:55 +080095)
96
Ed Tanousa5b3d492024-06-18 13:24:05 -070097libcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
John Chung197ea122024-05-03 19:57:55 +080098
99libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700100 'cper-generate',
101 libcper_generate_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -0700102 generator_section_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700103 version: meson.project_version(),
104 include_directories: include_directories(libcper_include),
105 dependencies: [
106 libcper_parse,
107 json_c_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700108 ],
109 install: true,
110 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800111)
112libcper_generate = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700113 include_directories: include_directories(libcper_include),
114 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800115)
116
John Chungabc62b82024-05-22 22:45:36 +0800117install_headers('cper-parse.h')
118install_headers('cper-utils.h')
119install_headers('common-utils.h')
120install_headers('generator/cper-generate.h', subdir: 'generator')
121install_headers('edk/Cper.h', subdir: 'edk')
122install_headers('edk/BaseTypes.h', subdir: 'edk')
John Chung197ea122024-05-03 19:57:55 +0800123
John Chungabc62b82024-05-22 22:45:36 +0800124if get_option('utility').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700125 executable(
126 'cper-convert',
127 'cli-app/cper-convert.c',
128 include_directories: include_directories(libcper_include),
129 dependencies: [
130 libcper_parse,
131 json_c_dep,
132 ],
133 install: true,
134 install_dir: get_option('bindir'),
135 )
John Chungabc62b82024-05-22 22:45:36 +0800136
Ed Tanousa5b3d492024-06-18 13:24:05 -0700137 executable(
138 'cper-generate',
139 'generator/cper-generate-cli.c',
Ed Tanousa84fc932024-07-15 13:48:35 -0700140 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700141 include_directories: include_directories(libcper_include),
142 dependencies: [
143 libcper_generate,
144 ],
145 install: true,
146 install_dir: get_option('bindir'),
147 )
John Chungabc62b82024-05-22 22:45:36 +0800148endif
John Chung197ea122024-05-03 19:57:55 +0800149
John Chung197ea122024-05-03 19:57:55 +0800150if get_option('tests').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700151 subdir('tests')
Ed Tanous358c7e12024-07-15 13:54:57 -0700152endif