George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 1 | project( |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 2 | 'openpower-occ-control', |
| 3 | 'cpp', |
| 4 | version: '1.0.0', |
Patrick Williams | 50cfb70 | 2023-07-12 11:15:24 -0500 | [diff] [blame] | 5 | meson_version: '>=1.1.1', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 6 | default_options: [ |
| 7 | 'warning_level=3', |
| 8 | 'werror=true', |
Patrick Williams | 50cfb70 | 2023-07-12 11:15:24 -0500 | [diff] [blame] | 9 | 'cpp_std=c++23', |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 10 | 'buildtype=debugoptimized', |
| 11 | ], |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 12 | ) |
| 13 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 14 | cxx = meson.get_compiler('cpp') |
| 15 | |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 16 | conf_data = configuration_data() |
| 17 | conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control') |
| 18 | conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control') |
| 19 | conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors') |
| 20 | conf_data.set_quoted('CPU_NAME', 'cpu') |
| 21 | conf_data.set_quoted('OCC_NAME', 'occ') |
| 22 | conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1') |
| 23 | conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ') |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 24 | conf_data.set_quoted( |
| 25 | 'CPU_SUBPATH', |
| 26 | '/xyz/openbmc_project/inventory/system/chassis/motherboard', |
| 27 | ) |
| 28 | conf_data.set_quoted( |
| 29 | 'OCC_CONTROL_PERSIST_PATH', |
| 30 | '/var/lib/openpower-occ-control', |
| 31 | ) |
Dhruvaraj Subhashchandran | 1173b2b | 2024-06-01 11:12:13 -0500 | [diff] [blame] | 32 | conf_data.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path')) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 33 | |
| 34 | conf_data.set('MAX_CPUS', get_option('max-cpus')) |
| 35 | conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0) |
| 36 | conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0) |
Eddie James | 3f710bd | 2021-10-20 13:40:52 -0500 | [diff] [blame] | 37 | conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor')) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 38 | |
Sheldon Bailey | 16a5adb | 2025-06-10 14:10:06 -0500 | [diff] [blame^] | 39 | conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/') |
| 40 | conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/') |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 41 | |
Chris Cain | 720a384 | 2025-01-09 10:23:36 -0600 | [diff] [blame] | 42 | conf_data.set('PHAL_SUPPORT', get_option('phal-support').allowed()) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 43 | |
Eddie James | 88811ad | 2024-08-27 13:39:05 -0500 | [diff] [blame] | 44 | if get_option('transport-implementation') == 'mctp-demux' |
| 45 | conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1) |
| 46 | elif get_option('transport-implementation') == 'af-mctp' |
| 47 | conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1) |
| 48 | endif |
| 49 | |
Rashmica Gupta | 52328cb | 2023-02-15 10:38:16 +1100 | [diff] [blame] | 50 | if cxx.has_header('poll.h') |
| 51 | conf_data.set('PLDM_HAS_POLL', 1) |
| 52 | endif |
| 53 | |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 54 | configure_file(output: 'config.h', configuration: conf_data) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 55 | |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 56 | install_data( |
| 57 | 'occ-active.sh', |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 58 | install_mode: 'rwxr-xr-x', |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 59 | install_dir: get_option('bindir'), |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 60 | ) |
| 61 | |
| 62 | systemd = dependency('systemd') |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 63 | systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 64 | subdir('service_files') |
| 65 | |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 66 | sdbusplus_dep = dependency('sdbusplus') |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 67 | |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 68 | python_prog = find_program('python3', required: true) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 69 | |
| 70 | deps = [] |
| 71 | sources = [] |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 72 | |
Patrick Williams | f6992a4 | 2024-02-28 11:12:24 -0600 | [diff] [blame] | 73 | cereal_dep = dependency('cereal', required: false) |
| 74 | has_cereal = cxx.has_header_symbol( |
| 75 | 'cereal/cereal.hpp', |
| 76 | 'cereal::specialize', |
| 77 | dependencies: cereal_dep, |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 78 | required: false, |
| 79 | ) |
Patrick Williams | f6992a4 | 2024-02-28 11:12:24 -0600 | [diff] [blame] | 80 | if not has_cereal |
| 81 | cereal_opts = import('cmake').subproject_options() |
| 82 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) |
| 83 | cereal_proj = import('cmake').subproject( |
| 84 | 'cereal', |
| 85 | options: cereal_opts, |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 86 | required: false, |
| 87 | ) |
Patrick Williams | f6992a4 | 2024-02-28 11:12:24 -0600 | [diff] [blame] | 88 | assert(cereal_proj.found(), 'cereal is required') |
| 89 | cereal_dep = cereal_proj.dependency('cereal') |
| 90 | endif |
| 91 | |
Patrick Williams | a937491 | 2023-12-07 17:22:45 -0600 | [diff] [blame] | 92 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Patrick Williams | 447c183 | 2024-02-28 11:15:33 -0600 | [diff] [blame] | 93 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 94 | phosphor_logging_dep = dependency('phosphor-logging') |
| 95 | sdeventplus_dep = dependency('sdeventplus') |
Sheldon Bailey | 16a5adb | 2025-06-10 14:10:06 -0500 | [diff] [blame^] | 96 | libpldm_dep = dependency('libpldm') |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 97 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 98 | deps += [ |
Patrick Williams | f6992a4 | 2024-02-28 11:12:24 -0600 | [diff] [blame] | 99 | cereal_dep, |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 100 | nlohmann_json_dep, |
| 101 | phosphor_dbus_interfaces_dep, |
| 102 | phosphor_logging_dep, |
| 103 | sdbusplus_dep, |
| 104 | sdeventplus_dep, |
Sheldon Bailey | 16a5adb | 2025-06-10 14:10:06 -0500 | [diff] [blame^] | 105 | libpldm_dep, |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 106 | ] |
Patrick Williams | d86651f | 2023-02-08 09:31:48 -0600 | [diff] [blame] | 107 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 108 | sources += [ |
| 109 | 'app.cpp', |
| 110 | 'occ_pass_through.cpp', |
| 111 | 'occ_manager.cpp', |
| 112 | 'occ_status.cpp', |
| 113 | 'occ_device.cpp', |
| 114 | 'occ_errors.cpp', |
| 115 | 'occ_ffdc.cpp', |
| 116 | 'occ_presence.cpp', |
| 117 | 'occ_command.cpp', |
| 118 | 'occ_dbus.cpp', |
| 119 | 'powercap.cpp', |
Sheldon Bailey | 16a5adb | 2025-06-10 14:10:06 -0500 | [diff] [blame^] | 120 | 'powermode.cpp', |
| 121 | 'pldm.cpp', |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 122 | 'utils.cpp', |
| 123 | ] |
| 124 | |
Chris Cain | 720a384 | 2025-01-09 10:23:36 -0600 | [diff] [blame] | 125 | if get_option('phal-support').allowed() |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 126 | deps += [cxx.find_library('pdbg'), cxx.find_library('phal')] |
Chris Cain | 720a384 | 2025-01-09 10:23:36 -0600 | [diff] [blame] | 127 | endif |
| 128 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 129 | yamldir = get_option('yamldir') |
| 130 | if yamldir == '' |
| 131 | yamldir = meson.project_source_root() / 'example' |
| 132 | endif |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 133 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 134 | # Generate occ-sensor.hpp. |
| 135 | occ_sensor_hpp = custom_target( |
| 136 | 'occ-sensor.hpp', |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 137 | command: [ |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 138 | python_prog, |
| 139 | meson.project_source_root() + '/sensor_gen.py', |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 140 | '-i', |
| 141 | yamldir, |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 142 | ], |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 143 | output: 'occ-sensor.hpp', |
| 144 | ) |
| 145 | sources += [occ_sensor_hpp] |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 146 | |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 147 | executable( |
| 148 | 'openpower-occ-control', |
| 149 | sources, |
| 150 | include_directories: '.', |
| 151 | implicit_include_directories: true, |
| 152 | dependencies: deps, |
| 153 | install: true, |
| 154 | install_dir: get_option('bindir'), |
| 155 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 156 | |
Patrick Williams | eb88805 | 2025-01-30 17:47:34 -0500 | [diff] [blame] | 157 | if get_option('tests').allowed() |
Patrick Williams | 601cea4 | 2025-02-01 08:36:51 -0500 | [diff] [blame] | 158 | subdir('test') |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 159 | endif |