blob: 51aff7362396c9d34dcccafcdc35141dcee9e865 [file] [log] [blame]
George Liua31da972022-04-14 14:07:18 +08001project(
2 'phosphor-inventory-manager', 'cpp',
3 version : '1.0.0',
Patrick Williamsc3eb3872023-07-12 11:15:18 -05004 meson_version: '>=1.1.1',
George Liua31da972022-04-14 14:07:18 +08005 default_options: [
6 'warning_level=3',
7 'werror=true',
Patrick Williamsc3eb3872023-07-12 11:15:18 -05008 'cpp_std=c++23',
George Liua31da972022-04-14 14:07:18 +08009 'buildtype=debugoptimized',
10 ]
11)
12
13conf_data = configuration_data()
14conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.Inventory.Manager')
15conf_data.set_quoted('INVENTORY_ROOT', '/xyz/openbmc_project/inventory')
16conf_data.set_quoted('IFACE', 'xyz.openbmc_project.Inventory.Manager')
17conf_data.set_quoted('PIM_PERSIST_PATH', '/var/lib/phosphor-inventory-manager')
18conf_data.set_quoted('ASSOCIATIONS_FILE_PATH', '/usr/share/phosphor-inventory-manager/associations.json')
19conf_data.set('CLASS_VERSION', 2)
Patrick Williamsba493592023-11-29 06:44:07 -060020conf_data.set('CREATE_ASSOCIATIONS', get_option('associations').allowed())
George Liua31da972022-04-14 14:07:18 +080021configure_file(output: 'config.h',
22 configuration: conf_data
23)
24
25cpp = meson.get_compiler('cpp')
26# Get Cereal dependency.
27cereal_dep = dependency('cereal', required: false)
28has_cereal = cpp.has_header_symbol(
29 'cereal/cereal.hpp',
30 'cereal::specialize',
31 dependencies: cereal_dep,
32 required: false)
33if not has_cereal
34 cereal_opts = import('cmake').subproject_options()
Konstantin Aladyshev31424482024-04-02 18:09:57 +030035 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
George Liua31da972022-04-14 14:07:18 +080036 cereal_proj = import('cmake').subproject(
37 'cereal',
38 options: cereal_opts,
39 required: false)
40 assert(cereal_proj.found(), 'cereal is required')
41 cereal_dep = cereal_proj.dependency('cereal')
42endif
43
Konstantin Aladysheva927ffe2024-04-22 16:47:37 +030044sdbusplus_dep = dependency('sdbusplus', required : false)
George Liua31da972022-04-14 14:07:18 +080045phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
46phosphor_logging_dep = dependency('phosphor-logging')
47
48prog_python = find_program('python3', required: true)
49
50sources = []
51deps = []
Patrick Williamsba493592023-11-29 06:44:07 -060052if get_option('associations').allowed()
George Liua31da972022-04-14 14:07:18 +080053 sources += [
54 'association_manager.cpp',
55 ]
Konstantin Aladyshev58a0c352024-04-22 17:10:47 +030056 nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
George Liua31da972022-04-14 14:07:18 +080057 deps += [
Konstantin Aladyshev58a0c352024-04-22 17:10:47 +030058 nlohmann_json_dep,
George Liua31da972022-04-14 14:07:18 +080059 ]
60endif
61
62ifacesdir = get_option('IFACES_PATH')
63if ifacesdir == ''
Patrick Williams8a1ccdc2023-04-12 08:01:04 -050064 ifacesdir = phosphor_dbus_interfaces_dep.get_variable('yamldir')
George Liua31da972022-04-14 14:07:18 +080065endif
66
Konstantin Aladysheva927ffe2024-04-22 16:47:37 +030067sdbusplus_python_env = {}
68if not sdbusplus_dep.found()
69 sdbusplus_proj = subproject('sdbusplus')
70 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
71 sdbusplus_python_env = {'PYTHONPATH': meson.current_source_dir() / 'subprojects' / 'sdbusplus' / 'tools'}
72endif
73
George Liua31da972022-04-14 14:07:18 +080074generated_cpp = custom_target(
75 'generated.cpp',
76 command : [
77 prog_python,
78 meson.project_source_root() + '/pimgen.py',
79 '-i', ifacesdir,
80 '-d', get_option('YAML_PATH'),
81 '-o', meson.current_build_dir(),
Santosh Puranikc4c94822023-01-05 22:43:46 +053082 '-b', conf_data.get_unquoted('BUSNAME'),
George Liua31da972022-04-14 14:07:18 +080083 'generate-cpp'
84 ],
Konstantin Aladysheva927ffe2024-04-22 16:47:37 +030085 env: sdbusplus_python_env,
George Liua31da972022-04-14 14:07:18 +080086 output : 'generated.cpp')
87
88gen_serialization_hpp = custom_target(
89 'gen_serialization.hpp',
90 command : [
91 prog_python,
92 meson.project_source_root() + '/pimgen.py',
93 '-i', ifacesdir,
94 '-d', get_option('YAML_PATH'),
95 '-o', meson.current_build_dir(),
Santosh Puranikc4c94822023-01-05 22:43:46 +053096 '-b', conf_data.get_unquoted('BUSNAME'),
George Liua31da972022-04-14 14:07:18 +080097 'generate-serialization'
98 ],
Konstantin Aladysheva927ffe2024-04-22 16:47:37 +030099 env: sdbusplus_python_env,
George Liua31da972022-04-14 14:07:18 +0800100 output : 'gen_serialization.hpp')
101
102sources += [
103 generated_cpp,
104 gen_serialization_hpp,
105 'app.cpp',
106 'errors.cpp',
107 'functor.cpp',
108 'manager.cpp',
109]
110
111deps += [
112 cereal_dep,
113 phosphor_dbus_interfaces_dep,
114 phosphor_logging_dep,
115 sdbusplus_dep,
116]
117
118executable(
119 'phosphor-inventory',
120 sources,
121 implicit_include_directories: true,
122 dependencies: deps,
123 install: true,
124 install_dir: get_option('bindir'),
125)
George Liu07f94f02022-04-14 14:09:44 +0800126
127build_tests = get_option('tests')
128if not build_tests.disabled()
129 subdir('test')
130endif