xref: /openbmc/entity-manager/meson.build (revision 37304f099971e0f1805dbc0e3b779a1badfd57a5)
1b4459915SBrad Bishopproject(
2b4459915SBrad Bishop    'entity-manager',
3b4459915SBrad Bishop    'cpp',
4*37304f09SPatrick Williams    default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'],
5b4459915SBrad Bishop    license: 'Apache-2.0',
6b4459915SBrad Bishop    version: '0.1',
7a183f4a5SPatrick Williams    meson_version: '>=1.1.1',
8b4459915SBrad Bishop)
9ec98491aSBrad Bishopadd_project_arguments('-Wno-psabi', language: 'cpp')
10b4459915SBrad Bishop
11b4459915SBrad Bishopboost_args = [
12ae2d4354SEd Tanous    '-DBOOST_ASIO_NO_DEPRECATED',
13b4459915SBrad Bishop    '-DBOOST_SYSTEM_NO_DEPRECATED',
14b4459915SBrad Bishop    '-DBOOST_ERROR_CODE_HEADER_ONLY',
15b4459915SBrad Bishop    '-DBOOST_NO_RTTI',
16b4459915SBrad Bishop    '-DBOOST_NO_TYPEID',
17b4459915SBrad Bishop    '-DBOOST_ALL_NO_LIB',
18*37304f09SPatrick Williams    '-DBOOST_ALLOW_DEPRECATED_HEADERS',
19b4459915SBrad Bishop]
20b4459915SBrad Bishopbuild_tests = get_option('tests')
21e3a12b6aSBrad Bishopcpp = meson.get_compiler('cpp')
22787e828bSBrad Bishopboost = dependency('boost', required: false)
23787e828bSBrad Bishopif not boost.found()
24787e828bSBrad Bishop    subproject('boost', required: false)
25*37304f09SPatrick Williams    boost = declare_dependency(include_directories: 'subprojects/boost_1_71_0')
2607d467bcSEd Tanous    boost = boost.as_system('system')
27787e828bSBrad Bishopendif
2892daaaa3SBrad Bishopif get_option('fru-device')
29e3a12b6aSBrad Bishop    i2c = cpp.find_library('i2c')
3092daaaa3SBrad Bishopendif
3114a7bc93SAndrew Jeffery
322ab7341bSChris Sidesif get_option('devicetree-vpd')
33*37304f09SPatrick Williams    phosphor_dbus_interfaces_dep = dependency(
34*37304f09SPatrick Williams        'phosphor-dbus-interfaces',
35*37304f09SPatrick Williams        include_type: 'system',
36*37304f09SPatrick Williams    )
372ab7341bSChris Sidesendif
382ab7341bSChris Sides
397e11982fSPatrick Williamsnlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
40c3db2c3cSAlexander Hansensdbusplus = dependency('sdbusplus', include_type: 'system')
41c3db2c3cSAlexander Hansenphosphor_logging_dep = dependency('phosphor-logging')
4214a7bc93SAndrew Jeffery
43b4459915SBrad Bishopsystemd = dependency('systemd')
44ee1db76fSPatrick Williamssystemd_system_unit_dir = systemd.get_variable(
45b4459915SBrad Bishop    'systemdsystemunitdir',
46*37304f09SPatrick Williams    pkgconfig_define: ['prefix', get_option('prefix')],
47*37304f09SPatrick Williams)
48b4459915SBrad Bishoppackagedir = join_paths(
49b4459915SBrad Bishop    get_option('prefix'),
50b4459915SBrad Bishop    get_option('datadir'),
51b4459915SBrad Bishop    meson.project_name(),
52b4459915SBrad Bishop)
53a9c58929SAndrew Jefferysysconfdir = join_paths(
54a9c58929SAndrew Jeffery    get_option('prefix'),
55a9c58929SAndrew Jeffery    get_option('sysconfdir'),
56a9c58929SAndrew Jeffery    meson.project_name(),
57a9c58929SAndrew Jeffery)
58b4459915SBrad Bishopthreads = dependency('threads')
5955ae5a88SEd Tanousif cpp.has_header('valijson/validator.hpp')
6055ae5a88SEd Tanous    valijson = declare_dependency()
6155ae5a88SEd Tanouselse
6255ae5a88SEd Tanous    subproject('valijson', required: false)
6355ae5a88SEd Tanous    valijson = declare_dependency(
64*37304f09SPatrick Williams        include_directories: 'subprojects/valijson/include',
6555ae5a88SEd Tanous    )
6655ae5a88SEd Tanous    valijson = valijson.as_system('system')
67ff1ddb7eSBrad Bishopendif
68b4459915SBrad Bishop
69b4459915SBrad Bishopinstall_data('blacklist.json')
70b4459915SBrad Bishop
71edc46347SAlexander Hansen# this creates the 'configs' variable
72edc46347SAlexander Hansensubdir('configurations')
73edc46347SAlexander Hansen
749dc2cc53SEd Tanousfilepaths = []
75b4459915SBrad Bishopforeach c : configs
769dc2cc53SEd Tanous    file = join_paths('configurations', c)
77*37304f09SPatrick Williams    install_data(file, install_dir: join_paths(packagedir, 'configurations'))
789dc2cc53SEd Tanous    filepaths += [file]
79b4459915SBrad Bishopendforeach
80b4459915SBrad Bishop
817742c87cSMatt Spinlerif get_option('validate-json')
82bfc7296eSBrad Bishop    validate_script = files('scripts/validate_configs.py')
839dc2cc53SEd Tanous    autojson = custom_target(
849dc2cc53SEd Tanous        'check_syntax',
85*37304f09SPatrick Williams        command: [validate_script, '-v', '-k'],
869dc2cc53SEd Tanous        depend_files: files(filepaths),
879dc2cc53SEd Tanous        build_by_default: true,
889dc2cc53SEd Tanous        capture: true,
899dc2cc53SEd Tanous        output: 'validate_configs.log',
909dc2cc53SEd Tanous    )
917742c87cSMatt Spinlerendif
929dc2cc53SEd Tanous
93b4459915SBrad Bishopschemas = [
94b4459915SBrad Bishop    'global.json',
9566665886SBrad Bishop    'legacy.json',
96b980991bSBrad Bishop    'openbmc-dbus.json',
977d05ee59SBrad Bishop    'ibm.json',
987d05ee59SBrad Bishop    'intel.json',
997dc140d5SYikai Tsai    'mctp.json',
1007d05ee59SBrad Bishop    'pid.json',
1017d05ee59SBrad Bishop    'pid_zone.json',
1027d05ee59SBrad Bishop    'stepwise.json',
1037d05ee59SBrad Bishop    'virtual_sensor.json',
10448edf9a9SAndrew Geissler    'satellite_controller.json',
1053671cd2bSJagpal Singh Gill    'leak_detector.json',
106e6fc3b7bSJagpal Singh Gill    'firmware.json',
107b4459915SBrad Bishop]
108b4459915SBrad Bishop
109b4459915SBrad Bishopforeach s : schemas
110b4459915SBrad Bishop    install_data(
111b4459915SBrad Bishop        join_paths('schemas', s),
112*37304f09SPatrick Williams        install_dir: join_paths(packagedir, 'configurations', 'schemas'),
113b4459915SBrad Bishop    )
114b4459915SBrad Bishopendforeach
115b4459915SBrad Bishop
116b4459915SBrad Bishopsubdir('service_files')
117b4459915SBrad Bishopsubdir('src')
118b9f50cd5SBrad Bishop
119ff58eba9SJason M. Billsif not build_tests.disabled()
120a62466ceSPatrick Venture    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
121b9f50cd5SBrad Bishop    gtest = dependency('gtest', main: true, disabler: true, required: false)
122f2f5b7acSBenjamin Fair    gmock = dependency('gmock', disabler: true, required: false)
123f2f5b7acSBenjamin Fair    if not (gtest.found() and gmock.found()) and build_tests.enabled()
12455ae5a88SEd Tanous        cmake = import('cmake')
125b9f50cd5SBrad Bishop        gtest_subproject = cmake.subproject('gtest')
126b9f50cd5SBrad Bishop        cm_gtest = gtest_subproject.dependency('gtest')
127b9f50cd5SBrad Bishop        cm_gtest_main = gtest_subproject.dependency('gtest_main')
128*37304f09SPatrick Williams        gtest = declare_dependency(
129*37304f09SPatrick Williams            dependencies: [cm_gtest, cm_gtest_main, threads],
130*37304f09SPatrick Williams        )
131f2f5b7acSBenjamin Fair        gmock = gtest_subproject.dependency('gmock')
132f2f5b7acSBenjamin Fair
133b9f50cd5SBrad Bishop    endif
134b9f50cd5SBrad Bishop
135b9f50cd5SBrad Bishop    test(
136b9f50cd5SBrad Bishop        'test_entity_manager',
137b9f50cd5SBrad Bishop        executable(
138b9f50cd5SBrad Bishop            'test_entity_manager',
139b9f50cd5SBrad Bishop            'test/test_entity-manager.cpp',
140e45d8c71SBrad Bishop            'src/expression.cpp',
141e45d8c71SBrad Bishop            'src/utils.cpp',
142a62466ceSPatrick Venture            cpp_args: test_boost_args,
143b9f50cd5SBrad Bishop            dependencies: [
144b9f50cd5SBrad Bishop                boost,
145b9f50cd5SBrad Bishop                gtest,
14614a7bc93SAndrew Jeffery                nlohmann_json_dep,
147c3db2c3cSAlexander Hansen                phosphor_logging_dep,
148b9f50cd5SBrad Bishop                sdbusplus,
149b9f50cd5SBrad Bishop                valijson,
150b9f50cd5SBrad Bishop            ],
151a5d25dccSAndrew Jeffery            include_directories: 'src',
152*37304f09SPatrick Williams        ),
153b9f50cd5SBrad Bishop    )
154a62466ceSPatrick Venture
155a62466ceSPatrick Venture    test(
156a62466ceSPatrick Venture        'test_fru_utils',
157a62466ceSPatrick Venture        executable(
158a62466ceSPatrick Venture            'test_fru_utils',
159a62466ceSPatrick Venture            'test/test_fru-utils.cpp',
160e45d8c71SBrad Bishop            'src/fru_utils.cpp',
161309c0b13SZev Weiss            'src/fru_reader.cpp',
162a62466ceSPatrick Venture            cpp_args: test_boost_args,
163*37304f09SPatrick Williams            dependencies: [boost, gtest, phosphor_logging_dep, sdbusplus],
164a5d25dccSAndrew Jeffery            include_directories: 'src',
165*37304f09SPatrick Williams        ),
166a62466ceSPatrick Venture    )
167f2f5b7acSBenjamin Fair
168f2f5b7acSBenjamin Fair    test(
169f2f5b7acSBenjamin Fair        'test_topology',
170f2f5b7acSBenjamin Fair        executable(
171f2f5b7acSBenjamin Fair            'test_topology',
172f2f5b7acSBenjamin Fair            'test/test_topology.cpp',
173f2f5b7acSBenjamin Fair            'src/topology.cpp',
174f2f5b7acSBenjamin Fair            cpp_args: test_boost_args,
175f2f5b7acSBenjamin Fair            dependencies: [
176f2f5b7acSBenjamin Fair                gtest,
177f2f5b7acSBenjamin Fair                gmock,
178af29361cSPatrick Williams                nlohmann_json_dep,
179c3db2c3cSAlexander Hansen                phosphor_logging_dep,
180f2f5b7acSBenjamin Fair            ],
181a5d25dccSAndrew Jeffery            include_directories: 'src',
182*37304f09SPatrick Williams        ),
183f2f5b7acSBenjamin Fair    )
184ff58eba9SJason M. Billsendif
185