blob: 7d90fa3e788b7b8cfdc444260c91919d9d528098 [file] [log] [blame]
Brad Bishop39b370a2019-09-02 02:37:32 -04001project(
George Liu690e7802019-08-23 11:04:01 +08002 'phosphor-power',
Brad Bishop39b370a2019-09-02 02:37:32 -04003 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Matthew Barthd13feab2019-12-20 14:09:19 -06007 'cpp_std=c++17',
8 'prefix=/usr'
Brad Bishop39b370a2019-09-02 02:37:32 -04009 ],
10 license: 'Apache-2.0',
11 version: '1.0',
12)
13
14build_tests = get_option('tests')
15
Brandon Wymandc8e9312020-02-14 17:04:18 -060016if 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
Brad Bishop39b370a2019-09-02 02:37:32 -040031cppfs = 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)
Brad Bishop39b370a2019-09-02 02:37:32 -040034phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
35phosphor_logging = dependency('phosphor-logging')
Lei YU43082e72020-03-09 10:32:48 +080036prog_python = import('python').find_installation('python3')
Brad Bishop39b370a2019-09-02 02:37:32 -040037sdbusplus = dependency('sdbusplus')
38sdbuspp = find_program('sdbus++')
39sdeventplus = dependency('sdeventplus')
Cheng C Yange83604b2020-01-09 09:41:47 +080040pthread = dependency('threads')
Matthew Barth7cbc5532020-01-29 15:13:13 -060041stdplus = dependency('stdplus')
Andrew Geissler89283d12020-05-30 23:17:07 -050042boost = dependency('boost')
Brandon Wymanb76ab242020-09-16 18:06:06 -050043fmt = dependency('fmt')
Brad Bishop39b370a2019-09-02 02:37:32 -040044
Lei YUbd3bd822019-10-10 15:28:10 +080045systemd = dependency('systemd')
46servicedir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
47
48services = [
Brad Bishop1c40f1c2020-04-08 19:32:43 -040049 ['supply-monitor', 'power-supply-monitor@.service'],
50 ['sequencer-monitor', 'pseq-monitor-pgood.service'],
51 ['sequencer-monitor', 'pseq-monitor.service'],
52 ['supply-monitor-ng', 'phosphor-psu-monitor.service'],
53 ['regulators', 'phosphor-regulators.service'],
54 ['regulators', 'phosphor-regulators-config.service'],
55 ['regulators', 'phosphor-regulators-monitor-enable.service'],
56 ['regulators', 'phosphor-regulators-monitor-disable.service'],
Lei YUbd3bd822019-10-10 15:28:10 +080057]
58
59foreach service : services
Brad Bishop1c40f1c2020-04-08 19:32:43 -040060 if get_option(service[0])
61 configure_file(input: 'services/' + service[1],
62 output: service[1],
Lei YUbd3bd822019-10-10 15:28:10 +080063 copy: true,
64 install_dir: servicedir)
Brad Bishop1c40f1c2020-04-08 19:32:43 -040065 endif
Lei YUbd3bd822019-10-10 15:28:10 +080066endforeach
67
Andy YF Wang40247cc2019-09-06 18:30:56 +080068# Get the power sequencer class name
69sequencer = get_option('power_sequencer')
70if sequencer == 'ucd90160'
71 sequencer_class = 'UCD90160'
72elif sequencer == 'mihawk-cpld'
73 sequencer_class = 'MihawkCPLD'
74else
75 # power sequencer is incorrect
76 error('power sequencer is incorrect')
77endif
78
Brad Bishop39b370a2019-09-02 02:37:32 -040079conf = configuration_data()
80conf.set_quoted(
81 'INPUT_HISTORY_BUSNAME_ROOT', get_option('input-history-busname-root'))
82conf.set_quoted(
83 'INPUT_HISTORY_SENSOR_ROOT', get_option('input-history-sensor-root'))
George Liu690e7802019-08-23 11:04:01 +080084conf.set_quoted(
85 'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json')
Andy YF Wang40247cc2019-09-06 18:30:56 +080086conf.set(
87 'SEQUENCER', sequencer_class)
Brad Bishop39b370a2019-09-02 02:37:32 -040088conf.set10(
Andy YF Wang40247cc2019-09-06 18:30:56 +080089 'DEVICE_ACCESS', get_option('device-access'))
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050090conf.set10('IBM_VPD', get_option('ibm-vpd'))
Brad Bishop39b370a2019-09-02 02:37:32 -040091
92configure_file(output: 'config.h', configuration: conf)
93
94# Ensure the generated header here winds up in the correct path in the build
95# tree such that it actually get used and doesn't get found in the sysroot
96# somewhere. Meson doesn't allow path elements (rightfully so) when specifying
97# the output filename of a target definition so the target must be defined in
98# the directory where the artifacts need to be placed. Do that now, because
99# the generated source (cpp) is needed to define the library target.
100subdir('org/open_power/Witherspoon/Fault')
101
102libpower = static_library(
103 'power',
104 error_cpp,
105 error_hpp,
106 'gpio.cpp',
107 'pmbus.cpp',
108 'utility.cpp',
109 dependencies: [
110 cppfs,
Brad Bishop39b370a2019-09-02 02:37:32 -0400111 phosphor_dbus_interfaces,
112 phosphor_logging,
113 sdbusplus,
114 sdeventplus,
115 ],
116)
117
Lei YU7c2fbbb2019-11-06 14:56:02 +0800118libpower_inc = include_directories('.')
119
Shawn McCarney4c94bc72019-12-13 17:49:31 -0600120# Build the tools/i2c sub-directory first. Other sub-directories depend on
121# Meson variables defined there.
122subdir('tools/i2c')
123
Brad Bishop1c40f1c2020-04-08 19:32:43 -0400124if get_option('regulators')
125 subdir('phosphor-regulators')
126endif
127if get_option('sequencer-monitor')
128 subdir('power-sequencer')
129endif
130if get_option('supply-monitor')
131 subdir('power-supply')
132endif
133if get_option('supply-monitor-ng')
134 subdir('phosphor-power-supply')
135endif
136if get_option('utils')
137 subdir('tools/power-utils')
138endif
Shawn McCarneyff481432020-02-13 10:38:44 -0600139if get_option('tests').enabled()
140 subdir('test')
141endif
Brad Bishop1c40f1c2020-04-08 19:32:43 -0400142if get_option('cold-redundancy')
143 subdir('cold-redundancy')
144endif