blob: 732d5a28c9c017384226a2f4f02ae1f8ea8ef1f7 [file] [log] [blame]
John Chung197ea122024-05-03 19:57:55 +08001project(
2 'libcper', ['c', 'cpp'],
3 version: '0.1',
4 meson_version: '>=1.1.1',
5 default_options: [
6 'c_std=c18',
7 'cpp_std=c++23',
8 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
9 'werror=true',
10 'warning_level=2',
11 ])
12
13project_description = 'libcper library'
14
15SectionSources = files(
16 'sections/cper-section-arm.c',
17 'sections/cper-section.c',
18 'sections/cper-section-ccix-per.c',
19 'sections/cper-section-cxl-component.c',
20 'sections/cper-section-cxl-protocol.c',
21 'sections/cper-section-dmar-generic.c',
22 'sections/cper-section-dmar-iommu.c',
23 'sections/cper-section-dmar-vtd.c',
24 'sections/cper-section-firmware.c',
25 'sections/cper-section-generic.c',
26 'sections/cper-section-ia32x64.c',
27 'sections/cper-section-ipf.c',
28 'sections/cper-section-memory.c',
29 'sections/cper-section-pci-bus.c',
30 'sections/cper-section-pci-dev.c',
31 'sections/cper-section-pcie.c'
32)
33
34EDKSources = files(
35 'edk/Cper.c'
36)
37
38GeneratorSectionSources = files(
39 'generator/sections/gen-section-arm.c',
40 'generator/sections/gen-section.c',
41 'generator/sections/gen-section-ccix-per.c',
42 'generator/sections/gen-section-cxl-component.c',
43 'generator/sections/gen-section-cxl-protocol.c',
44 'generator/sections/gen-section-dmar.c',
45 'generator/sections/gen-section-firmware.c',
46 'generator/sections/gen-section-generic.c',
47 'generator/sections/gen-section-ia32x64.c',
48 'generator/sections/gen-section-memory.c',
49 'generator/sections/gen-section-pci-bus.c',
50 'generator/sections/gen-section-pci-dev.c',
51 'generator/sections/gen-section-pcie.c'
52)
53
54cmake = import('cmake')
John Chungabc62b82024-05-22 22:45:36 +080055cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080056
57json_c_dep = dependency(
58 'json-c',
59 required: true,
60 fallback : ['json-c', 'json_c_dep'])
61
John Chungabc62b82024-05-22 22:45:36 +080062libb64 = cc.find_library('base64', has_headers: 'libbase64.h', required: false)
John Chung197ea122024-05-03 19:57:55 +080063if not libb64.found()
64 opt_var = cmake.subproject_options()
65 opt_var.add_cmake_defines({
66 'BUILD_SHARED_LIBS': true,
John Chungabc62b82024-05-22 22:45:36 +080067 'BASE64_BUILD_CLI': false,
John Chung197ea122024-05-03 19:57:55 +080068 'BASE64_WITH_AVX': false,
69 'BASE64_WITH_AVX2': false,
70 'BASE64_WITH_AVX512': false,
71 'BASE64_WITH_SSSE3': false,
72 'BASE64_WITH_SSE41': false,
73 'BASE64_WITH_SSE42': false})
74
75 libb64_ex = cmake.subproject('libb64', options: opt_var)
76 libb64 = libb64_ex.dependency('base64')
77endif
78
79libcper_parse_sources = [
80 'cper-parse.c',
81 'ir-parse.c',
82 'cper-utils.c',
83 'common-utils.c',
84 'json-schema.c'
85]
86
87libcper_include = ['.']
88
89libcper_parse = library(
90 'cper-parse',
91 libcper_parse_sources,
92 SectionSources,
93 EDKSources,
94 version: meson.project_version(),
95 include_directories:include_directories(libcper_include),
96 c_args: '-Wno-address-of-packed-member',
97 dependencies: [
98 json_c_dep,
99 libb64,
100 ],
101 install: true,
102 install_dir: get_option('libdir')
103)
104libcper_parse = declare_dependency(
105 include_directories: include_directories(libcper_include),
106 link_with: libcper_parse
107)
108
109
110libcper_generate_sources = [
111 'generator/cper-generate.c',
112 'generator/gen-utils.c',
113 'common-utils.c'
114]
115
116libcper_generate = library(
117 'cper-generate',
118 libcper_generate_sources,
119 GeneratorSectionSources,
120 version: meson.project_version(),
121 include_directories:include_directories(libcper_include),
122 dependencies: [
123 libcper_parse,
124 json_c_dep,
125 libb64,
126 ],
127 install: true,
128 install_dir: get_option('libdir')
129)
130libcper_generate = declare_dependency(
131 include_directories: include_directories(libcper_include),
132 link_with: libcper_generate
133)
134
John Chungabc62b82024-05-22 22:45:36 +0800135install_headers('cper-parse.h')
136install_headers('cper-utils.h')
137install_headers('common-utils.h')
138install_headers('generator/cper-generate.h', subdir: 'generator')
139install_headers('edk/Cper.h', subdir: 'edk')
140install_headers('edk/BaseTypes.h', subdir: 'edk')
John Chung197ea122024-05-03 19:57:55 +0800141
John Chungabc62b82024-05-22 22:45:36 +0800142if get_option('utility').allowed()
143 executable(
144 'cper-convert',
145 'cli-app/cper-convert.c',
146 include_directories:include_directories(libcper_include),
147 dependencies: [
148 libcper_parse,
149 json_c_dep,
150 ],
151 install: true,
152 install_dir: get_option('bindir')
153 )
154
155 executable(
156 'cper-generate',
157 'generator/cper-generate-cli.c',
158 EDKSources,
159 include_directories:include_directories(libcper_include),
160 dependencies: [
161 libcper_generate,
162 ],
163 install: true,
164 install_dir: get_option('bindir')
165 )
166endif
John Chung197ea122024-05-03 19:57:55 +0800167
168run_command('cp', '-r', 'specification/json/', meson.current_build_dir())
169run_command('mv', meson.current_build_dir() / 'json', meson.current_build_dir() / 'specification')
170
171if get_option('tests').allowed()
172 subdir('tests')
173endif
174