1project(
2    'phosphor-state-manager',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++17'
8    ],
9    license: 'Apache-2.0',
10    version: '0.1',
11)
12
13conf = configuration_data()
14conf.set_quoted(
15    'HOST_BUSNAME', get_option('host-busname'))
16conf.set_quoted(
17    'HOST_OBJPATH', get_option('host-objpath'))
18conf.set_quoted(
19    'CHASSIS_BUSNAME', get_option('chassis-busname'))
20conf.set_quoted(
21    'CHASSIS_OBJPATH', get_option('chassis-objpath'))
22conf.set_quoted(
23    'BMC_BUSNAME', get_option('bmc-busname'))
24conf.set_quoted(
25    'BMC_OBJPATH', get_option('bmc-objpath'))
26conf.set_quoted(
27    'HOST_RUNNING_FILE', get_option('host-running-file'))
28conf.set_quoted(
29    'HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path'))
30conf.set_quoted(
31    'POH_COUNTER_PERSIST_PATH', get_option('poh-counter-persist-path'))
32conf.set_quoted(
33    'CHASSIS_STATE_CHANGE_PERSIST_PATH', get_option('chassis-state-change-persist-path'))
34conf.set_quoted(
35    'SCHEDULED_HOST_TRANSITION_PERSIST_PATH', get_option('scheduled-host-transition-persist-path'))
36conf.set_quoted(
37    'SCHEDULED_HOST_TRANSITION_BUSNAME', get_option('scheduled-host-transition-busname'))
38conf.set(
39    'BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed'))
40conf.set(
41    'CLASS_VERSION', get_option('class-version'))
42
43configure_file(output: 'config.h', configuration: conf)
44
45sdbusplus = dependency('sdbusplus')
46sdeventplus = dependency('sdeventplus')
47phosphorlogging = dependency('phosphor-logging')
48phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
49
50cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
51
52executable('phosphor-host-state-manager',
53            'host_state_manager.cpp',
54            'host_state_manager_main.cpp',
55            'settings.cpp',
56            dependencies: [
57            sdbusplus, sdeventplus, phosphorlogging,
58            phosphordbusinterfaces, cppfs
59            ],
60    implicit_include_directories: true,
61    install: true
62)
63
64executable('phosphor-chassis-state-manager',
65            'chassis_state_manager.cpp',
66            'chassis_state_manager_main.cpp',
67            dependencies: [
68            sdbusplus, sdeventplus, phosphorlogging,
69            phosphordbusinterfaces, cppfs
70            ],
71    implicit_include_directories: true,
72    install: true
73)
74
75executable('phosphor-bmc-state-manager',
76            'bmc_state_manager.cpp',
77            'bmc_state_manager_main.cpp',
78            dependencies: [
79            sdbusplus, sdeventplus, phosphorlogging,
80            phosphordbusinterfaces, cppfs
81            ],
82    implicit_include_directories: true,
83    install: true
84)
85
86executable('phosphor-discover-system-state',
87            'discover_system_state.cpp',
88            'settings.cpp',
89            dependencies: [
90            sdbusplus, phosphorlogging
91            ],
92    implicit_include_directories: true,
93    install: true
94)
95
96executable('phosphor-host-check',
97            'host_check_main.cpp',
98            dependencies: [
99            sdbusplus, phosphorlogging
100            ],
101    implicit_include_directories: true,
102    install: true
103)
104
105executable('phosphor-systemd-target-monitor',
106            'systemd_target_monitor.cpp',
107            'systemd_target_parser.cpp',
108            'systemd_target_signal.cpp',
109            dependencies: [
110            sdbusplus, sdeventplus, phosphorlogging
111            ],
112    implicit_include_directories: true,
113    install: true
114)
115
116executable('phosphor-scheduled-host-transition',
117            'scheduled_host_transition_main.cpp',
118            'scheduled_host_transition.cpp',
119            'utils.cpp',
120            dependencies: [
121            sdbusplus, sdeventplus, phosphorlogging
122            ],
123    implicit_include_directories: true,
124    install: true
125)
126
127install_data('obmcutil',
128        install_mode: 'rwxr-xr-x',
129        install_dir: get_option('bindir')
130)
131
132systemd = dependency('systemd')
133systemd_system_unit_dir = systemd.get_pkgconfig_variable(
134    'systemdsystemunitdir',
135    define_variable: ['prefix', get_option('prefix')])
136subdir('service_files')
137subdir('target_files')
138
139datadir = join_paths(
140    get_option('sysconfdir'),
141    'phosphor-systemd-target-monitor'
142)
143subdir('data')
144
145build_tests = get_option('tests')
146
147# If test coverage of source files within the root directory are wanted,
148# need to define and build the tests from here
149if not build_tests.disabled()
150gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
151gmock = dependency('gmock', disabler: true, required: build_tests)
152  test(
153      'test_systemd_parser',
154      executable('test_systemd_parser',
155          './test/systemd_parser.cpp',
156          'systemd_target_parser.cpp',
157          dependencies: [
158              gtest,
159          ],
160          implicit_include_directories: true,
161          include_directories: '../'
162      )
163  )
164
165  test(
166      'test_systemd_signal',
167      executable('test_systemd_signal',
168          './test/systemd_signal.cpp',
169          'systemd_target_signal.cpp',
170          dependencies: [
171              gtest, sdbusplus, sdeventplus, phosphorlogging,
172          ],
173          implicit_include_directories: true,
174          include_directories: '../'
175      )
176  )
177
178  test(
179      'test_scheduled_host_transition',
180      executable('test_scheduled_host_transition',
181          './test/test_scheduled_host_transition.cpp',
182          'scheduled_host_transition.cpp',
183          'utils.cpp',
184          dependencies: [
185              gtest, gmock, sdbusplus, sdeventplus, phosphorlogging,
186          ],
187          implicit_include_directories: true,
188          include_directories: '../'
189      )
190  )
191endif
192