1project( 2 'phosphor-pid-control', 3 'cpp', 4 version: '1.0.0', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'warning_level=3', 8 'werror=true', 9 'cpp_std=c++23', 10 'b_lto=true', 11 ], 12) 13 14cxx = meson.get_compiler('cpp') 15 16conf_data = configuration_data() 17 18conf_data.set('STRICT_FAILSAFE_PWM', get_option('strict-failsafe-pwm')) 19conf_data.set('OFFLINE_FAILSAFE_PWM', get_option('offline-failsafe-pwm')) 20conf_data.set('UNC_FAILSAFE', get_option('unc-failsafe')) 21conf_data.set( 22 'HANDLE_MISSING_OBJECT_PATHS', 23 get_option('handle-missing-object-paths'), 24) 25 26configure_file(output: 'config.h', configuration: conf_data) 27 28if get_option('oe-sdk').allowed() 29 OECORE_TARGET_SYSROOT = run_command( 30 'sh', 31 '-c', 32 'echo $OECORE_TARGET_SYSROOT', 33 ).stdout().strip() 34 if OECORE_TARGET_SYSROOT == '' 35 error('OECORE_TARGET_SYSROOT must be set with enable oe-sdk') 36 endif 37 message('Enabling OE-SDK at OECORE_TARGET_SYSROOT: ' + OECORE_TARGET_SYSROOT) 38 rpath = ':'.join( 39 [OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'], 40 ) 41 ld_so = run_command( 42 'sh', 43 '-c', 44 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1', 45 ).stdout().strip() 46 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] 47else 48 dynamic_linker = [] 49endif 50 51systemd = dependency('systemd') 52systemd_system_unit_dir = systemd.get_variable( 53 'systemdsystemunitdir', 54 pkgconfig_define: ['prefix', get_option('prefix')], 55) 56 57systemd_conf_data = configuration_data() 58bindir = get_option('prefix') / get_option('bindir') 59systemd_conf_data.set('BINDIR', bindir) 60systemd_conf_data.set('SYSTEMD_TARGET', get_option('systemd_target')) 61 62configure_file( 63 input: 'phosphor-pid-control.service.in', 64 output: 'phosphor-pid-control.service', 65 configuration: systemd_conf_data, 66 install: true, 67 install_dir: systemd_system_unit_dir, 68) 69 70nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 71phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 72phosphor_logging_dep = dependency('phosphor-logging') 73sdbusplus_dep = dependency('sdbusplus') 74libsystemd_dep = dependency('libsystemd') 75ipmid_dep = dependency('libipmid') 76 77 78if cxx.has_header('CLI/CLI.hpp') 79 CLI11_dep = declare_dependency() 80else 81 CLI11_dep = dependency('CLI11') 82endif 83 84deps = [ 85 CLI11_dep, 86 ipmid_dep, 87 libsystemd_dep, 88 nlohmann_json_dep, 89 phosphor_dbus_interfaces_dep, 90 phosphor_logging_dep, 91 sdbusplus_dep, 92] 93 94root_inc = include_directories( 95 '.', 96 'buildjson', 97 'dbus', 98 'errors', 99 'experiments', 100 'ipmi', 101 'notimpl', 102 'pid', 103 'sensors', 104 'sysfs', 105) 106 107setsensor_sources = ['setsensor.cpp'] 108 109libswampd_sources = [ 110 'main.cpp', 111 'util.cpp', 112 'notimpl/readonly.cpp', 113 'notimpl/writeonly.cpp', 114 'dbus/dbusconfiguration.cpp', 115 'dbus/dbusutil.cpp', 116 'dbus/dbushelper.cpp', 117 'dbus/dbuspassiveredundancy.cpp', 118 'dbus/dbuspassive.cpp', 119 'dbus/dbuswrite.cpp', 120 'failsafeloggers/builder.cpp', 121 'failsafeloggers/failsafe_logger_utility.cpp', 122 'sysfs/sysfsread.cpp', 123 'sysfs/sysfswrite.cpp', 124 'sysfs/util.cpp', 125 'sensors/pluggable.cpp', 126 'sensors/host.cpp', 127 'sensors/builder.cpp', 128 'sensors/buildjson.cpp', 129 'sensors/manager.cpp', 130 'sensors/build_utils.cpp', 131 'pid/ec/pid.cpp', 132 'pid/ec/logging.cpp', 133 'pid/ec/stepwise.cpp', 134 'pid/fancontroller.cpp', 135 'pid/thermalcontroller.cpp', 136 'pid/pidcontroller.cpp', 137 'pid/stepwisecontroller.cpp', 138 'pid/builder.cpp', 139 'pid/buildjson.cpp', 140 'pid/zone.cpp', 141 'pid/util.cpp', 142 'pid/pidloop.cpp', 143 'pid/tuning.cpp', 144 'buildjson/buildjson.cpp', 145 'experiments/drive.cpp', 146] 147 148libmanualcmds_sources = [ 149 'ipmi/main_ipmi.cpp', 150 'ipmi/manualcmds.cpp', 151 'ipmi/dbus_mode.cpp', 152] 153 154libmanualcmds = library( 155 'manualcmds', 156 libmanualcmds_sources, 157 implicit_include_directories: false, 158 dependencies: deps, 159 version: meson.project_version(), 160 override_options: ['b_lundef=false'], 161 install: true, 162 install_dir: get_option('libdir') / 'ipmid-providers', 163) 164 165executable( 166 'swampd', 167 libswampd_sources, 168 implicit_include_directories: false, 169 include_directories: root_inc, 170 dependencies: deps, 171 install: true, 172 install_dir: get_option('bindir'), 173) 174 175executable( 176 'setsensor', 177 setsensor_sources, 178 implicit_include_directories: true, 179 dependencies: deps, 180 install: true, 181 install_dir: get_option('bindir'), 182) 183 184if get_option('tests').allowed() 185 subdir('test') 186endif 187