-
Notifications
You must be signed in to change notification settings - Fork 10
/
meson.build
191 lines (170 loc) · 5.67 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
project(
'phosphor-power',
'cpp',
default_options: [
'warning_level=3',
'werror=true',
'cpp_std=c++23',
'buildtype=debugoptimized',
'prefix=/usr'
],
license: 'Apache-2.0',
version: '1.0',
meson_version: '>=1.1.1',
)
cxx = meson.get_compiler('cpp')
build_tests = get_option('tests')
if get_option('oe-sdk').allowed()
# Setup OE SYSROOT
OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
if OECORE_TARGET_SYSROOT == ''
error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
endif
message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
else
dynamic_linker = []
endif
gmock = dependency('gmock', disabler: true, required: false)
gtest = dependency('gtest', main: true, disabler: true, required: false)
if (not gtest.found() or not gmock.found()) and build_tests.allowed()
gtest_opts = import('cmake').subproject_options()
gtest_opts.add_cmake_defines({
'BUILD_SHARED_LIBS': 'ON'
})
gtest_proj = import('cmake').subproject('googletest',
options: gtest_opts,
required: false)
if gtest_proj.found()
gtest = declare_dependency(
dependencies: [
dependency('threads'),
gtest_proj.dependency('gtest'),
gtest_proj.dependency('gtest_main'),
]
)
gmock = gtest_proj.dependency('gmock')
else
assert(false, 'Googletest is required if tests are enabled')
endif
endif
phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
phosphor_logging = dependency('phosphor-logging')
prog_python = import('python').find_installation('python3')
sdbusplus = dependency('sdbusplus')
sdbuspp = find_program('sdbus++')
sdeventplus = dependency('sdeventplus')
pthread = dependency('threads')
stdplus = dependency('stdplus')
boost = dependency('boost')
libgpiodcxx = dependency('libgpiodcxx',
default_options: ['bindings=cxx'])
nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
if cxx.has_header('CLI/CLI.hpp')
cli11_dep = declare_dependency()
else
cli11_dep = dependency('CLI11')
endif
systemd = dependency('systemd')
libsystemd_dep = dependency('libsystemd')
servicedir = systemd.get_variable('systemdsystemunitdir')
services = [
['supply-monitor', '[email protected]'],
['sequencer-monitor', 'pseq-monitor-pgood.service'],
['sequencer-monitor', 'pseq-monitor.service'],
['supply-monitor-ng', 'phosphor-psu-monitor.service'],
['regulators', 'phosphor-regulators.service'],
['regulators', 'phosphor-regulators-config.service'],
['regulators', 'phosphor-regulators-monitor-enable.service'],
['regulators', 'phosphor-regulators-monitor-disable.service'],
['power-control', 'phosphor-power-control.service'],
]
fs = import('fs')
foreach service : services
if get_option(service[0])
fs.copyfile('services/' + service[1],
install: true,
install_dir: servicedir)
endif
endforeach
# Get the power sequencer class name
sequencer = get_option('power_sequencer')
if sequencer == 'ucd90160'
sequencer_class = 'UCD90160'
elif sequencer == 'mihawk-cpld'
sequencer_class = 'MihawkCPLD'
else
# power sequencer is incorrect
error('power sequencer is incorrect')
endif
conf = configuration_data()
conf.set_quoted(
'INPUT_HISTORY_BUSNAME_ROOT', get_option('input-history-busname-root'))
conf.set_quoted(
'INPUT_HISTORY_SENSOR_ROOT', get_option('input-history-sensor-root'))
conf.set_quoted(
'INPUT_HISTORY_SYNC_GPIO', get_option('input-history-sync-gpio'))
conf.set_quoted(
'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json')
conf.set(
'SEQUENCER', sequencer_class)
conf.set10(
'DEVICE_ACCESS', get_option('device-access'))
conf.set10('IBM_VPD', get_option('ibm-vpd'))
configure_file(output: 'config.h', configuration: conf)
# Ensure the generated header here winds up in the correct path in the build
# tree such that it actually get used and doesn't get found in the sysroot
# somewhere. Meson doesn't allow path elements (rightfully so) when specifying
# the output filename of a target definition so the target must be defined in
# the directory where the artifacts need to be placed. Do that now, because
# the generated source (cpp) is needed to define the library target.
subdir('org/open_power/Witherspoon/Fault')
libpower = static_library(
'power',
error_cpp,
error_hpp,
'compatible_system_types_finder.cpp',
'dbus_interfaces_finder.cpp',
'gpio.cpp',
'pmbus.cpp',
'temporary_file.cpp',
'temporary_subdirectory.cpp',
'utility.cpp',
dependencies: [
nlohmann_json_dep,
phosphor_dbus_interfaces,
phosphor_logging,
sdbusplus,
sdeventplus,
],
)
libpower_inc = include_directories('.')
# Build the tools/i2c sub-directory first. Other sub-directories depend on
# Meson variables defined there.
subdir('tools/i2c')
if get_option('regulators')
subdir('phosphor-regulators')
endif
if get_option('sequencer-monitor')
subdir('power-sequencer')
endif
if get_option('power-control')
subdir('phosphor-power-sequencer')
endif
if get_option('supply-monitor')
subdir('power-supply')
endif
if get_option('supply-monitor-ng')
subdir('phosphor-power-supply')
endif
if get_option('utils')
subdir('tools/power-utils')
endif
if get_option('tests').allowed()
subdir('test')
endif
if get_option('cold-redundancy')
subdir('cold-redundancy')
endif