blob: 97518b19eca11ec93b4e50f9f1f6a0c50f89d270 [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',
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -06008 'cpp_std=c++17',
PriyangaRamasamyf272efc2021-03-03 23:24:31 -06009 'buildtype=debugoptimized'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060010 ],
11 version: '1.0'
12)
13
Andrew Jeffery3aec4782021-06-15 11:45:23 +093014add_global_arguments('-Wno-psabi', language : ['c', 'cpp'])
15
Andrew Jefferyf3953762021-06-15 11:10:10 +093016# Disable FORTIFY_SOURCE when compiling with no optimization
17if(get_option('optimization') == '0')
18 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
19 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
20endif
21
22# Setup googletest before we import any projects that also depend on it to make
23# sure we have control over its configuration
24build_tests = get_option('tests')
25if not build_tests.disabled()
26 gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
27 gmock_dep = dependency('gmock', disabler: true, required: false)
28 if not gtest_dep.found() or not gmock_dep.found()
29 cmake = import('cmake')
30 gtest_opts = cmake.subproject_options()
31 gtest_opts.set_override_option('warning_level', '1')
32 gtest_opts.set_override_option('werror', 'false')
33 gtest_proj = cmake.subproject('googletest',
34 options: gtest_opts,
35 required: false)
36 if gtest_proj.found()
37 gtest_dep = declare_dependency(
38 dependencies: [
39 dependency('threads'),
40 gtest_proj.dependency('gtest'),
41 gtest_proj.dependency('gtest_main'),
42 ]
43 )
44 gmock_dep = gtest_proj.dependency('gmock')
45 else
46 assert(not get_option('tests').enabled(),
47 'Googletest is required if tests are enabled')
48 endif
49 endif
50endif
51
Andrew Jeffery60b5bd22021-06-15 10:41:28 +093052phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces',
53 default_options: [ 'data_com_ibm=true', 'data_org_open_power=true' ],
54 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'])
55
56phosphor_logging = dependency('phosphor-logging',
57 default_options: [ 'openpower-pel-extension=enabled' ],
58 fallback: ['phosphor-logging', 'phosphor_logging_dep'])
59
60sdbusplus = dependency('sdbusplus', fallback: [ 'sdbusplus', 'sdbusplus_dep' ])
SunnySrivastava19847ef54422019-12-03 02:47:37 -060061
Andrew Jefferyf3953762021-06-15 11:10:10 +093062if not build_tests.disabled()
63 subdir('test')
64endif
65
SunnySrivastava19847ef54422019-12-03 02:47:37 -060066compiler = meson.get_compiler('cpp')
67python = find_program('python3', required:true)
68
SunnySrivastava19847ef54422019-12-03 02:47:37 -060069compiler.has_header('CLI/CLI.hpp')
70compiler.has_header('nlohmann/json.hpp')
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -060071
SunnySrivastava19847ef54422019-12-03 02:47:37 -060072configure_file(output: 'config.h',
73 configuration :{
Santosh Puranik0246a4d2020-11-04 16:57:39 +053074 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"',
75 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"',
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053076 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
SunnySrivastava198443306542020-04-01 02:50:20 -050077 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
78 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
SunnySrivastava1984a7392592020-03-09 10:19:33 -050079 'BUSNAME' : '"' + get_option('BUSNAME') + '"',
80 'OBJPATH' : '"' + get_option('OBJPATH') + '"',
81 'IFACE' : '"' + get_option('IFACE') + '"',
SunnySrivastava198443306542020-04-01 02:50:20 -050082 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
83 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
84 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
PriyangaRamasamy83a1d5d2020-04-30 19:15:43 +053085 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
Santosh Puranik0246a4d2020-11-04 16:57:39 +053086 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
87 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
Santosh Puranik4641bff2020-11-30 20:26:44 +053088 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053089 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"',
Alpana Kumarif05effd2021-04-07 07:32:53 -050090 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"',
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -060091 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"',
PriyangaRamasamy8cc5b152021-06-03 13:05:17 -050092 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"',
93 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060094 }
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053095 )
SunnySrivastava198443306542020-04-01 02:50:20 -050096
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -050097common_SOURCES =['common_utility.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053098'vpd-parser/parser_factory.cpp',
99 'vpd-parser/memory_vpd_parser.cpp',
100 'vpd-parser/keyword_vpd_parser.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500101 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530102 'vpdecc/vpdecc.c', 'vpdecc/vpdecc_support.c'
103]
104
SunnySrivastava198443306542020-04-01 02:50:20 -0500105if get_option('ibm-parser').enabled()
Alpana Kumari2f793042020-08-18 05:51:03 -0500106 libgpiodcxx = dependency('libgpiodcxx')
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530107 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp'
108 ]+common_SOURCES
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600109
110 ibm_vpd_exe = executable(
111 'ibm-read-vpd',
112 ibm_read_vpd_SOURCES,
113 dependencies: [
114 sdbusplus,
115 phosphor_logging,
Alpana Kumari2f793042020-08-18 05:51:03 -0500116 libgpiodcxx,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600117 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500118 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600119 install: true,
120 cpp_args : '-DIPZ_PARSER'
121 )
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530122
123 vpd_tool_SOURCES = ['vpd_tool.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530124 'vpd_tool_impl.cpp',
125 'vpd-manager/editor_impl.cpp',
126 ]+common_SOURCES
127
128 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager')
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530129
130 vpd_tool_exe = executable(
131 'vpd-tool',
132 vpd_tool_SOURCES,
133 dependencies: [
134 sdbusplus
135 ],
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530136 install: true,
137 include_directories : vpd_tool_INCLUDE
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530138 )
SunnySrivastava1984a7392592020-03-09 10:19:33 -0500139if get_option('vpd-manager').enabled()
140 subdir('vpd-manager')
141endif
142
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600143else
144 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
145 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
146
147 src_dir = meson.source_root()
148 FRU_GEN_SCRIPT = src_dir + '/writefru.py'
149 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
150
151 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
152 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
153
154 writefru_hpp = custom_target('writefru.hpp',
155 command:[python,
156 FRU_GEN_SCRIPT,
157 '-i',
158 get_option('FRU_YAML')
159 ],
160 depend_files :['writefru.mako.hpp',
161 'writefru.py',
162 get_option('FRU_YAML')
163 ],
164 output:'writefru.hpp'
165 )
166
167 extra_properties_gen_hpp = custom_target(
168 'extra-properties-gen.hpp',
169 command:[
170 python,
171 PROP_GEN_SCRIPT,
172 '-e',
173 get_option('PROP_YAML')
174 ],
175 depend_files : ['extra-properties.mako.hpp',
176 'extra-properties.py',
177 get_option('PROP_YAML')
178 ],
179 output:'extra-properties-gen.hpp'
180 )
181
182 openpower_read_vpd_SOURCES = ['app.cpp',
183 'args.cpp',
184 'impl.cpp',
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500185 'vpd-parser/ipz_parser.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600186 'write.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500187 'common_utility.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600188 writefru_hpp,
189 extra_properties_gen_hpp
190 ]
191
192 openpower_read_vpd_exe= executable(
193 'openpower-read-vpd',
194 openpower_read_vpd_SOURCES,
195 dependencies: [
196 sdbusplus,
197 phosphor_logging,
198 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500199 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600200 install: true,
201 )
202endif