1project( 2 'openpower-occ-control', 'cpp', 3 version : '1.0.0', 4 meson_version: '>=1.1.1', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++23', 9 'buildtype=debugoptimized' 10 ] 11) 12 13cxx = meson.get_compiler('cpp') 14 15conf_data = configuration_data() 16conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control') 17conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control') 18conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors') 19conf_data.set_quoted('CPU_NAME', 'cpu') 20conf_data.set_quoted('OCC_NAME', 'occ') 21conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1') 22conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ') 23conf_data.set_quoted('CPU_SUBPATH', '/xyz/openbmc_project/inventory/system/chassis/motherboard') 24conf_data.set_quoted('OCC_CONTROL_PERSIST_PATH', '/var/lib/openpower-occ-control') 25 26conf_data.set('MAX_CPUS', get_option('max-cpus')) 27conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0) 28conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0) 29conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor')) 30 31if get_option('i2c-occ').allowed() 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') 35else 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/') 38endif 39 40conf_data.set('I2C_OCC', get_option('i2c-occ').allowed()) 41conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').allowed()) 42conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm') 43conf_data.set('POWER10', get_option('power10-support').allowed()) 44 45configure_file(output: 'config.h', 46 configuration: conf_data 47) 48 49install_data('occ-active.sh', 50 install_mode: 'rwxr-xr-x', 51 install_dir: get_option('bindir') 52) 53 54systemd = dependency('systemd') 55systemd_system_unit_dir = systemd.get_variable( 56 'systemdsystemunitdir') 57subdir('service_files') 58 59sdbusplus_dep = dependency('sdbusplus') 60 61python_prog = find_program('python3', required: true) 62 63deps = [] 64sources = [] 65 66cereal_dep = dependency('cereal', required: false) 67has_cereal = cxx.has_header_symbol( 68 'cereal/cereal.hpp', 69 'cereal::specialize', 70 dependencies: cereal_dep, 71 required: false) 72if not has_cereal 73 cereal_opts = import('cmake').subproject_options() 74 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) 75 cereal_proj = import('cmake').subproject( 76 'cereal', 77 options: cereal_opts, 78 required: false) 79 assert(cereal_proj.found(), 'cereal is required') 80 cereal_dep = cereal_proj.dependency('cereal') 81endif 82 83nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 84sdeventplus_dep = dependency( 85 'sdeventplus', 86 fallback: [ 87 'sdeventplus', 88 'sdeventplus_dep' 89 ], 90) 91phosphor_dbus_interfaces_dep = dependency( 92 'phosphor-dbus-interfaces', 93 fallback: [ 94 'phosphor-dbus-interfaces', 95 'phosphor_dbus_interfaces_dep' 96 ], 97) 98phosphor_logging_dep = dependency( 99 'phosphor-logging', 100 fallback: [ 101 'phosphor-logging', 102 'phosphor_logging_dep' 103 ], 104) 105 106deps += [ 107 cereal_dep, 108 nlohmann_json_dep, 109 phosphor_dbus_interfaces_dep, 110 phosphor_logging_dep, 111 sdbusplus_dep, 112 sdeventplus_dep, 113] 114 115sources += [ 116 'app.cpp', 117 'occ_pass_through.cpp', 118 'occ_manager.cpp', 119 'occ_status.cpp', 120 'occ_device.cpp', 121 'occ_errors.cpp', 122 'occ_ffdc.cpp', 123 'occ_presence.cpp', 124 'occ_command.cpp', 125 'occ_dbus.cpp', 126 'powercap.cpp', 127 'i2c_occ.cpp', 128 'utils.cpp', 129] 130 131if get_option('with-host-communication-protocol')=='pldm' 132 libpldm_dep = dependency( 133 'libpldm', 134 fallback: ['pldm', 'libpldm_dep'], 135 default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'], 136 ) 137 deps += [ 138 libpldm_dep, 139 cxx.find_library('pdbg'), 140 cxx.find_library('phal'), 141 ] 142 sources += [ 143 'pldm.cpp', 144 ] 145endif 146 147if get_option('power10-support').allowed() 148 sources += [ 149 'powermode.cpp', 150 ] 151endif 152 153yamldir = get_option('yamldir') 154if yamldir == '' 155 yamldir = meson.project_source_root() / 'example' 156endif 157 158# Generate occ-sensor.hpp. 159occ_sensor_hpp = custom_target( 160 'occ-sensor.hpp', 161 command : [ 162 python_prog, 163 meson.project_source_root() + '/sensor_gen.py', 164 '-i', yamldir, 165 ], 166 output : 'occ-sensor.hpp') 167 sources += [occ_sensor_hpp] 168 169 executable( 170 'openpower-occ-control', 171 sources, 172 include_directories: '.', 173 implicit_include_directories: true, 174 dependencies: deps, 175 install: true, 176 install_dir: get_option('bindir') 177 ) 178 179if not get_option('tests').disabled() 180 subdir('test') 181endif 182