1project( 2 'phosphor-inventory-manager', 'cpp', 3 version : '1.0.0', 4 meson_version: '>=0.58.0', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++20', 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').enabled()) 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'}) 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') 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').enabled() 53 cpp = meson.get_compiler('cpp') 54 if cpp.has_header('nlohmann/json.hpp') 55 nlohmann_json_dep = declare_dependency() 56 else 57 subproject('nlohmann', required: false) 58 nlohmann_json_dep = declare_dependency( 59 include_directories: [ 60 'subprojects/nlohmann/single_include', 61 'subprojects/nlohmann/single_include/nlohmann', 62 ] 63 ) 64 endif 65 sources += [ 66 'association_manager.cpp', 67 ] 68 deps += [ 69 nlohmann_json_dep, 70 ] 71endif 72 73ifacesdir = get_option('IFACES_PATH') 74if ifacesdir == '' 75 ifacesdir = phosphor_dbus_interfaces_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir') 76endif 77 78generated_cpp = custom_target( 79 'generated.cpp', 80 command : [ 81 prog_python, 82 meson.project_source_root() + '/pimgen.py', 83 '-i', ifacesdir, 84 '-d', get_option('YAML_PATH'), 85 '-o', meson.current_build_dir(), 86 '-b', conf_data.get_unquoted('BUSNAME'), 87 'generate-cpp' 88 ], 89 output : 'generated.cpp') 90 91gen_serialization_hpp = custom_target( 92 'gen_serialization.hpp', 93 command : [ 94 prog_python, 95 meson.project_source_root() + '/pimgen.py', 96 '-i', ifacesdir, 97 '-d', get_option('YAML_PATH'), 98 '-o', meson.current_build_dir(), 99 '-b', conf_data.get_unquoted('BUSNAME'), 100 'generate-serialization' 101 ], 102 output : 'gen_serialization.hpp') 103 104sources += [ 105 generated_cpp, 106 gen_serialization_hpp, 107 'app.cpp', 108 'errors.cpp', 109 'functor.cpp', 110 'manager.cpp', 111] 112 113deps += [ 114 cereal_dep, 115 phosphor_dbus_interfaces_dep, 116 phosphor_logging_dep, 117 sdbusplus_dep, 118] 119 120executable( 121 'phosphor-inventory', 122 sources, 123 implicit_include_directories: true, 124 dependencies: deps, 125 install: true, 126 install_dir: get_option('bindir'), 127) 128 129build_tests = get_option('tests') 130if not build_tests.disabled() 131 subdir('test') 132endif 133