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