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 | 47831f5 | 2023-04-12 08:01:05 -0500 | [diff] [blame] | 4 | meson_version: '>=0.58.0', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
| 8 | 'cpp_std=c++20', |
| 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') |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 25 | |
| 26 | conf_data.set('MAX_CPUS', get_option('max-cpus')) |
| 27 | conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0) |
| 28 | conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0) |
Eddie James | 3f710bd | 2021-10-20 13:40:52 -0500 | [diff] [blame] | 29 | conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor')) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 30 | |
| 31 | if get_option('i2c-occ').enabled() |
| 32 | conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/i2c/drivers/occ-hwmon/') |
| 33 | conf_data.set_quoted('DEV_PATH', '/sys/bus/i2c/devices') |
| 34 | conf_data.set_quoted('I2C_OCC_DEVICE_NAME', 'p8-occ-hwmon') |
| 35 | else |
| 36 | conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/') |
| 37 | conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/') |
| 38 | endif |
| 39 | |
| 40 | if get_option('install-error-yaml').disabled() |
| 41 | conf_data.set('I2C_OCC', get_option('i2c-occ').enabled()) |
| 42 | conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').enabled()) |
| 43 | conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm') |
| 44 | conf_data.set('POWER10', get_option('power10-support').enabled()) |
| 45 | endif |
| 46 | |
| 47 | configure_file(output: 'config.h', |
| 48 | configuration: conf_data |
| 49 | ) |
| 50 | |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 51 | install_data('occ-active.sh', |
| 52 | install_mode: 'rwxr-xr-x', |
| 53 | install_dir: get_option('bindir') |
| 54 | ) |
| 55 | |
| 56 | systemd = dependency('systemd') |
| 57 | systemd_system_unit_dir = systemd.get_variable( |
Patrick Williams | 47831f5 | 2023-04-12 08:01:05 -0500 | [diff] [blame] | 58 | 'systemdsystemunitdir') |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 59 | subdir('service_files') |
| 60 | |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 61 | sdbusplus_dep = dependency('sdbusplus') |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 62 | |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 63 | python_prog = find_program('python3', required: true) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 64 | |
| 65 | deps = [] |
| 66 | sources = [] |
| 67 | if get_option('install-error-yaml').disabled() |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 68 | sdeventplus_dep = dependency( |
| 69 | 'sdeventplus', |
| 70 | fallback: [ |
| 71 | 'sdeventplus', |
| 72 | 'sdeventplus_dep' |
| 73 | ], |
| 74 | ) |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 75 | phosphor_dbus_interfaces_dep = dependency( |
| 76 | 'phosphor-dbus-interfaces', |
| 77 | fallback: [ |
| 78 | 'phosphor-dbus-interfaces', |
| 79 | 'phosphor_dbus_interfaces_dep' |
| 80 | ], |
| 81 | ) |
Patrick Williams | 18dcfb4 | 2023-02-08 09:25:22 -0600 | [diff] [blame] | 82 | phosphor_logging_dep = dependency( |
| 83 | 'phosphor-logging', |
| 84 | fallback: [ |
| 85 | 'phosphor-logging', |
| 86 | 'phosphor_logging_dep' |
| 87 | ], |
| 88 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 89 | |
Patrick Williams | d86651f | 2023-02-08 09:31:48 -0600 | [diff] [blame] | 90 | if cxx.has_header('nlohmann/json.hpp') |
| 91 | nlohmann_json_dep = declare_dependency() |
| 92 | else |
| 93 | subproject('nlohmann-json') |
| 94 | nlohmann_json_dep = declare_dependency( |
| 95 | include_directories: [ |
| 96 | 'subprojects/nlohmann-json/single_include', |
| 97 | 'subprojects/nlohmann-json/single_include/nlohmann', |
| 98 | ] |
| 99 | ) |
| 100 | endif |
| 101 | |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 102 | deps += [ |
Patrick Williams | d86651f | 2023-02-08 09:31:48 -0600 | [diff] [blame] | 103 | nlohmann_json_dep, |
| 104 | phosphor_dbus_interfaces_dep, |
| 105 | phosphor_logging_dep, |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 106 | sdbusplus_dep, |
| 107 | sdeventplus_dep, |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 108 | ] |
| 109 | |
| 110 | sources += [ |
| 111 | 'app.cpp', |
| 112 | 'occ_pass_through.cpp', |
| 113 | 'occ_manager.cpp', |
| 114 | 'occ_status.cpp', |
| 115 | 'occ_device.cpp', |
| 116 | 'occ_errors.cpp', |
Eddie James | 2f9f9bb | 2021-09-20 14:26:31 -0500 | [diff] [blame] | 117 | 'occ_ffdc.cpp', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 118 | 'occ_presence.cpp', |
| 119 | 'occ_command.cpp', |
| 120 | 'occ_dbus.cpp', |
| 121 | 'powercap.cpp', |
| 122 | 'i2c_occ.cpp', |
| 123 | 'utils.cpp', |
| 124 | ] |
| 125 | |
| 126 | if get_option('with-host-communication-protocol')=='pldm' |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 127 | libpldm_dep = dependency( |
| 128 | 'libpldm', |
| 129 | fallback: ['pldm', 'libpldm_dep'], |
| 130 | default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'], |
| 131 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 132 | deps += [ |
| 133 | libpldm_dep, |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 134 | cxx.find_library('pdbg'), |
| 135 | cxx.find_library('phal'), |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 136 | ] |
| 137 | sources += [ |
| 138 | 'pldm.cpp', |
| 139 | ] |
| 140 | endif |
| 141 | |
| 142 | if get_option('power10-support').enabled() |
| 143 | sources += [ |
| 144 | 'powermode.cpp', |
| 145 | ] |
| 146 | endif |
| 147 | |
| 148 | yamldir = get_option('yamldir') |
| 149 | if yamldir == '' |
Eddie James | 6b234c1 | 2021-10-20 16:35:47 -0500 | [diff] [blame] | 150 | yamldir = meson.project_source_root() / 'example' |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 151 | endif |
| 152 | |
| 153 | # Generate occ-sensor.hpp. |
| 154 | occ_sensor_hpp = custom_target( |
| 155 | 'occ-sensor.hpp', |
| 156 | command : [ |
| 157 | python_prog, |
| 158 | meson.project_source_root() + '/sensor_gen.py', |
Eddie James | 6b234c1 | 2021-10-20 16:35:47 -0500 | [diff] [blame] | 159 | '-i', yamldir, |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 160 | ], |
| 161 | output : 'occ-sensor.hpp') |
| 162 | sources += [occ_sensor_hpp] |
| 163 | |
| 164 | executable( |
| 165 | 'openpower-occ-control', |
| 166 | sources, |
Patrick Williams | d8aab2a | 2023-04-21 11:15:54 -0500 | [diff] [blame^] | 167 | include_directories: '.', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 168 | implicit_include_directories: true, |
| 169 | dependencies: deps, |
| 170 | install: true, |
| 171 | install_dir: get_option('bindir') |
| 172 | ) |
| 173 | endif |
| 174 | |
| 175 | if not get_option('tests').disabled() |
| 176 | subdir('test') |
| 177 | endif |