xref: /openbmc/libcper/meson.build (revision 45e7332f)
1197ea120SJohn Chungproject(
2a5b3d49bSEd Tanous    'libcper',
3a5b3d49bSEd Tanous    ['c', 'cpp'],
4197ea120SJohn Chung    version: '0.1',
5197ea120SJohn Chung    meson_version: '>=1.1.1',
6197ea120SJohn Chung    default_options: [
7197ea120SJohn Chung        'c_std=c18',
8197ea120SJohn Chung        'cpp_std=c++23',
9197ea120SJohn Chung        'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
10197ea120SJohn Chung        'werror=true',
11197ea120SJohn Chung        'warning_level=2',
12a5b3d49bSEd Tanous    ],
13a5b3d49bSEd Tanous)
14197ea120SJohn Chung
15*45e7332fSKarthik Rajagopalanadd_project_arguments(
16358c7e16SEd Tanous    '-DLIBCPER_JSON_SPEC="'
17358c7e16SEd Tanous    + meson.current_source_dir()
18358c7e16SEd Tanous    + '/specification/json/cper-json.json"',
19358c7e16SEd Tanous    language: ['c', 'cpp'],
20358c7e16SEd Tanous)
21358c7e16SEd Tanous
221a908984SAndrew Adriancelibrary_is_share = get_option('default_library') == 'shared'
23*45e7332fSKarthik Rajagopalanadd_project_arguments('-D_POSIX_C_SOURCE=200809L', language : 'c')
241a908984SAndrew Adriance
25197ea120SJohn Chungproject_description = 'libcper library'
26197ea120SJohn Chung
27a84fc937SEd Tanoussection_sources = files(
28197ea120SJohn Chung    'sections/cper-section-arm.c',
29197ea120SJohn Chung    'sections/cper-section-ccix-per.c',
30197ea120SJohn Chung    'sections/cper-section-cxl-component.c',
31197ea120SJohn Chung    'sections/cper-section-cxl-protocol.c',
32197ea120SJohn Chung    'sections/cper-section-dmar-generic.c',
33197ea120SJohn Chung    'sections/cper-section-dmar-iommu.c',
34197ea120SJohn Chung    'sections/cper-section-dmar-vtd.c',
35197ea120SJohn Chung    'sections/cper-section-firmware.c',
36197ea120SJohn Chung    'sections/cper-section-generic.c',
37197ea120SJohn Chung    'sections/cper-section-ia32x64.c',
38197ea120SJohn Chung    'sections/cper-section-ipf.c',
39197ea120SJohn Chung    'sections/cper-section-memory.c',
40683e0550SKarthik Rajagopalan    'sections/cper-section-nvidia.c',
41197ea120SJohn Chung    'sections/cper-section-pci-bus.c',
42197ea120SJohn Chung    'sections/cper-section-pci-dev.c',
43a5b3d49bSEd Tanous    'sections/cper-section-pcie.c',
44a5b3d49bSEd Tanous    'sections/cper-section.c',
45197ea120SJohn Chung)
46197ea120SJohn Chung
47a84fc937SEd Tanousedk_sources = files('edk/Cper.c')
48197ea120SJohn Chung
49a84fc937SEd Tanousgenerator_section_sources = files(
50197ea120SJohn Chung    'generator/sections/gen-section-arm.c',
51197ea120SJohn Chung    'generator/sections/gen-section-ccix-per.c',
52197ea120SJohn Chung    'generator/sections/gen-section-cxl-component.c',
53197ea120SJohn Chung    'generator/sections/gen-section-cxl-protocol.c',
54197ea120SJohn Chung    'generator/sections/gen-section-dmar.c',
55197ea120SJohn Chung    'generator/sections/gen-section-firmware.c',
56197ea120SJohn Chung    'generator/sections/gen-section-generic.c',
57197ea120SJohn Chung    'generator/sections/gen-section-ia32x64.c',
58197ea120SJohn Chung    'generator/sections/gen-section-memory.c',
59683e0550SKarthik Rajagopalan    'generator/sections/gen-section-nvidia.c',
60197ea120SJohn Chung    'generator/sections/gen-section-pci-bus.c',
61197ea120SJohn Chung    'generator/sections/gen-section-pci-dev.c',
62a5b3d49bSEd Tanous    'generator/sections/gen-section-pcie.c',
63a5b3d49bSEd Tanous    'generator/sections/gen-section.c',
64197ea120SJohn Chung)
65197ea120SJohn Chung
66abc62b89SJohn Chungcc = meson.get_compiler('c')
67197ea120SJohn Chung
68a5b3d49bSEd Tanousjson_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
69197ea120SJohn Chung
70197ea120SJohn Chunglibcper_parse_sources = [
71a7d2cdddSEd Tanous    'base64.c',
72197ea120SJohn Chung    'cper-parse.c',
73197ea120SJohn Chung    'ir-parse.c',
74197ea120SJohn Chung    'cper-utils.c',
75197ea120SJohn Chung    'common-utils.c',
76a5b3d49bSEd Tanous    'json-schema.c',
77197ea120SJohn Chung]
78197ea120SJohn Chung
79197ea120SJohn Chunglibcper_include = ['.']
80197ea120SJohn Chung
81197ea120SJohn Chunglibcper_parse = library(
82197ea120SJohn Chung    'cper-parse',
83197ea120SJohn Chung    libcper_parse_sources,
84a84fc937SEd Tanous    section_sources,
85a84fc937SEd Tanous    edk_sources,
86197ea120SJohn Chung    version: meson.project_version(),
87197ea120SJohn Chung    include_directories: include_directories(libcper_include),
88197ea120SJohn Chung    c_args: '-Wno-address-of-packed-member',
89197ea120SJohn Chung    dependencies: [
90197ea120SJohn Chung        json_c_dep,
91197ea120SJohn Chung    ],
92197ea120SJohn Chung    install: true,
93a5b3d49bSEd Tanous    install_dir: get_option('libdir'),
94197ea120SJohn Chung)
95197ea120SJohn Chunglibcper_parse = declare_dependency(
96197ea120SJohn Chung    include_directories: include_directories(libcper_include),
97a5b3d49bSEd Tanous    link_with: libcper_parse,
98197ea120SJohn Chung)
99197ea120SJohn Chung
100a5b3d49bSEd Tanouslibcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
101197ea120SJohn Chung
102197ea120SJohn Chunglibcper_generate = library(
103197ea120SJohn Chung    'cper-generate',
104197ea120SJohn Chung    libcper_generate_sources,
105a84fc937SEd Tanous    generator_section_sources,
106197ea120SJohn Chung    version: meson.project_version(),
107197ea120SJohn Chung    include_directories: include_directories(libcper_include),
108197ea120SJohn Chung    dependencies: [
109197ea120SJohn Chung        libcper_parse,
110197ea120SJohn Chung        json_c_dep,
111197ea120SJohn Chung    ],
112197ea120SJohn Chung    install: true,
113a5b3d49bSEd Tanous    install_dir: get_option('libdir'),
114197ea120SJohn Chung)
115197ea120SJohn Chunglibcper_generate = declare_dependency(
116197ea120SJohn Chung    include_directories: include_directories(libcper_include),
117a5b3d49bSEd Tanous    link_with: libcper_generate,
118197ea120SJohn Chung)
119197ea120SJohn Chung
120abc62b89SJohn Chunginstall_headers('cper-parse.h')
121abc62b89SJohn Chunginstall_headers('cper-utils.h')
122abc62b89SJohn Chunginstall_headers('common-utils.h')
123abc62b89SJohn Chunginstall_headers('generator/cper-generate.h', subdir: 'generator')
124abc62b89SJohn Chunginstall_headers('edk/Cper.h', subdir: 'edk')
125abc62b89SJohn Chunginstall_headers('edk/BaseTypes.h', subdir: 'edk')
126abc62b89SJohn Chung
127abc62b89SJohn Chungif get_option('utility').allowed()
128197ea120SJohn Chung    executable(
129197ea120SJohn Chung        'cper-convert',
130197ea120SJohn Chung        'cli-app/cper-convert.c',
131197ea120SJohn Chung        include_directories: include_directories(libcper_include),
132197ea120SJohn Chung        dependencies: [
133197ea120SJohn Chung            libcper_parse,
134197ea120SJohn Chung            json_c_dep,
135197ea120SJohn Chung        ],
136abc62b89SJohn Chung        install: true,
137a5b3d49bSEd Tanous        install_dir: get_option('bindir'),
138197ea120SJohn Chung    )
139197ea120SJohn Chung
140197ea120SJohn Chung    executable(
141197ea120SJohn Chung        'cper-generate',
142197ea120SJohn Chung        'generator/cper-generate-cli.c',
143a84fc937SEd Tanous        edk_sources,
144197ea120SJohn Chung        include_directories: include_directories(libcper_include),
145197ea120SJohn Chung        dependencies: [
146197ea120SJohn Chung            libcper_generate,
147197ea120SJohn Chung        ],
148abc62b89SJohn Chung        install: true,
149a5b3d49bSEd Tanous        install_dir: get_option('bindir'),
150197ea120SJohn Chung    )
151abc62b89SJohn Chungendif
152197ea120SJohn Chung
153197ea120SJohn Chungif get_option('tests').allowed()
154197ea120SJohn Chung    subdir('tests')
155197ea120SJohn Chungendif