xref: /openbmc/phosphor-inventory-manager/meson.build (revision af2d2a1a1908564ae6e95684ca584773f05aff29)
1a31da979SGeorge Liuproject(
2*af2d2a1aSPatrick Williams    'phosphor-inventory-manager',
3*af2d2a1aSPatrick Williams    'cpp',
4a31da979SGeorge Liu    version: '1.0.0',
5c3eb3879SPatrick Williams    meson_version: '>=1.1.1',
6a31da979SGeorge Liu    default_options: [
7a31da979SGeorge Liu        'warning_level=3',
8a31da979SGeorge Liu        'werror=true',
9c3eb3879SPatrick Williams        'cpp_std=c++23',
10a31da979SGeorge Liu        'buildtype=debugoptimized',
11*af2d2a1aSPatrick Williams    ],
12a31da979SGeorge Liu)
13a31da979SGeorge Liu
14a31da979SGeorge Liuconf_data = configuration_data()
15a31da979SGeorge Liuconf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.Inventory.Manager')
16a31da979SGeorge Liuconf_data.set_quoted('INVENTORY_ROOT', '/xyz/openbmc_project/inventory')
17a31da979SGeorge Liuconf_data.set_quoted('IFACE', 'xyz.openbmc_project.Inventory.Manager')
18a31da979SGeorge Liuconf_data.set_quoted('PIM_PERSIST_PATH', '/var/lib/phosphor-inventory-manager')
19*af2d2a1aSPatrick Williamsconf_data.set_quoted(
20*af2d2a1aSPatrick Williams    'ASSOCIATIONS_FILE_PATH',
21*af2d2a1aSPatrick Williams    '/usr/share/phosphor-inventory-manager/associations.json',
22*af2d2a1aSPatrick Williams)
23a31da979SGeorge Liuconf_data.set('CLASS_VERSION', 2)
24ba49359eSPatrick Williamsconf_data.set('CREATE_ASSOCIATIONS', get_option('associations').allowed())
25*af2d2a1aSPatrick Williamsconfigure_file(output: 'config.h', configuration: conf_data)
26a31da979SGeorge Liu
27a31da979SGeorge Liucpp = meson.get_compiler('cpp')
28a31da979SGeorge Liu# Get Cereal dependency.
29a31da979SGeorge Liucereal_dep = dependency('cereal', required: false)
30a31da979SGeorge Liuhas_cereal = cpp.has_header_symbol(
31a31da979SGeorge Liu    'cereal/cereal.hpp',
32a31da979SGeorge Liu    'cereal::specialize',
33a31da979SGeorge Liu    dependencies: cereal_dep,
34*af2d2a1aSPatrick Williams    required: false,
35*af2d2a1aSPatrick Williams)
36a31da979SGeorge Liuif not has_cereal
37a31da979SGeorge Liu    cereal_opts = import('cmake').subproject_options()
38*af2d2a1aSPatrick Williams    cereal_opts.add_cmake_defines(
39*af2d2a1aSPatrick Williams        {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
40*af2d2a1aSPatrick Williams    )
41a31da979SGeorge Liu    cereal_proj = import('cmake').subproject(
42a31da979SGeorge Liu        'cereal',
43a31da979SGeorge Liu        options: cereal_opts,
44*af2d2a1aSPatrick Williams        required: false,
45*af2d2a1aSPatrick Williams    )
46a31da979SGeorge Liu    assert(cereal_proj.found(), 'cereal is required')
47a31da979SGeorge Liu    cereal_dep = cereal_proj.dependency('cereal')
48a31da979SGeorge Liuendif
49a31da979SGeorge Liu
50a927ffe2SKonstantin Aladyshevsdbusplus_dep = dependency('sdbusplus', required: false)
51a31da979SGeorge Liuphosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
52a31da979SGeorge Liuphosphor_logging_dep = dependency('phosphor-logging')
53a31da979SGeorge Liu
54a31da979SGeorge Liuprog_python = find_program('python3', required: true)
55a31da979SGeorge Liu
56a31da979SGeorge Liusources = []
57a31da979SGeorge Liudeps = []
58ba49359eSPatrick Williamsif get_option('associations').allowed()
59*af2d2a1aSPatrick Williams    sources += ['association_manager.cpp']
6058a0c359SKonstantin Aladyshev    nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
61*af2d2a1aSPatrick Williams    deps += [nlohmann_json_dep]
62a31da979SGeorge Liuendif
63a31da979SGeorge Liu
64a31da979SGeorge Liuifacesdir = get_option('IFACES_PATH')
65a31da979SGeorge Liuif ifacesdir == ''
668a1ccdc6SPatrick Williams    ifacesdir = phosphor_dbus_interfaces_dep.get_variable('yamldir')
67a31da979SGeorge Liuendif
68a31da979SGeorge Liu
69a927ffe2SKonstantin Aladyshevsdbusplus_python_env = {}
70a927ffe2SKonstantin Aladyshevif not sdbusplus_dep.found()
71a927ffe2SKonstantin Aladyshev    sdbusplus_proj = subproject('sdbusplus')
72a927ffe2SKonstantin Aladyshev    sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
73*af2d2a1aSPatrick Williams    sdbusplus_python_env = {
74*af2d2a1aSPatrick Williams        'PYTHONPATH': meson.current_source_dir() / 'subprojects' / 'sdbusplus' / 'tools',
75*af2d2a1aSPatrick Williams    }
76a927ffe2SKonstantin Aladyshevendif
77a927ffe2SKonstantin Aladyshev
78a31da979SGeorge Liugenerated_cpp = custom_target(
79a31da979SGeorge Liu    'generated.cpp',
80a31da979SGeorge Liu    command: [
81a31da979SGeorge Liu        prog_python,
82a31da979SGeorge Liu        meson.project_source_root() + '/pimgen.py',
83*af2d2a1aSPatrick Williams        '-i',
84*af2d2a1aSPatrick Williams        ifacesdir,
85*af2d2a1aSPatrick Williams        '-d',
86*af2d2a1aSPatrick Williams        get_option('YAML_PATH'),
87*af2d2a1aSPatrick Williams        '-o',
88*af2d2a1aSPatrick Williams        meson.current_build_dir(),
89*af2d2a1aSPatrick Williams        '-b',
90*af2d2a1aSPatrick Williams        conf_data.get_unquoted('BUSNAME'),
91*af2d2a1aSPatrick Williams        'generate-cpp',
92a31da979SGeorge Liu    ],
93a927ffe2SKonstantin Aladyshev    env: sdbusplus_python_env,
94*af2d2a1aSPatrick Williams    output: 'generated.cpp',
95*af2d2a1aSPatrick Williams)
96a31da979SGeorge Liu
97a31da979SGeorge Liugen_serialization_hpp = custom_target(
98a31da979SGeorge Liu    'gen_serialization.hpp',
99a31da979SGeorge Liu    command: [
100a31da979SGeorge Liu        prog_python,
101a31da979SGeorge Liu        meson.project_source_root() + '/pimgen.py',
102*af2d2a1aSPatrick Williams        '-i',
103*af2d2a1aSPatrick Williams        ifacesdir,
104*af2d2a1aSPatrick Williams        '-d',
105*af2d2a1aSPatrick Williams        get_option('YAML_PATH'),
106*af2d2a1aSPatrick Williams        '-o',
107*af2d2a1aSPatrick Williams        meson.current_build_dir(),
108*af2d2a1aSPatrick Williams        '-b',
109*af2d2a1aSPatrick Williams        conf_data.get_unquoted('BUSNAME'),
110*af2d2a1aSPatrick Williams        'generate-serialization',
111a31da979SGeorge Liu    ],
112a927ffe2SKonstantin Aladyshev    env: sdbusplus_python_env,
113*af2d2a1aSPatrick Williams    output: 'gen_serialization.hpp',
114*af2d2a1aSPatrick Williams)
115a31da979SGeorge Liu
116a31da979SGeorge Liusources += [
117a31da979SGeorge Liu    generated_cpp,
118a31da979SGeorge Liu    gen_serialization_hpp,
119a31da979SGeorge Liu    'app.cpp',
120a31da979SGeorge Liu    'errors.cpp',
121a31da979SGeorge Liu    'functor.cpp',
122a31da979SGeorge Liu    'manager.cpp',
123a31da979SGeorge Liu]
124a31da979SGeorge Liu
125a31da979SGeorge Liudeps += [
126a31da979SGeorge Liu    cereal_dep,
127a31da979SGeorge Liu    phosphor_dbus_interfaces_dep,
128a31da979SGeorge Liu    phosphor_logging_dep,
129a31da979SGeorge Liu    sdbusplus_dep,
130a31da979SGeorge Liu]
131a31da979SGeorge Liu
132a31da979SGeorge Liuexecutable(
133a31da979SGeorge Liu    'phosphor-inventory',
134a31da979SGeorge Liu    sources,
135a31da979SGeorge Liu    implicit_include_directories: true,
136a31da979SGeorge Liu    dependencies: deps,
137a31da979SGeorge Liu    install: true,
138a31da979SGeorge Liu    install_dir: get_option('bindir'),
139a31da979SGeorge Liu)
14007f94f02SGeorge Liu
14107f94f02SGeorge Liubuild_tests = get_option('tests')
142fb3ceac4SPatrick Williamsif build_tests.allowed()
14307f94f02SGeorge Liu    subdir('test')
14407f94f02SGeorge Liuendif
145