| Brandon Kim | dab96f1 | 2021-02-18 11:21:37 -0800 | [diff] [blame] | 1 | # Copyright 2021 Google LLC | 
|  | 2 | # | 
|  | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | # you may not use this file except in compliance with the License. | 
|  | 5 | # You may obtain a copy of the License at | 
|  | 6 | # | 
|  | 7 | #      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | # | 
|  | 9 | # Unless required by applicable law or agreed to in writing, software | 
|  | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | # See the License for the specific language governing permissions and | 
|  | 13 | # limitations under the License. | 
|  | 14 |  | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 15 | project( | 
|  | 16 | 'metrics-ipmi-blobs', | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 17 | ['cpp', 'c'], | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 18 | version: '0.1', | 
|  | 19 | default_options: [ | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 20 | 'warning_level=3', | 
|  | 21 | 'werror=true', | 
| Patrick Williams | 1dfe24e | 2023-07-12 11:16:02 -0500 | [diff] [blame] | 22 | 'cpp_std=c++23', | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 23 | 'c_std=c18', | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 24 | 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'), | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 25 | ], | 
|  | 26 | ) | 
|  | 27 |  | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 28 | nanopb = find_program('nanopb_generator.py', native: true, required: false) | 
|  | 29 | if not nanopb.found() | 
|  | 30 | nanopb_opts = import('cmake').subproject_options() | 
|  | 31 | nanopb_opts.add_cmake_defines({'BUILD_SHARED_LIBS': 'ON'}) | 
|  | 32 | nanopb_proj = import('cmake').subproject('nanopb', options: nanopb_opts) | 
|  | 33 | nanopb = find_program(meson.global_source_root() + '/subprojects/nanopb/generator/nanopb_generator.py', native: true) | 
|  | 34 | nanopb_dep = nanopb_proj.dependency('protobuf_nanopb') | 
|  | 35 | else | 
|  | 36 | nanopb_dep = meson.get_compiler('cpp').find_library('protobuf-nanopb') | 
|  | 37 | endif | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 38 |  | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 39 | nanopb_kwargs = { | 
|  | 40 | 'output': [ | 
|  | 41 | '@BASENAME@.pb.n.h', | 
|  | 42 | '@BASENAME@.pb.n.c', | 
|  | 43 | ], | 
|  | 44 | 'command': [ | 
|  | 45 | nanopb, | 
|  | 46 | '-q', | 
|  | 47 | '-s', 'packed_struct:0', | 
|  | 48 | '-H.n.h', | 
|  | 49 | '-S.n.c', | 
|  | 50 | '-I' + import('fs').relative_to(meson.current_source_dir(), meson.global_build_root()), | 
|  | 51 | '-D' + import('fs').relative_to(meson.current_build_dir(), meson.global_build_root()), | 
|  | 52 | '@INPUT@', | 
|  | 53 | ], | 
|  | 54 | } | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 55 |  | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 56 | tgt = custom_target( | 
|  | 57 | 'metricblob.pb.n.hc', | 
|  | 58 | input: 'metricblob.proto', | 
|  | 59 | kwargs: nanopb_kwargs) | 
|  | 60 | metrics_nanopb_hdr = tgt[0] | 
|  | 61 | metrics_nanopb_src = tgt[1] | 
|  | 62 |  | 
|  | 63 | metrics_nanopb_pre = declare_dependency( | 
|  | 64 | include_directories: include_directories('.'), | 
|  | 65 | sources: metrics_nanopb_hdr, | 
|  | 66 | dependencies: [ | 
|  | 67 | nanopb_dep, | 
|  | 68 | ]) | 
|  | 69 |  | 
|  | 70 | metrics_nanopb_lib = static_library( | 
|  | 71 | 'metrics_nanopb', | 
|  | 72 | metrics_nanopb_src, | 
|  | 73 | implicit_include_directories: false, | 
|  | 74 | dependencies: metrics_nanopb_pre) | 
|  | 75 |  | 
|  | 76 | metrics_nanopb_dep = declare_dependency( | 
|  | 77 | dependencies: metrics_nanopb_pre, | 
|  | 78 | link_with: metrics_nanopb_lib) | 
|  | 79 |  | 
|  | 80 | pre = declare_dependency( | 
|  | 81 | include_directories: include_directories('.'), | 
|  | 82 | dependencies: [ | 
|  | 83 | metrics_nanopb_dep, | 
|  | 84 | dependency('phosphor-logging'), | 
|  | 85 | dependency('phosphor-ipmi-blobs'), | 
|  | 86 | dependency('sdbusplus'), | 
|  | 87 | ]) | 
| William A. Kennington III | b056df6 | 2021-03-23 21:19:18 -0700 | [diff] [blame] | 88 |  | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 89 | lib = static_library( | 
|  | 90 | 'metricsblob', | 
|  | 91 | 'util.cpp', | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 92 | 'handler.cpp', | 
|  | 93 | 'metric.cpp', | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 94 | implicit_include_directories: false, | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 95 | dependencies: pre) | 
| Sui Chen | 03eba28 | 2021-02-11 11:35:56 -0800 | [diff] [blame] | 96 |  | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 97 | dep = declare_dependency( | 
| William A. Kennington III | 7f49370 | 2024-02-08 01:09:11 -0800 | [diff] [blame] | 98 | dependencies: pre, | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 99 | link_with: lib) | 
|  | 100 |  | 
|  | 101 | shared_module( | 
|  | 102 | 'metricsblob', | 
|  | 103 | 'main.cpp', | 
|  | 104 | dependencies: dep, | 
|  | 105 | implicit_include_directories: false, | 
|  | 106 | install: true, | 
| William A. Kennington III | 548f3ad | 2021-06-17 20:07:47 -0700 | [diff] [blame] | 107 | install_dir: get_option('libdir') / 'blob-ipmid') | 
| William A. Kennington III | 3f43b7e | 2021-02-16 16:54:40 -0800 | [diff] [blame] | 108 |  | 
|  | 109 | if not get_option('tests').disabled() | 
|  | 110 | subdir('test') | 
|  | 111 | endif |