blob: 96e194c7c87e999a8b1adf7983190af7eefb3750 [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'),
Ed Tanousa5b3d492024-06-18 13:24:05 -070010 'warning_level=2',
Ed Tanous0df69a82024-10-03 17:35:11 -070011 'werror=true',
Ed Tanousa5b3d492024-06-18 13:24:05 -070012 ],
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="'
Ed Tanousd6b62632025-03-14 15:30:07 -070017 + meson.current_source_dir() + '/specification/json"',
Ed Tanous358c7e12024-07-15 13:54:57 -070018 language: ['c', 'cpp'],
19)
20
Aushim Nagarkatti517282f2025-03-03 17:08:31 -080021add_project_arguments('-DLIBCPER_EXAMPLES="'
22 + meson.current_source_dir() + '/examples"', language: ['c', 'cpp'])
Aushim Nagarkattiae8f6d92025-01-29 17:34:44 -080023
Ed Tanousedee0a32025-03-16 17:40:04 -070024add_project_arguments('-Wno-unused-function', language: ['c', 'cpp'])
25
Andrew Adriance1a908982024-07-02 14:26:10 -070026library_is_share = get_option('default_library') == 'shared'
Ed Tanous10eb6de2024-10-03 17:23:12 -070027add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c')
Andrew Adriance1a908982024-07-02 14:26:10 -070028
Aushim Nagarkattidd9e8d92025-02-28 11:20:45 -080029if get_option('output-all-properties').enabled()
30 add_project_arguments('-DOUTPUT_ALL_PROPERTIES', language: ['c', 'cpp'])
31endif
32
John Chung197ea122024-05-03 19:57:55 +080033project_description = 'libcper library'
34
Ed Tanous8121f7e2025-03-06 14:39:07 -080035libcper_parse_sources = files(
Ed Tanous10eb6de2024-10-03 17:23:12 -070036 'sections/cper-section-ampere.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070037 'sections/cper-section-arm.c',
38 'sections/cper-section-ccix-per.c',
39 'sections/cper-section-cxl-component.c',
40 'sections/cper-section-cxl-protocol.c',
41 'sections/cper-section-dmar-generic.c',
42 'sections/cper-section-dmar-iommu.c',
43 'sections/cper-section-dmar-vtd.c',
44 'sections/cper-section-firmware.c',
45 'sections/cper-section-generic.c',
46 'sections/cper-section-ia32x64.c',
47 'sections/cper-section-ipf.c',
48 'sections/cper-section-memory.c',
Karthik Rajagopalan683e0552024-03-07 12:30:43 -080049 'sections/cper-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070050 'sections/cper-section-pci-bus.c',
51 'sections/cper-section-pci-dev.c',
52 'sections/cper-section-pcie.c',
53 'sections/cper-section.c',
John Chung197ea122024-05-03 19:57:55 +080054)
55
Ed Tanousa3b7f8a2024-11-04 16:38:59 -080056edk_sources = files('Cper.c')
John Chung197ea122024-05-03 19:57:55 +080057
Ed Tanousd6b62632025-03-14 15:30:07 -070058libcper_generate_sources = files(
Ed Tanous10eb6de2024-10-03 17:23:12 -070059 'generator/sections/gen-section-ampere.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070060 'generator/sections/gen-section-arm.c',
61 'generator/sections/gen-section-ccix-per.c',
62 'generator/sections/gen-section-cxl-component.c',
63 'generator/sections/gen-section-cxl-protocol.c',
64 'generator/sections/gen-section-dmar.c',
65 'generator/sections/gen-section-firmware.c',
66 'generator/sections/gen-section-generic.c',
67 'generator/sections/gen-section-ia32x64.c',
68 'generator/sections/gen-section-memory.c',
Karthik Rajagopalan683e0552024-03-07 12:30:43 -080069 'generator/sections/gen-section-nvidia.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070070 'generator/sections/gen-section-pci-bus.c',
71 'generator/sections/gen-section-pci-dev.c',
72 'generator/sections/gen-section-pcie.c',
73 'generator/sections/gen-section.c',
John Chung197ea122024-05-03 19:57:55 +080074)
75
John Chungabc62b82024-05-22 22:45:36 +080076cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080077
Ed Tanousa3663052025-03-16 12:54:36 -070078json_c_dep = dependency('json-c')
Ed Tanous50b966f2025-03-11 09:06:19 -070079libcper_include = ['include']
80libcper_include_dir = include_directories(libcper_include, is_system: true)
81
Ed Tanous8121f7e2025-03-06 14:39:07 -080082libcper_parse_sources += files(
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070083 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070084 'common-utils.c',
Ed Tanous0df69a82024-10-03 17:35:11 -070085 'cper-parse.c',
86 'cper-utils.c',
87 'ir-parse.c',
Ed Tanous50b966f2025-03-11 09:06:19 -070088 'log.c',
Ed Tanous0df69a82024-10-03 17:35:11 -070089)
John Chung197ea122024-05-03 19:57:55 +080090
Thu Nguyene42fb482024-10-15 14:43:11 +000091subdir('include')
John Chung197ea122024-05-03 19:57:55 +080092
93libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070094 'cper-parse',
95 libcper_parse_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -070096 edk_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -070097 version: meson.project_version(),
Thu Nguyene42fb482024-10-15 14:43:11 +000098 include_directories: libcper_include_dir,
Ed Tanousa5b3d492024-06-18 13:24:05 -070099 c_args: '-Wno-address-of-packed-member',
Ed Tanous10eb6de2024-10-03 17:23:12 -0700100 dependencies: [json_c_dep],
Ed Tanousa5b3d492024-06-18 13:24:05 -0700101 install: true,
102 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800103)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700104libcper_parse_dep = declare_dependency(
Thu Nguyene42fb482024-10-15 14:43:11 +0000105 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700106 link_with: [libcper_parse],
John Chung197ea122024-05-03 19:57:55 +0800107)
108
Ed Tanousd6b62632025-03-14 15:30:07 -0700109libcper_generate_sources += files(
Ed Tanous10eb6de2024-10-03 17:23:12 -0700110 'generator/cper-generate.c',
111 'generator/gen-utils.c',
Ed Tanousd6b62632025-03-14 15:30:07 -0700112)
John Chung197ea122024-05-03 19:57:55 +0800113
114libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700115 'cper-generate',
116 libcper_generate_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700117 version: meson.project_version(),
Thu Nguyene42fb482024-10-15 14:43:11 +0000118 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700119 dependencies: [json_c_dep],
120 link_with: [libcper_parse],
Ed Tanousa5b3d492024-06-18 13:24:05 -0700121 install: true,
122 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800123)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700124libcper_generate_dep = declare_dependency(
Thu Nguyene42fb482024-10-15 14:43:11 +0000125 include_directories: libcper_include_dir,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700126 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800127)
128
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700129import('pkgconfig').generate(
130 libcper_parse,
131 name: meson.project_name(),
132 version: meson.project_version(),
Ed Tanous10eb6de2024-10-03 17:23:12 -0700133 description: 'C bindings for parsing CPER',
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700134)
135
John Chungabc62b82024-05-22 22:45:36 +0800136if get_option('utility').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700137 executable(
138 'cper-convert',
139 'cli-app/cper-convert.c',
Thu Nguyene42fb482024-10-15 14:43:11 +0000140 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700141 dependencies: [json_c_dep],
142 link_with: [libcper_parse, libcper_generate],
Ed Tanousa5b3d492024-06-18 13:24:05 -0700143 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,
Thu Nguyene42fb482024-10-15 14:43:11 +0000151 include_directories: libcper_include_dir,
Ed Tanous50b966f2025-03-11 09:06:19 -0700152 link_with: [libcper_parse, libcper_generate],
Ed Tanousa5b3d492024-06-18 13:24:05 -0700153 install: true,
154 install_dir: get_option('bindir'),
155 )
John Chungabc62b82024-05-22 22:45:36 +0800156endif
John Chung197ea122024-05-03 19:57:55 +0800157
Aushim Nagarkattidd9e8d92025-02-28 11:20:45 -0800158# Disable unit tests when output-all-properties is enabled
159# because it changes CPER-IR output format.
160if get_option('output-all-properties').disabled()
161 if get_option('tests').allowed()
162 subdir('tests')
163 endif
Karthik Rajagopalan5220c9b2024-08-08 00:24:44 -0700164endif