blob: 1f9287b8c8f66f2ac885c3c74848dd169afa66d2 [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
Andrew Adriance1a908982024-07-02 14:26:10 -070015library_is_share = get_option('default_library') == 'shared'
16
John Chung197ea122024-05-03 19:57:55 +080017project_description = 'libcper library'
18
19SectionSources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070020 'sections/cper-section-arm.c',
21 'sections/cper-section-ccix-per.c',
22 'sections/cper-section-cxl-component.c',
23 'sections/cper-section-cxl-protocol.c',
24 'sections/cper-section-dmar-generic.c',
25 'sections/cper-section-dmar-iommu.c',
26 'sections/cper-section-dmar-vtd.c',
27 'sections/cper-section-firmware.c',
28 'sections/cper-section-generic.c',
29 'sections/cper-section-ia32x64.c',
30 'sections/cper-section-ipf.c',
31 'sections/cper-section-memory.c',
32 'sections/cper-section-pci-bus.c',
33 'sections/cper-section-pci-dev.c',
34 'sections/cper-section-pcie.c',
35 'sections/cper-section.c',
John Chung197ea122024-05-03 19:57:55 +080036)
37
Ed Tanousa5b3d492024-06-18 13:24:05 -070038EDKSources = files('edk/Cper.c')
John Chung197ea122024-05-03 19:57:55 +080039
40GeneratorSectionSources = files(
Ed Tanousa5b3d492024-06-18 13:24:05 -070041 'generator/sections/gen-section-arm.c',
42 'generator/sections/gen-section-ccix-per.c',
43 'generator/sections/gen-section-cxl-component.c',
44 'generator/sections/gen-section-cxl-protocol.c',
45 'generator/sections/gen-section-dmar.c',
46 'generator/sections/gen-section-firmware.c',
47 'generator/sections/gen-section-generic.c',
48 'generator/sections/gen-section-ia32x64.c',
49 'generator/sections/gen-section-memory.c',
50 'generator/sections/gen-section-pci-bus.c',
51 'generator/sections/gen-section-pci-dev.c',
52 'generator/sections/gen-section-pcie.c',
53 'generator/sections/gen-section.c',
John Chung197ea122024-05-03 19:57:55 +080054)
55
56cmake = import('cmake')
John Chungabc62b82024-05-22 22:45:36 +080057cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080058
Ed Tanousa5b3d492024-06-18 13:24:05 -070059json_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
John Chung197ea122024-05-03 19:57:55 +080060
John Chung197ea122024-05-03 19:57:55 +080061libcper_parse_sources = [
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070062 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070063 'cper-parse.c',
64 'ir-parse.c',
65 'cper-utils.c',
66 'common-utils.c',
67 'json-schema.c',
John Chung197ea122024-05-03 19:57:55 +080068]
69
70libcper_include = ['.']
71
72libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070073 'cper-parse',
74 libcper_parse_sources,
75 SectionSources,
76 EDKSources,
77 version: meson.project_version(),
78 include_directories: include_directories(libcper_include),
79 c_args: '-Wno-address-of-packed-member',
80 dependencies: [
81 json_c_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -070082 ],
83 install: true,
84 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +080085)
86libcper_parse = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -070087 include_directories: include_directories(libcper_include),
88 link_with: libcper_parse,
John Chung197ea122024-05-03 19:57:55 +080089)
90
Ed Tanousa5b3d492024-06-18 13:24:05 -070091libcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
John Chung197ea122024-05-03 19:57:55 +080092
93libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070094 'cper-generate',
95 libcper_generate_sources,
96 GeneratorSectionSources,
97 version: meson.project_version(),
98 include_directories: include_directories(libcper_include),
99 dependencies: [
100 libcper_parse,
101 json_c_dep,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700102 ],
103 install: true,
104 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800105)
106libcper_generate = declare_dependency(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700107 include_directories: include_directories(libcper_include),
108 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800109)
110
John Chungabc62b82024-05-22 22:45:36 +0800111install_headers('cper-parse.h')
112install_headers('cper-utils.h')
113install_headers('common-utils.h')
114install_headers('generator/cper-generate.h', subdir: 'generator')
115install_headers('edk/Cper.h', subdir: 'edk')
116install_headers('edk/BaseTypes.h', subdir: 'edk')
John Chung197ea122024-05-03 19:57:55 +0800117
John Chungabc62b82024-05-22 22:45:36 +0800118if get_option('utility').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700119 executable(
120 'cper-convert',
121 'cli-app/cper-convert.c',
122 include_directories: include_directories(libcper_include),
123 dependencies: [
124 libcper_parse,
125 json_c_dep,
126 ],
127 install: true,
128 install_dir: get_option('bindir'),
129 )
John Chungabc62b82024-05-22 22:45:36 +0800130
Ed Tanousa5b3d492024-06-18 13:24:05 -0700131 executable(
132 'cper-generate',
133 'generator/cper-generate-cli.c',
134 EDKSources,
135 include_directories: include_directories(libcper_include),
136 dependencies: [
137 libcper_generate,
138 ],
139 install: true,
140 install_dir: get_option('bindir'),
141 )
John Chungabc62b82024-05-22 22:45:36 +0800142endif
John Chung197ea122024-05-03 19:57:55 +0800143
Ed Tanous1e267b62024-06-18 13:20:42 -0700144run_command('cp', '-r', 'specification/json/', meson.current_build_dir(), check: true)
Ed Tanousa5b3d492024-06-18 13:24:05 -0700145run_command(
146 'mv',
147 meson.current_build_dir() / 'json',
148 meson.current_build_dir() / 'specification',
149)
John Chung197ea122024-05-03 19:57:55 +0800150
151if get_option('tests').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700152 subdir('tests')
John Chung197ea122024-05-03 19:57:55 +0800153endif