1project( 2 'phosphor-inventory-manager', 'cpp', 3 version : '1.0.0', 4 meson_version: '>=1.1.1', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++23', 9 '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) 20conf_data.set('CREATE_ASSOCIATIONS', get_option('associations').allowed()) 21configure_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() 35 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) 36 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 44sdbusplus_dep = dependency('sdbusplus', required : false) 45phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 46phosphor_logging_dep = dependency('phosphor-logging') 47 48prog_python = find_program('python3', required: true) 49 50sources = [] 51deps = [] 52if get_option('associations').allowed() 53 sources += [ 54 'association_manager.cpp', 55 ] 56 deps += [ 57 dependency('nlohmann_json', include_type: 'system'), 58 ] 59endif 60 61ifacesdir = get_option('IFACES_PATH') 62if ifacesdir == '' 63 ifacesdir = phosphor_dbus_interfaces_dep.get_variable('yamldir') 64endif 65 66sdbusplus_python_env = {} 67if not sdbusplus_dep.found() 68 sdbusplus_proj = subproject('sdbusplus') 69 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') 70 sdbusplus_python_env = {'PYTHONPATH': meson.current_source_dir() / 'subprojects' / 'sdbusplus' / 'tools'} 71endif 72 73generated_cpp = custom_target( 74 'generated.cpp', 75 command : [ 76 prog_python, 77 meson.project_source_root() + '/pimgen.py', 78 '-i', ifacesdir, 79 '-d', get_option('YAML_PATH'), 80 '-o', meson.current_build_dir(), 81 '-b', conf_data.get_unquoted('BUSNAME'), 82 'generate-cpp' 83 ], 84 env: sdbusplus_python_env, 85 output : 'generated.cpp') 86 87gen_serialization_hpp = custom_target( 88 'gen_serialization.hpp', 89 command : [ 90 prog_python, 91 meson.project_source_root() + '/pimgen.py', 92 '-i', ifacesdir, 93 '-d', get_option('YAML_PATH'), 94 '-o', meson.current_build_dir(), 95 '-b', conf_data.get_unquoted('BUSNAME'), 96 'generate-serialization' 97 ], 98 env: sdbusplus_python_env, 99 output : 'gen_serialization.hpp') 100 101sources += [ 102 generated_cpp, 103 gen_serialization_hpp, 104 'app.cpp', 105 'errors.cpp', 106 'functor.cpp', 107 'manager.cpp', 108] 109 110deps += [ 111 cereal_dep, 112 phosphor_dbus_interfaces_dep, 113 phosphor_logging_dep, 114 sdbusplus_dep, 115] 116 117executable( 118 'phosphor-inventory', 119 sources, 120 implicit_include_directories: true, 121 dependencies: deps, 122 install: true, 123 install_dir: get_option('bindir'), 124) 125 126build_tests = get_option('tests') 127if not build_tests.disabled() 128 subdir('test') 129endif 130