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
45if(get_option('warm-reboot').enabled())
46    add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
47endif
48
49sdbusplus = dependency('sdbusplus')
50sdeventplus = dependency('sdeventplus')
51phosphorlogging = dependency('phosphor-logging')
52phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
53
54cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
55
56executable('phosphor-host-state-manager',
57            'host_state_manager.cpp',
58            'host_state_manager_main.cpp',
59            'settings.cpp',
60            dependencies: [
61            sdbusplus, sdeventplus, phosphorlogging,
62            phosphordbusinterfaces, cppfs
63            ],
64    implicit_include_directories: true,
65    install: true
66)
67
68executable('phosphor-chassis-state-manager',
69            'chassis_state_manager.cpp',
70            'chassis_state_manager_main.cpp',
71            dependencies: [
72            sdbusplus, sdeventplus, phosphorlogging,
73            phosphordbusinterfaces, cppfs
74            ],
75    implicit_include_directories: true,
76    install: true
77)
78
79executable('phosphor-bmc-state-manager',
80            'bmc_state_manager.cpp',
81            'bmc_state_manager_main.cpp',
82            dependencies: [
83            sdbusplus, sdeventplus, phosphorlogging,
84            phosphordbusinterfaces, cppfs
85            ],
86    implicit_include_directories: true,
87    install: true
88)
89
90executable('phosphor-discover-system-state',
91            'discover_system_state.cpp',
92            'settings.cpp',
93            dependencies: [
94            sdbusplus, phosphorlogging
95            ],
96    implicit_include_directories: true,
97    install: true
98)
99
100executable('phosphor-host-check',
101            'host_check_main.cpp',
102            dependencies: [
103            sdbusplus, phosphorlogging
104            ],
105    implicit_include_directories: true,
106    install: true
107)
108
109executable('phosphor-systemd-target-monitor',
110            'systemd_target_monitor.cpp',
111            'systemd_target_parser.cpp',
112            'systemd_target_signal.cpp',
113            dependencies: [
114            sdbusplus, sdeventplus, phosphorlogging
115            ],
116    implicit_include_directories: true,
117    install: true
118)
119
120executable('phosphor-scheduled-host-transition',
121            'scheduled_host_transition_main.cpp',
122            'scheduled_host_transition.cpp',
123            'utils.cpp',
124            dependencies: [
125            sdbusplus, sdeventplus, phosphorlogging
126            ],
127    implicit_include_directories: true,
128    install: true
129)
130
131install_data('obmcutil',
132        install_mode: 'rwxr-xr-x',
133        install_dir: get_option('bindir')
134)
135
136systemd = dependency('systemd')
137systemd_system_unit_dir = systemd.get_pkgconfig_variable(
138    'systemdsystemunitdir',
139    define_variable: ['prefix', get_option('prefix')])
140subdir('service_files')
141subdir('target_files')
142
143datadir = join_paths(
144    get_option('sysconfdir'),
145    'phosphor-systemd-target-monitor'
146)
147subdir('data')
148
149build_tests = get_option('tests')
150
151# If test coverage of source files within the root directory are wanted,
152# need to define and build the tests from here
153if not build_tests.disabled()
154gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
155gmock = dependency('gmock', disabler: true, required: build_tests)
156  test(
157      'test_systemd_parser',
158      executable('test_systemd_parser',
159          './test/systemd_parser.cpp',
160          'systemd_target_parser.cpp',
161          dependencies: [
162              gtest,
163          ],
164          implicit_include_directories: true,
165          include_directories: '../'
166      )
167  )
168
169  test(
170      'test_systemd_signal',
171      executable('test_systemd_signal',
172          './test/systemd_signal.cpp',
173          'systemd_target_signal.cpp',
174          dependencies: [
175              gtest, sdbusplus, sdeventplus, phosphorlogging,
176          ],
177          implicit_include_directories: true,
178          include_directories: '../'
179      )
180  )
181
182  test(
183      'test_scheduled_host_transition',
184      executable('test_scheduled_host_transition',
185          './test/test_scheduled_host_transition.cpp',
186          'scheduled_host_transition.cpp',
187          'utils.cpp',
188          dependencies: [
189              gtest, gmock, sdbusplus, sdeventplus, phosphorlogging,
190          ],
191          implicit_include_directories: true,
192          include_directories: '../'
193      )
194  )
195endif
196