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