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