blob: 7f01052d293e633af956678ff392ed5f0921ad2c [file] [log] [blame]
George Liu4b062012020-10-13 15:26:58 +08001project(
2 'phosphor-ledmanager', 'cpp',
3 version : '1.0.0',
4 meson_version: '>=0.54.1',
5 default_options: [
6 'warning_level=3',
7 'werror=true',
8 'cpp_std=c++17',
9 'buildtype=debugoptimized'
10 ]
11)
12
13conf_data = configuration_data()
14conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.LED.GroupManager')
15conf_data.set_quoted('OBJPATH', '/xyz/openbmc_project/led/groups')
16conf_data.set_quoted('LED_JSON_FILE', '/usr/share/phosphor-led-manager/led-group-config.json')
17conf_data.set_quoted('SAVED_GROUPS_FILE', '/var/lib/phosphor-led-manager/savedGroups')
18conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
19conf_data.set_quoted('CALLOUT_REV_ASSOCIATION', 'fault')
20conf_data.set_quoted('ELOG_ENTRY', 'entry')
21conf_data.set_quoted('LED_FAULT', 'fault')
22
23conf_data.set('CLASS_VERSION', 1)
24conf_data.set('LED_USE_JSON', get_option('use-json').enabled())
25conf_data.set('USE_LAMP_TEST', get_option('use-lamp-test').enabled())
26
27sdbusplus_dep = dependency('sdbusplus', required: false)
28if sdbusplus_dep.found()
29 sdbusplusplus_prog = find_program('sdbus++')
30 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
31else
32 sdbusplus_proj = subproject('sdbusplus', required: true)
33 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
34 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
35 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
36 'sdbuspp_gen_meson_prog'
37 )
38endif
39
40sdeventplus = dependency('sdeventplus')
41phosphorlogging = dependency('phosphor-logging')
42phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
43gtest = dependency('gtest', main: true, disabler: true, required: true)
44gmock = dependency('gmock', disabler: true, required: true)
45prog_python = find_program('python3', required: true)
46realpath_prog = find_program('realpath')
47
48cpp = meson.get_compiler('cpp')
49if cpp.has_header('nlohmann/json.hpp')
50 nlohmann_json = declare_dependency()
51else
52 subproject('nlohmann', required: false)
53 nlohmann_json = declare_dependency(
54 include_directories: [
55 'subprojects/nlohmann/single_include',
56 'subprojects/nlohmann/single_include/nlohmann',
57 ]
58 )
59endif
60
61selected_subdirs = []
62selected_subdirs += 'xyz/openbmc_project'
63
64generated_root = meson.current_build_dir() / 'gen'
65generated_others = []
66generated_sources = []
67
68# Source the generated meson files.
69subdir('gen')
70foreach d : selected_subdirs
71 subdir('gen' / d)
72endforeach
73
74# Parse through the list from sdbus++-gendir and put into sets.
75generated_headers = []
76generated_cpp = []
77generated_others_files = []
78
79foreach g : generated_sources generated_others
80 foreach f : g.to_list()
81 rel_path = run_command(
82 realpath_prog,
83 '--relative-to', generated_root,
84 f.full_path(),
85 ).stdout().strip().split('\n')[-1]
86
87 if rel_path.endswith('.hpp')
88 generated_headers += rel_path
89 elif rel_path.endswith('.cpp')
90 generated_cpp += rel_path
91 else
92 generated_others_files += rel_path
93 endif
94 endforeach
95endforeach
96
97deps = [
98 sdbusplus_dep,
99 sdeventplus,
100 phosphorlogging,
101 phosphordbusinterfaces,
102 nlohmann_json
103]
104
105sources = [
106 'group.cpp',
107 'led-main.cpp',
108 'manager.cpp',
109 'serialize.cpp',
110 'utils.cpp',
111]
112
113if get_option('use-json').disabled()
114 led_gen_hpp = custom_target(
115 'led-gen.hpp',
116 command : [
117 prog_python,
118 meson.source_root() + '/parse_led.py',
119 '-i', meson.source_root(),
120 '-o', meson.current_build_dir(),
121 ],
122 output : 'led-gen.hpp')
123 sources += [led_gen_hpp]
124endif
125
126if get_option('use-lamp-test').enabled()
127 conf_data.set_quoted('LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/lamp_test')
128 conf_data.set_quoted('HOST_LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/host_lamp_test')
129 conf_data.set_quoted('LAMP_TEST_LED_OVERRIDES_JSON', '/usr/share/phosphor-led-manager/lamp-test-led-overrides.json')
130 conf_data.set('LAMP_TEST_TIMEOUT_IN_SECS', 240)
131
132 sources += ['lamptest.cpp']
133endif
134
135configure_file(output: 'config.h',
136 configuration: conf_data
137)
138
139install_data(
140 'scripts/led-set-all-groups-asserted.sh',
141 install_dir: get_option('bindir')
142)
143
144executable(
145 'phosphor-ledmanager',
146 sources,
147 generated_sources,
148 include_directories: include_directories('gen'),
149 dependencies: sdbusplus_dep,
150 implicit_include_directories: true,
151 dependencies: deps,
152 install: true,
153 install_dir: get_option('bindir')
154)
155subdir('fault-monitor')
156
157build_tests = get_option('tests')
158if not build_tests.disabled()
159 subdir('test')
160endif