George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-inventory-manager', 'cpp', |
| 3 | version : '1.0.0', |
Patrick Williams | c3eb387 | 2023-07-12 11:15:18 -0500 | [diff] [blame] | 4 | meson_version: '>=1.1.1', |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
Patrick Williams | c3eb387 | 2023-07-12 11:15:18 -0500 | [diff] [blame] | 8 | 'cpp_std=c++23', |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 9 | 'buildtype=debugoptimized', |
| 10 | ] |
| 11 | ) |
| 12 | |
| 13 | conf_data = configuration_data() |
| 14 | conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.Inventory.Manager') |
| 15 | conf_data.set_quoted('INVENTORY_ROOT', '/xyz/openbmc_project/inventory') |
| 16 | conf_data.set_quoted('IFACE', 'xyz.openbmc_project.Inventory.Manager') |
| 17 | conf_data.set_quoted('PIM_PERSIST_PATH', '/var/lib/phosphor-inventory-manager') |
| 18 | conf_data.set_quoted('ASSOCIATIONS_FILE_PATH', '/usr/share/phosphor-inventory-manager/associations.json') |
| 19 | conf_data.set('CLASS_VERSION', 2) |
Patrick Williams | ba49359 | 2023-11-29 06:44:07 -0600 | [diff] [blame] | 20 | conf_data.set('CREATE_ASSOCIATIONS', get_option('associations').allowed()) |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 21 | configure_file(output: 'config.h', |
| 22 | configuration: conf_data |
| 23 | ) |
| 24 | |
| 25 | cpp = meson.get_compiler('cpp') |
| 26 | # Get Cereal dependency. |
| 27 | cereal_dep = dependency('cereal', required: false) |
| 28 | has_cereal = cpp.has_header_symbol( |
| 29 | 'cereal/cereal.hpp', |
| 30 | 'cereal::specialize', |
| 31 | dependencies: cereal_dep, |
| 32 | required: false) |
| 33 | if not has_cereal |
| 34 | cereal_opts = import('cmake').subproject_options() |
Konstantin Aladyshev | 3142448 | 2024-04-02 18:09:57 +0300 | [diff] [blame] | 35 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 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') |
| 42 | endif |
| 43 | |
Konstantin Aladyshev | a927ffe | 2024-04-22 16:47:37 +0300 | [diff] [blame] | 44 | sdbusplus_dep = dependency('sdbusplus', required : false) |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 45 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 46 | phosphor_logging_dep = dependency('phosphor-logging') |
| 47 | |
| 48 | prog_python = find_program('python3', required: true) |
| 49 | |
| 50 | sources = [] |
| 51 | deps = [] |
Patrick Williams | ba49359 | 2023-11-29 06:44:07 -0600 | [diff] [blame] | 52 | if get_option('associations').allowed() |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 53 | sources += [ |
| 54 | 'association_manager.cpp', |
| 55 | ] |
Konstantin Aladyshev | 58a0c35 | 2024-04-22 17:10:47 +0300 | [diff] [blame^] | 56 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 57 | deps += [ |
Konstantin Aladyshev | 58a0c35 | 2024-04-22 17:10:47 +0300 | [diff] [blame^] | 58 | nlohmann_json_dep, |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 59 | ] |
| 60 | endif |
| 61 | |
| 62 | ifacesdir = get_option('IFACES_PATH') |
| 63 | if ifacesdir == '' |
Patrick Williams | 8a1ccdc | 2023-04-12 08:01:04 -0500 | [diff] [blame] | 64 | ifacesdir = phosphor_dbus_interfaces_dep.get_variable('yamldir') |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 65 | endif |
| 66 | |
Konstantin Aladyshev | a927ffe | 2024-04-22 16:47:37 +0300 | [diff] [blame] | 67 | sdbusplus_python_env = {} |
| 68 | if 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'} |
| 72 | endif |
| 73 | |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 74 | generated_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 Puranik | c4c9482 | 2023-01-05 22:43:46 +0530 | [diff] [blame] | 82 | '-b', conf_data.get_unquoted('BUSNAME'), |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 83 | 'generate-cpp' |
| 84 | ], |
Konstantin Aladyshev | a927ffe | 2024-04-22 16:47:37 +0300 | [diff] [blame] | 85 | env: sdbusplus_python_env, |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 86 | output : 'generated.cpp') |
| 87 | |
| 88 | gen_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 Puranik | c4c9482 | 2023-01-05 22:43:46 +0530 | [diff] [blame] | 96 | '-b', conf_data.get_unquoted('BUSNAME'), |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 97 | 'generate-serialization' |
| 98 | ], |
Konstantin Aladyshev | a927ffe | 2024-04-22 16:47:37 +0300 | [diff] [blame] | 99 | env: sdbusplus_python_env, |
George Liu | a31da97 | 2022-04-14 14:07:18 +0800 | [diff] [blame] | 100 | output : 'gen_serialization.hpp') |
| 101 | |
| 102 | sources += [ |
| 103 | generated_cpp, |
| 104 | gen_serialization_hpp, |
| 105 | 'app.cpp', |
| 106 | 'errors.cpp', |
| 107 | 'functor.cpp', |
| 108 | 'manager.cpp', |
| 109 | ] |
| 110 | |
| 111 | deps += [ |
| 112 | cereal_dep, |
| 113 | phosphor_dbus_interfaces_dep, |
| 114 | phosphor_logging_dep, |
| 115 | sdbusplus_dep, |
| 116 | ] |
| 117 | |
| 118 | executable( |
| 119 | 'phosphor-inventory', |
| 120 | sources, |
| 121 | implicit_include_directories: true, |
| 122 | dependencies: deps, |
| 123 | install: true, |
| 124 | install_dir: get_option('bindir'), |
| 125 | ) |
George Liu | 07f94f0 | 2022-04-14 14:09:44 +0800 | [diff] [blame] | 126 | |
| 127 | build_tests = get_option('tests') |
| 128 | if not build_tests.disabled() |
| 129 | subdir('test') |
| 130 | endif |