George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'openpower-occ-control', 'cpp', |
| 3 | version : '1.0.0', |
| 4 | meson_version: '>=0.57.0', |
| 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 | |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 51 | sdbusplus_dep = dependency('sdbusplus') |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 52 | sdbusplusplus_prog = find_program('sdbus++') |
| 53 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') |
Patrick Williams | e2a5851 | 2022-09-13 11:26:57 -0500 | [diff] [blame] | 54 | sdbusplusplus_depfiles = files() |
| 55 | if sdbusplus_dep.type_name() == 'internal' |
| 56 | sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles') |
| 57 | endif |
| 58 | |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 59 | python_prog = find_program('python3', required: true) |
| 60 | realpath_prog = find_program('realpath') |
| 61 | |
| 62 | selected_subdirs = [] |
| 63 | selected_subdirs += 'org/open_power/OCC' |
| 64 | |
| 65 | generated_root = meson.current_build_dir() / 'gen' |
| 66 | generated_others = [] |
| 67 | generated_sources = [] |
| 68 | |
| 69 | # Source the generated meson files. |
| 70 | subdir('gen') |
| 71 | foreach d : selected_subdirs |
| 72 | subdir('gen' / d) |
| 73 | endforeach |
| 74 | |
| 75 | # Parse through the list from sdbus++-gendir and put into sets. |
| 76 | generated_headers = [] |
| 77 | generated_cpp = [] |
| 78 | generated_others_files = [] |
| 79 | |
| 80 | foreach g : generated_sources generated_others |
| 81 | foreach f : g.to_list() |
| 82 | rel_path = run_command( |
| 83 | realpath_prog, |
| 84 | '--relative-to', generated_root, |
| 85 | f.full_path(), |
| 86 | ).stdout().strip().split('\n')[-1] |
| 87 | |
| 88 | if rel_path.endswith('.hpp') |
| 89 | generated_headers += rel_path |
| 90 | elif rel_path.endswith('.cpp') |
| 91 | generated_cpp += rel_path |
| 92 | else |
| 93 | generated_others_files += rel_path |
| 94 | endif |
| 95 | endforeach |
| 96 | endforeach |
| 97 | |
| 98 | deps = [] |
| 99 | sources = [] |
| 100 | if get_option('install-error-yaml').disabled() |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 101 | sdeventplus_dep = dependency( |
| 102 | 'sdeventplus', |
| 103 | fallback: [ |
| 104 | 'sdeventplus', |
| 105 | 'sdeventplus_dep' |
| 106 | ], |
| 107 | ) |
| 108 | phosphor_logging_dep = dependency( |
| 109 | 'phosphor-logging', |
| 110 | fallback: [ |
| 111 | 'phosphor-logging', |
| 112 | 'phosphor_logging_dep' |
| 113 | ], |
| 114 | ) |
| 115 | phosphor_dbus_interfaces_dep = dependency( |
| 116 | 'phosphor-dbus-interfaces', |
| 117 | fallback: [ |
| 118 | 'phosphor-dbus-interfaces', |
| 119 | 'phosphor_dbus_interfaces_dep' |
| 120 | ], |
| 121 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 122 | |
| 123 | deps += [ |
| 124 | sdbusplus_dep, |
| 125 | sdeventplus_dep, |
| 126 | phosphor_logging_dep, |
| 127 | phosphor_dbus_interfaces_dep, |
| 128 | ] |
| 129 | |
| 130 | sources += [ |
| 131 | 'app.cpp', |
| 132 | 'occ_pass_through.cpp', |
| 133 | 'occ_manager.cpp', |
| 134 | 'occ_status.cpp', |
| 135 | 'occ_device.cpp', |
| 136 | 'occ_errors.cpp', |
Eddie James | 2f9f9bb | 2021-09-20 14:26:31 -0500 | [diff] [blame] | 137 | 'occ_ffdc.cpp', |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 138 | 'occ_presence.cpp', |
| 139 | 'occ_command.cpp', |
| 140 | 'occ_dbus.cpp', |
| 141 | 'powercap.cpp', |
| 142 | 'i2c_occ.cpp', |
| 143 | 'utils.cpp', |
| 144 | ] |
| 145 | |
| 146 | if get_option('with-host-communication-protocol')=='pldm' |
George Liu | 9ed399d | 2021-09-10 13:14:27 +0800 | [diff] [blame] | 147 | libpldm_dep = dependency( |
| 148 | 'libpldm', |
| 149 | fallback: ['pldm', 'libpldm_dep'], |
| 150 | default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'], |
| 151 | ) |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 152 | deps += [ |
| 153 | libpldm_dep, |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 154 | cxx.find_library('pdbg'), |
| 155 | cxx.find_library('phal'), |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 156 | ] |
| 157 | sources += [ |
| 158 | 'pldm.cpp', |
| 159 | ] |
| 160 | endif |
| 161 | |
| 162 | if get_option('power10-support').enabled() |
| 163 | sources += [ |
| 164 | 'powermode.cpp', |
| 165 | ] |
| 166 | endif |
| 167 | |
| 168 | yamldir = get_option('yamldir') |
| 169 | if yamldir == '' |
Eddie James | 6b234c1 | 2021-10-20 16:35:47 -0500 | [diff] [blame] | 170 | yamldir = meson.project_source_root() / 'example' |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 171 | endif |
| 172 | |
| 173 | # Generate occ-sensor.hpp. |
| 174 | occ_sensor_hpp = custom_target( |
| 175 | 'occ-sensor.hpp', |
| 176 | command : [ |
| 177 | python_prog, |
| 178 | meson.project_source_root() + '/sensor_gen.py', |
Eddie James | 6b234c1 | 2021-10-20 16:35:47 -0500 | [diff] [blame] | 179 | '-i', yamldir, |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 180 | ], |
| 181 | output : 'occ-sensor.hpp') |
| 182 | sources += [occ_sensor_hpp] |
| 183 | |
| 184 | executable( |
| 185 | 'openpower-occ-control', |
| 186 | sources, |
| 187 | generated_sources, |
| 188 | include_directories: ['.', 'gen'], |
| 189 | implicit_include_directories: true, |
| 190 | dependencies: deps, |
| 191 | install: true, |
| 192 | install_dir: get_option('bindir') |
| 193 | ) |
| 194 | endif |
| 195 | |
| 196 | if not get_option('tests').disabled() |
| 197 | subdir('test') |
| 198 | endif |