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