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