xref: /openbmc/openpower-vpd-parser/meson.build (revision e12b181b3a038ef789ed480d8acc506eaa396835)
1project(
2     'openpower-vpd-parser',
3     'c',
4     'cpp',
5     default_options: [
6     'cpp_std=c++17'
7     ],
8     version: '1.0'
9)
10
11build_tests = get_option('tests')
12
13sdbusplus = dependency('sdbusplus')
14phosphor_logging = dependency('phosphor-logging')
15phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
16
17compiler = meson.get_compiler('cpp')
18python = find_program('python3', required:true)
19
20compiler.has_header('CLI/CLI.hpp')
21compiler.has_header('nlohmann/json.hpp')
22add_global_arguments('-Wno-psabi', language : ['c', 'cpp'])
23configure_file(output: 'config.h',
24                       configuration :{
25                       'INVENTORY_JSON': '"'+get_option('INVENTORY_JSON')+'"',
26                       'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
27                       'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
28                       'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
29                       'BUSNAME' : '"' + get_option('BUSNAME') + '"',
30                       'OBJPATH' : '"' + get_option('OBJPATH') + '"',
31                       'IFACE' : '"' + get_option('IFACE') + '"',
32                       'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
33                       'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
34                       'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
35                       'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
36		       'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
37		       'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
38		       'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"'
39                       }
40  )
41
42if get_option('ibm-parser').enabled()
43        ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp',
44                                'vpd-parser/ipz_parser.cpp',
45                                'impl.cpp',
46                                'utils.cpp',
47                                'vpd-parser/keyword_vpd_parser.cpp',
48                                'vpdecc/vpdecc.c',
49                                'vpdecc/vpdecc_support.c',
50                                'vpd-parser/memory_vpd_parser.cpp',
51                                'vpd-parser/parser_factory.cpp'
52                               ]
53
54        ibm_vpd_exe = executable(
55                                'ibm-read-vpd',
56                                ibm_read_vpd_SOURCES,
57                                dependencies: [
58                                        sdbusplus,
59                                        phosphor_logging,
60                                ],
61                                include_directories : 'vpd-parser/',
62                                install: true,
63                                cpp_args : '-DIPZ_PARSER'
64                            )
65
66        vpd_tool_SOURCES = ['vpd_tool.cpp',
67                            'vpd_tool_impl.cpp'
68                           ]
69
70        vpd_tool_exe = executable(
71                                 'vpd-tool',
72                                 vpd_tool_SOURCES,
73                                 dependencies: [
74                                   sdbusplus
75                                   ],
76                                 install: true
77                                 )
78if get_option('vpd-manager').enabled()
79    subdir('vpd-manager')
80endif
81
82else
83        FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
84        PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
85
86        src_dir = meson.source_root()
87        FRU_GEN_SCRIPT = src_dir + '/writefru.py'
88        FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
89
90        PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
91        PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
92
93        writefru_hpp = custom_target('writefru.hpp',
94                                     command:[python,
95                                              FRU_GEN_SCRIPT,
96                                              '-i',
97                                              get_option('FRU_YAML')
98                                     ],
99                                     depend_files :['writefru.mako.hpp',
100                                                    'writefru.py',
101                                                    get_option('FRU_YAML')
102                                     ],
103                                     output:'writefru.hpp'
104        )
105
106        extra_properties_gen_hpp = custom_target(
107                                        'extra-properties-gen.hpp',
108                                        command:[
109                                                python,
110                                                PROP_GEN_SCRIPT,
111                                                '-e',
112                                                get_option('PROP_YAML')
113                                        ],
114                                        depend_files : ['extra-properties.mako.hpp',
115                                                        'extra-properties.py',
116                                                        get_option('PROP_YAML')
117                                        ],
118                                        output:'extra-properties-gen.hpp'
119        )
120
121        openpower_read_vpd_SOURCES = ['app.cpp',
122                                      'args.cpp',
123                                      'impl.cpp',
124                                      'vpd-parser/ipz_parser.cpp',
125                                      'write.cpp',
126                                      'utils.cpp',
127                                      writefru_hpp,
128                                      extra_properties_gen_hpp
129        ]
130
131        openpower_read_vpd_exe= executable(
132                'openpower-read-vpd',
133                openpower_read_vpd_SOURCES,
134                dependencies: [
135                        sdbusplus,
136                        phosphor_logging,
137                ],
138                include_directories : 'vpd-parser/',
139                install: true,
140        )
141endif
142subdir('test')
143