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