xref: /openbmc/phosphor-power/meson.build (revision cd9ab087)
1project(
2    'phosphor-power',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++17',
8        'prefix=/usr'
9    ],
10    license: 'Apache-2.0',
11    version: '1.0',
12)
13
14build_tests = get_option('tests')
15
16if get_option('oe-sdk').enabled()
17  # Setup OE SYSROOT
18  OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
19  if OECORE_TARGET_SYSROOT == ''
20    error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
21  endif
22  message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
23  rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
24  ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
25  dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
26else
27  dynamic_linker = []
28endif
29
30
31cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
32gmock = dependency('gmock', disabler: true, required: build_tests)
33gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
34phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
35phosphor_logging = dependency('phosphor-logging')
36prog_python = import('python').find_installation('python3')
37sdbusplus = dependency('sdbusplus')
38sdbuspp = find_program('sdbus++')
39sdeventplus = dependency('sdeventplus')
40pthread = dependency('threads')
41stdplus = dependency('stdplus')
42
43systemd = dependency('systemd')
44servicedir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
45
46services = [
47    'power-supply-monitor@.service',
48    'pseq-monitor-pgood.service',
49    'pseq-monitor.service',
50    'phosphor-psu-monitor.service',
51    'phosphor-regulators.service'
52]
53
54foreach service : services
55  configure_file(input: 'services/' + service,
56                 output: service,
57                 copy: true,
58                 install_dir: servicedir)
59endforeach
60
61# Get the power sequencer class name
62sequencer = get_option('power_sequencer')
63if sequencer == 'ucd90160'
64    sequencer_class = 'UCD90160'
65elif sequencer == 'mihawk-cpld'
66    sequencer_class = 'MihawkCPLD'
67else
68    # power sequencer is incorrect
69    error('power sequencer is incorrect')
70endif
71
72conf = configuration_data()
73conf.set_quoted(
74    'INPUT_HISTORY_BUSNAME_ROOT', get_option('input-history-busname-root'))
75conf.set_quoted(
76    'INPUT_HISTORY_SENSOR_ROOT', get_option('input-history-sensor-root'))
77conf.set_quoted(
78    'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json')
79conf.set(
80    'SEQUENCER', sequencer_class)
81conf.set10(
82    'DEVICE_ACCESS', get_option('device-access'))
83
84configure_file(output: 'config.h', configuration: conf)
85
86# Ensure the generated header here winds up in the correct path in the build
87# tree such that it actually get used and doesn't get found in the sysroot
88# somewhere.  Meson doesn't allow path elements (rightfully so) when specifying
89# the output filename of a target definition so the target must be defined in
90# the directory where the artifacts need to be placed.  Do that now, because
91# the generated source (cpp) is needed to define the library target.
92subdir('org/open_power/Witherspoon/Fault')
93
94libpower = static_library(
95    'power',
96    error_cpp,
97    error_hpp,
98    'gpio.cpp',
99    'pmbus.cpp',
100    'utility.cpp',
101    dependencies: [
102        cppfs,
103        phosphor_dbus_interfaces,
104        phosphor_logging,
105        sdbusplus,
106        sdeventplus,
107    ],
108)
109
110libpower_inc = include_directories('.')
111
112# Build the tools/i2c sub-directory first.  Other sub-directories depend on
113# Meson variables defined there.
114subdir('tools/i2c')
115
116subdir('phosphor-regulators')
117subdir('power-sequencer')
118subdir('power-supply')
119subdir('phosphor-power-supply')
120subdir('tools/power-utils')
121if get_option('tests').enabled()
122    subdir('test')
123endif
124subdir('cold-redundancy')
125