blob: a102a3f2016700dff0933d1cae05961dfce58842 [file] [log] [blame]
SunnySrivastava19847ef54422019-12-03 02:47:37 -06001project(
2 'openpower-vpd-parser',
3 'c',
4 'cpp',
5 default_options: [
Priyanga Ramasamy9d149342020-07-16 23:41:26 +05306 'warning_level=3',
7 'werror=true',
Patrick Williams8e532c12021-10-06 15:34:56 -05008 'cpp_std=c++20',
PriyangaRamasamyf272efc2021-03-03 23:24:31 -06009 'buildtype=debugoptimized'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060010 ],
Patrick Williams8e532c12021-10-06 15:34:56 -050011 version: '1.0',
12 meson_version: '>=0.57.0',
SunnySrivastava19847ef54422019-12-03 02:47:37 -060013)
14
Andrew Jeffery3aec4782021-06-15 11:45:23 +093015add_global_arguments('-Wno-psabi', language : ['c', 'cpp'])
16
Andrew Jefferyf3953762021-06-15 11:10:10 +093017# Disable FORTIFY_SOURCE when compiling with no optimization
18if(get_option('optimization') == '0')
19 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
20 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
21endif
22
23# Setup googletest before we import any projects that also depend on it to make
24# sure we have control over its configuration
25build_tests = get_option('tests')
26if not build_tests.disabled()
27 gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
28 gmock_dep = dependency('gmock', disabler: true, required: false)
29 if not gtest_dep.found() or not gmock_dep.found()
30 cmake = import('cmake')
31 gtest_opts = cmake.subproject_options()
32 gtest_opts.set_override_option('warning_level', '1')
33 gtest_opts.set_override_option('werror', 'false')
34 gtest_proj = cmake.subproject('googletest',
35 options: gtest_opts,
36 required: false)
37 if gtest_proj.found()
38 gtest_dep = declare_dependency(
39 dependencies: [
40 dependency('threads'),
41 gtest_proj.dependency('gtest'),
42 gtest_proj.dependency('gtest_main'),
43 ]
44 )
45 gmock_dep = gtest_proj.dependency('gmock')
46 else
47 assert(not get_option('tests').enabled(),
48 'Googletest is required if tests are enabled')
49 endif
50 endif
51endif
52
Andrew Jeffery60b5bd22021-06-15 10:41:28 +093053phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces',
54 default_options: [ 'data_com_ibm=true', 'data_org_open_power=true' ],
55 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'])
56
57phosphor_logging = dependency('phosphor-logging',
58 default_options: [ 'openpower-pel-extension=enabled' ],
59 fallback: ['phosphor-logging', 'phosphor_logging_dep'])
60
61sdbusplus = dependency('sdbusplus', fallback: [ 'sdbusplus', 'sdbusplus_dep' ])
SunnySrivastava19847ef54422019-12-03 02:47:37 -060062
Andrew Jefferyf3953762021-06-15 11:10:10 +093063if not build_tests.disabled()
64 subdir('test')
65endif
66
SunnySrivastava19847ef54422019-12-03 02:47:37 -060067compiler = meson.get_compiler('cpp')
68python = find_program('python3', required:true)
69
SunnySrivastava19847ef54422019-12-03 02:47:37 -060070compiler.has_header('CLI/CLI.hpp')
71compiler.has_header('nlohmann/json.hpp')
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -060072
SunnySrivastava19847ef54422019-12-03 02:47:37 -060073configure_file(output: 'config.h',
74 configuration :{
Santosh Puranik0246a4d2020-11-04 16:57:39 +053075 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"',
76 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"',
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053077 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
SunnySrivastava198443306542020-04-01 02:50:20 -050078 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
79 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
SunnySrivastava1984a7392592020-03-09 10:19:33 -050080 'BUSNAME' : '"' + get_option('BUSNAME') + '"',
81 'OBJPATH' : '"' + get_option('OBJPATH') + '"',
82 'IFACE' : '"' + get_option('IFACE') + '"',
SunnySrivastava198443306542020-04-01 02:50:20 -050083 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
84 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
85 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
PriyangaRamasamy83a1d5d2020-04-30 19:15:43 +053086 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
Santosh Puranik0246a4d2020-11-04 16:57:39 +053087 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
88 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
Santosh Puranik4641bff2020-11-30 20:26:44 +053089 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053090 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"',
Alpana Kumarif05effd2021-04-07 07:32:53 -050091 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"',
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -060092 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"',
PriyangaRamasamy8cc5b152021-06-03 13:05:17 -050093 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"',
94 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060095 }
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053096 )
SunnySrivastava198443306542020-04-01 02:50:20 -050097
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -050098common_SOURCES =['common_utility.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053099'vpd-parser/parser_factory.cpp',
100 'vpd-parser/memory_vpd_parser.cpp',
101 'vpd-parser/keyword_vpd_parser.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500102 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530103 'vpdecc/vpdecc.c', 'vpdecc/vpdecc_support.c'
104]
105
SunnySrivastava198443306542020-04-01 02:50:20 -0500106if get_option('ibm-parser').enabled()
Alpana Kumari2f793042020-08-18 05:51:03 -0500107 libgpiodcxx = dependency('libgpiodcxx')
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530108 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp'
109 ]+common_SOURCES
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600110
111 ibm_vpd_exe = executable(
112 'ibm-read-vpd',
113 ibm_read_vpd_SOURCES,
114 dependencies: [
115 sdbusplus,
116 phosphor_logging,
Alpana Kumari2f793042020-08-18 05:51:03 -0500117 libgpiodcxx,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600118 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500119 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600120 install: true,
121 cpp_args : '-DIPZ_PARSER'
122 )
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530123
124 vpd_tool_SOURCES = ['vpd_tool.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530125 'vpd_tool_impl.cpp',
126 'vpd-manager/editor_impl.cpp',
127 ]+common_SOURCES
128
129 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager')
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530130
131 vpd_tool_exe = executable(
132 'vpd-tool',
133 vpd_tool_SOURCES,
134 dependencies: [
135 sdbusplus
136 ],
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530137 install: true,
138 include_directories : vpd_tool_INCLUDE
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530139 )
SunnySrivastava1984a7392592020-03-09 10:19:33 -0500140if get_option('vpd-manager').enabled()
141 subdir('vpd-manager')
142endif
143
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600144else
145 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
146 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
147
148 src_dir = meson.source_root()
149 FRU_GEN_SCRIPT = src_dir + '/writefru.py'
150 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
151
152 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
153 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
154
155 writefru_hpp = custom_target('writefru.hpp',
156 command:[python,
157 FRU_GEN_SCRIPT,
158 '-i',
159 get_option('FRU_YAML')
160 ],
161 depend_files :['writefru.mako.hpp',
162 'writefru.py',
163 get_option('FRU_YAML')
164 ],
165 output:'writefru.hpp'
166 )
167
168 extra_properties_gen_hpp = custom_target(
169 'extra-properties-gen.hpp',
170 command:[
171 python,
172 PROP_GEN_SCRIPT,
173 '-e',
174 get_option('PROP_YAML')
175 ],
176 depend_files : ['extra-properties.mako.hpp',
177 'extra-properties.py',
178 get_option('PROP_YAML')
179 ],
180 output:'extra-properties-gen.hpp'
181 )
182
183 openpower_read_vpd_SOURCES = ['app.cpp',
184 'args.cpp',
185 'impl.cpp',
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500186 'vpd-parser/ipz_parser.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600187 'write.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500188 'common_utility.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600189 writefru_hpp,
190 extra_properties_gen_hpp
191 ]
192
193 openpower_read_vpd_exe= executable(
194 'openpower-read-vpd',
195 openpower_read_vpd_SOURCES,
196 dependencies: [
197 sdbusplus,
198 phosphor_logging,
199 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500200 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600201 install: true,
202 )
203endif