blob: fb4a399e21f264306084ba7ed8d0330f944517df [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 Tanous10eb6de2024-10-03 17:23:12 -070017 + meson.current_source_dir() + '/specification/json/cper-json.json"',
Ed Tanous358c7e12024-07-15 13:54:57 -070018 language: ['c', 'cpp'],
19)
20
Andrew Adriance1a908982024-07-02 14:26:10 -070021library_is_share = get_option('default_library') == 'shared'
Ed Tanous10eb6de2024-10-03 17:23:12 -070022add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c')
Andrew Adriance1a908982024-07-02 14:26:10 -070023
John Chung197ea122024-05-03 19:57:55 +080024project_description = 'libcper library'
25
Ed Tanousa84fc932024-07-15 13:48:35 -070026section_sources = files(
Ed Tanous10eb6de2024-10-03 17:23:12 -070027 'sections/cper-section-ampere.c',
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',
John Chung197ea122024-05-03 19:57:55 +080045)
46
Ed Tanousa3b7f8a2024-11-04 16:38:59 -080047edk_sources = files('Cper.c')
John Chung197ea122024-05-03 19:57:55 +080048
Ed Tanousa84fc932024-07-15 13:48:35 -070049generator_section_sources = files(
Ed Tanous10eb6de2024-10-03 17:23:12 -070050 'generator/sections/gen-section-ampere.c',
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',
John Chung197ea122024-05-03 19:57:55 +080065)
66
John Chungabc62b82024-05-22 22:45:36 +080067cc = meson.get_compiler('c')
John Chung197ea122024-05-03 19:57:55 +080068
Ed Tanouseed88bb2024-10-03 17:18:20 -070069json_c_dep = dependency('json-c', required: false)
70if not json_c_dep.found()
Ed Tanous10eb6de2024-10-03 17:23:12 -070071 json_c = subproject(
72 'json-c',
73 required: true,
74 default_options: ['warning_level=0'],
75 )
Ed Tanouseed88bb2024-10-03 17:18:20 -070076 json_c_dep = json_c.get_variable('json_c_dep')
77endif
John Chung197ea122024-05-03 19:57:55 +080078
Ed Tanous0df69a82024-10-03 17:35:11 -070079libcper_parse_sources = files(
Ed Tanousa7d2cdd2024-07-15 11:07:27 -070080 'base64.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070081 'common-utils.c',
Ed Tanous0df69a82024-10-03 17:35:11 -070082 'cper-parse.c',
83 'cper-utils.c',
84 'ir-parse.c',
Ed Tanousa5b3d492024-06-18 13:24:05 -070085 'json-schema.c',
Ed Tanous0df69a82024-10-03 17:35:11 -070086)
John Chung197ea122024-05-03 19:57:55 +080087
Thu Nguyene42fb482024-10-15 14:43:11 +000088libcper_include = ['include']
89libcper_include_dir = include_directories(libcper_include, is_system: true)
90subdir('include')
John Chung197ea122024-05-03 19:57:55 +080091
92libcper_parse = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -070093 'cper-parse',
94 libcper_parse_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -070095 section_sources,
96 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 Tanousa5b3d492024-06-18 13:24:05 -0700106 link_with: libcper_parse,
John Chung197ea122024-05-03 19:57:55 +0800107)
108
Ed Tanous10eb6de2024-10-03 17:23:12 -0700109libcper_generate_sources = [
Ed Tanous0df69a82024-10-03 17:35:11 -0700110 'common-utils.c',
Ed Tanous10eb6de2024-10-03 17:23:12 -0700111 'generator/cper-generate.c',
112 'generator/gen-utils.c',
Ed Tanous10eb6de2024-10-03 17:23:12 -0700113]
John Chung197ea122024-05-03 19:57:55 +0800114
115libcper_generate = library(
Ed Tanousa5b3d492024-06-18 13:24:05 -0700116 'cper-generate',
117 libcper_generate_sources,
Ed Tanousa84fc932024-07-15 13:48:35 -0700118 generator_section_sources,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700119 version: meson.project_version(),
Thu Nguyene42fb482024-10-15 14:43:11 +0000120 include_directories: libcper_include_dir,
Ed Tanous10eb6de2024-10-03 17:23:12 -0700121 dependencies: [libcper_parse_dep, json_c_dep],
Ed Tanousa5b3d492024-06-18 13:24:05 -0700122 install: true,
123 install_dir: get_option('libdir'),
John Chung197ea122024-05-03 19:57:55 +0800124)
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700125libcper_generate_dep = declare_dependency(
Thu Nguyene42fb482024-10-15 14:43:11 +0000126 include_directories: libcper_include_dir,
Ed Tanousa5b3d492024-06-18 13:24:05 -0700127 link_with: libcper_generate,
John Chung197ea122024-05-03 19:57:55 +0800128)
129
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700130import('pkgconfig').generate(
131 libcper_parse,
132 name: meson.project_name(),
133 version: meson.project_version(),
Ed Tanous10eb6de2024-10-03 17:23:12 -0700134 description: 'C bindings for parsing CPER',
Karthik Rajagopalan9fe2cb52024-08-08 15:12:29 -0700135)
136
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',
Thu Nguyene42fb482024-10-15 14:43:11 +0000141 include_directories: libcper_include_dir,
Ed Tanous10eb6de2024-10-03 17:23:12 -0700142 dependencies: [libcper_parse_dep, json_c_dep],
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 Tanous10eb6de2024-10-03 17:23:12 -0700152 dependencies: [libcper_generate_dep],
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
John Chung197ea122024-05-03 19:57:55 +0800158if get_option('tests').allowed()
Ed Tanousa5b3d492024-06-18 13:24:05 -0700159 subdir('tests')
Karthik Rajagopalan5220c9b2024-08-08 00:24:44 -0700160endif