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') |
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 | |
Patrick Williams | a8ebb1d | 2023-11-29 06:44:15 -0600 | [diff] [blame] | 31 | if get_option('i2c-occ').allowed() |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 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 | |
Patrick Williams | a8ebb1d | 2023-11-29 06:44:15 -0600 | [diff] [blame] | 40 | conf_data.set('I2C_OCC', get_option('i2c-occ').allowed()) |
| 41 | conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').allowed()) |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 42 | conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm') |
Patrick Williams | a8ebb1d | 2023-11-29 06:44:15 -0600 | [diff] [blame] | 43 | conf_data.set('POWER10', get_option('power10-support').allowed()) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 44 | |
| 45 | configure_file(output: 'config.h', |
| 46 | configuration: conf_data |
| 47 | ) |
| 48 | |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 49 | install_data('occ-active.sh', |
| 50 | install_mode: 'rwxr-xr-x', |
| 51 | install_dir: get_option('bindir') |
| 52 | ) |
| 53 | |
| 54 | systemd = dependency('systemd') |
| 55 | systemd_system_unit_dir = systemd.get_variable( |
Patrick Williams | 47831f5 | 2023-04-12 08:01:05 -0500 | [diff] [blame] | 56 | 'systemdsystemunitdir') |
Chris Cain | 7bd6d14 | 2023-01-11 13:41:09 -0600 | [diff] [blame] | 57 | subdir('service_files') |
| 58 | |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 59 | sdbusplus_dep = dependency('sdbusplus') |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 60 | |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 61 | python_prog = find_program('python3', required: true) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 62 | |
| 63 | deps = [] |
| 64 | sources = [] |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 65 | |
Patrick Williams | a937491 | 2023-12-07 17:22:45 -0600 | [diff] [blame] | 66 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 67 | sdeventplus_dep = dependency( |
| 68 | 'sdeventplus', |
| 69 | fallback: [ |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 70 | 'sdeventplus', |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 71 | 'sdeventplus_dep' |
| 72 | ], |
| 73 | ) |
| 74 | phosphor_dbus_interfaces_dep = dependency( |
| 75 | 'phosphor-dbus-interfaces', |
| 76 | fallback: [ |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 77 | 'phosphor-dbus-interfaces', |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 78 | 'phosphor_dbus_interfaces_dep' |
| 79 | ], |
| 80 | ) |
| 81 | phosphor_logging_dep = dependency( |
| 82 | 'phosphor-logging', |
| 83 | fallback: [ |
Patrick Williams | 18dcfb4 | 2023-02-08 09:25:22 -0600 | [diff] [blame] | 84 | 'phosphor-logging', |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 85 | 'phosphor_logging_dep' |
| 86 | ], |
| 87 | ) |
| 88 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 89 | deps += [ |
| 90 | nlohmann_json_dep, |
| 91 | phosphor_dbus_interfaces_dep, |
| 92 | phosphor_logging_dep, |
| 93 | sdbusplus_dep, |
| 94 | sdeventplus_dep, |
| 95 | ] |
Patrick Williams | d86651f | 2023-02-08 09:31:48 -0600 | [diff] [blame] | 96 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 97 | sources += [ |
| 98 | 'app.cpp', |
| 99 | 'occ_pass_through.cpp', |
| 100 | 'occ_manager.cpp', |
| 101 | 'occ_status.cpp', |
| 102 | 'occ_device.cpp', |
| 103 | 'occ_errors.cpp', |
| 104 | 'occ_ffdc.cpp', |
| 105 | 'occ_presence.cpp', |
| 106 | 'occ_command.cpp', |
| 107 | 'occ_dbus.cpp', |
| 108 | 'powercap.cpp', |
| 109 | 'i2c_occ.cpp', |
| 110 | 'utils.cpp', |
| 111 | ] |
| 112 | |
| 113 | if get_option('with-host-communication-protocol')=='pldm' |
| 114 | libpldm_dep = dependency( |
| 115 | 'libpldm', |
| 116 | fallback: ['pldm', 'libpldm_dep'], |
| 117 | default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'], |
| 118 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 119 | deps += [ |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 120 | libpldm_dep, |
| 121 | cxx.find_library('pdbg'), |
| 122 | cxx.find_library('phal'), |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 123 | ] |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 124 | sources += [ |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 125 | 'pldm.cpp', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 126 | ] |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 127 | endif |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 128 | |
Patrick Williams | a8ebb1d | 2023-11-29 06:44:15 -0600 | [diff] [blame] | 129 | if get_option('power10-support').allowed() |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 130 | sources += [ |
| 131 | 'powermode.cpp', |
| 132 | ] |
| 133 | endif |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 134 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 135 | yamldir = get_option('yamldir') |
| 136 | if yamldir == '' |
| 137 | yamldir = meson.project_source_root() / 'example' |
| 138 | endif |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 139 | |
Patrick Williams | 9bec8af | 2023-09-07 14:02:27 -0500 | [diff] [blame] | 140 | # Generate occ-sensor.hpp. |
| 141 | occ_sensor_hpp = custom_target( |
| 142 | 'occ-sensor.hpp', |
| 143 | command : [ |
| 144 | python_prog, |
| 145 | meson.project_source_root() + '/sensor_gen.py', |
| 146 | '-i', yamldir, |
| 147 | ], |
| 148 | output : 'occ-sensor.hpp') |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 149 | sources += [occ_sensor_hpp] |
| 150 | |
| 151 | executable( |
| 152 | 'openpower-occ-control', |
| 153 | sources, |
Patrick Williams | d8aab2a | 2023-04-21 11:15:54 -0500 | [diff] [blame] | 154 | include_directories: '.', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 155 | implicit_include_directories: true, |
| 156 | dependencies: deps, |
| 157 | install: true, |
| 158 | install_dir: get_option('bindir') |
| 159 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 160 | |
| 161 | if not get_option('tests').disabled() |
| 162 | subdir('test') |
| 163 | endif |