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