xref: /openbmc/libcper/meson.build (revision a84fc937)
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
151a908984SAndrew Adriancelibrary_is_share = get_option('default_library') == 'shared'
161a908984SAndrew Adriance
17197ea120SJohn Chungproject_description = 'libcper library'
18197ea120SJohn Chung
19*a84fc937SEd Tanoussection_sources = files(
20197ea120SJohn Chung    'sections/cper-section-arm.c',
21197ea120SJohn Chung    'sections/cper-section-ccix-per.c',
22197ea120SJohn Chung    'sections/cper-section-cxl-component.c',
23197ea120SJohn Chung    'sections/cper-section-cxl-protocol.c',
24197ea120SJohn Chung    'sections/cper-section-dmar-generic.c',
25197ea120SJohn Chung    'sections/cper-section-dmar-iommu.c',
26197ea120SJohn Chung    'sections/cper-section-dmar-vtd.c',
27197ea120SJohn Chung    'sections/cper-section-firmware.c',
28197ea120SJohn Chung    'sections/cper-section-generic.c',
29197ea120SJohn Chung    'sections/cper-section-ia32x64.c',
30197ea120SJohn Chung    'sections/cper-section-ipf.c',
31197ea120SJohn Chung    'sections/cper-section-memory.c',
32197ea120SJohn Chung    'sections/cper-section-pci-bus.c',
33197ea120SJohn Chung    'sections/cper-section-pci-dev.c',
34a5b3d49bSEd Tanous    'sections/cper-section-pcie.c',
35a5b3d49bSEd Tanous    'sections/cper-section.c',
36197ea120SJohn Chung)
37197ea120SJohn Chung
38*a84fc937SEd Tanousedk_sources = files('edk/Cper.c')
39197ea120SJohn Chung
40*a84fc937SEd Tanousgenerator_section_sources = files(
41197ea120SJohn Chung    'generator/sections/gen-section-arm.c',
42197ea120SJohn Chung    'generator/sections/gen-section-ccix-per.c',
43197ea120SJohn Chung    'generator/sections/gen-section-cxl-component.c',
44197ea120SJohn Chung    'generator/sections/gen-section-cxl-protocol.c',
45197ea120SJohn Chung    'generator/sections/gen-section-dmar.c',
46197ea120SJohn Chung    'generator/sections/gen-section-firmware.c',
47197ea120SJohn Chung    'generator/sections/gen-section-generic.c',
48197ea120SJohn Chung    'generator/sections/gen-section-ia32x64.c',
49197ea120SJohn Chung    'generator/sections/gen-section-memory.c',
50197ea120SJohn Chung    'generator/sections/gen-section-pci-bus.c',
51197ea120SJohn Chung    'generator/sections/gen-section-pci-dev.c',
52a5b3d49bSEd Tanous    'generator/sections/gen-section-pcie.c',
53a5b3d49bSEd Tanous    'generator/sections/gen-section.c',
54197ea120SJohn Chung)
55197ea120SJohn Chung
56abc62b89SJohn Chungcc = meson.get_compiler('c')
57197ea120SJohn Chung
58a5b3d49bSEd Tanousjson_c_dep = dependency('json-c', required: true, fallback: ['json-c', 'json_c_dep'])
59197ea120SJohn Chung
60197ea120SJohn Chunglibcper_parse_sources = [
61a7d2cdddSEd Tanous    'base64.c',
62197ea120SJohn Chung    'cper-parse.c',
63197ea120SJohn Chung    'ir-parse.c',
64197ea120SJohn Chung    'cper-utils.c',
65197ea120SJohn Chung    'common-utils.c',
66a5b3d49bSEd Tanous    'json-schema.c',
67197ea120SJohn Chung]
68197ea120SJohn Chung
69197ea120SJohn Chunglibcper_include = ['.']
70197ea120SJohn Chung
71197ea120SJohn Chunglibcper_parse = library(
72197ea120SJohn Chung    'cper-parse',
73197ea120SJohn Chung    libcper_parse_sources,
74*a84fc937SEd Tanous    section_sources,
75*a84fc937SEd Tanous    edk_sources,
76197ea120SJohn Chung    version: meson.project_version(),
77197ea120SJohn Chung    include_directories: include_directories(libcper_include),
78197ea120SJohn Chung    c_args: '-Wno-address-of-packed-member',
79197ea120SJohn Chung    dependencies: [
80197ea120SJohn Chung        json_c_dep,
81197ea120SJohn Chung    ],
82197ea120SJohn Chung    install: true,
83a5b3d49bSEd Tanous    install_dir: get_option('libdir'),
84197ea120SJohn Chung)
85197ea120SJohn Chunglibcper_parse = declare_dependency(
86197ea120SJohn Chung    include_directories: include_directories(libcper_include),
87a5b3d49bSEd Tanous    link_with: libcper_parse,
88197ea120SJohn Chung)
89197ea120SJohn Chung
90a5b3d49bSEd Tanouslibcper_generate_sources = ['generator/cper-generate.c', 'generator/gen-utils.c', 'common-utils.c']
91197ea120SJohn Chung
92197ea120SJohn Chunglibcper_generate = library(
93197ea120SJohn Chung    'cper-generate',
94197ea120SJohn Chung    libcper_generate_sources,
95*a84fc937SEd Tanous    generator_section_sources,
96197ea120SJohn Chung    version: meson.project_version(),
97197ea120SJohn Chung    include_directories: include_directories(libcper_include),
98197ea120SJohn Chung    dependencies: [
99197ea120SJohn Chung        libcper_parse,
100197ea120SJohn Chung        json_c_dep,
101197ea120SJohn Chung    ],
102197ea120SJohn Chung    install: true,
103a5b3d49bSEd Tanous    install_dir: get_option('libdir'),
104197ea120SJohn Chung)
105197ea120SJohn Chunglibcper_generate = declare_dependency(
106197ea120SJohn Chung    include_directories: include_directories(libcper_include),
107a5b3d49bSEd Tanous    link_with: libcper_generate,
108197ea120SJohn Chung)
109197ea120SJohn Chung
110abc62b89SJohn Chunginstall_headers('cper-parse.h')
111abc62b89SJohn Chunginstall_headers('cper-utils.h')
112abc62b89SJohn Chunginstall_headers('common-utils.h')
113abc62b89SJohn Chunginstall_headers('generator/cper-generate.h', subdir: 'generator')
114abc62b89SJohn Chunginstall_headers('edk/Cper.h', subdir: 'edk')
115abc62b89SJohn Chunginstall_headers('edk/BaseTypes.h', subdir: 'edk')
116abc62b89SJohn Chung
117abc62b89SJohn Chungif get_option('utility').allowed()
118197ea120SJohn Chung    executable(
119197ea120SJohn Chung        'cper-convert',
120197ea120SJohn Chung        'cli-app/cper-convert.c',
121197ea120SJohn Chung        include_directories: include_directories(libcper_include),
122197ea120SJohn Chung        dependencies: [
123197ea120SJohn Chung            libcper_parse,
124197ea120SJohn Chung            json_c_dep,
125197ea120SJohn Chung        ],
126abc62b89SJohn Chung        install: true,
127a5b3d49bSEd Tanous        install_dir: get_option('bindir'),
128197ea120SJohn Chung    )
129197ea120SJohn Chung
130197ea120SJohn Chung    executable(
131197ea120SJohn Chung        'cper-generate',
132197ea120SJohn Chung        'generator/cper-generate-cli.c',
133*a84fc937SEd Tanous        edk_sources,
134197ea120SJohn Chung        include_directories: include_directories(libcper_include),
135197ea120SJohn Chung        dependencies: [
136197ea120SJohn Chung            libcper_generate,
137197ea120SJohn Chung        ],
138abc62b89SJohn Chung        install: true,
139a5b3d49bSEd Tanous        install_dir: get_option('bindir'),
140197ea120SJohn Chung    )
141abc62b89SJohn Chungendif
142197ea120SJohn Chung
1431e267b64SEd Tanousrun_command('cp', '-r', 'specification/json/', meson.current_build_dir(), check: true)
144a5b3d49bSEd Tanousrun_command(
145a5b3d49bSEd Tanous    'mv',
146a5b3d49bSEd Tanous    meson.current_build_dir() / 'json',
147a5b3d49bSEd Tanous    meson.current_build_dir() / 'specification',
148a5b3d49bSEd Tanous)
149197ea120SJohn Chung
150197ea120SJohn Chungif get_option('tests').allowed()
151197ea120SJohn Chung    subdir('tests')
152197ea120SJohn Chungendif
153