# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

project(
  'metrics-ipmi-blobs',
  ['cpp', 'c'],
  version: '0.1',
  default_options: [
    'warning_level=3',
    'werror=true',
    'cpp_std=c++23',
    'c_std=c18',
    'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
  ],
)

nanopb = find_program('nanopb_generator.py', native: true, required: false)
if not nanopb.found()
  nanopb_opts = import('cmake').subproject_options()
  nanopb_opts.add_cmake_defines({'BUILD_SHARED_LIBS': 'ON'})
  nanopb_proj = import('cmake').subproject('nanopb', options: nanopb_opts)
  nanopb = find_program(meson.global_source_root() + '/subprojects/nanopb/generator/nanopb_generator.py', native: true)
  nanopb_dep = nanopb_proj.dependency('protobuf_nanopb')
else
  nanopb_dep = meson.get_compiler('cpp').find_library('protobuf-nanopb')
endif

nanopb_kwargs = {
  'output': [
    '@BASENAME@.pb.n.h',
    '@BASENAME@.pb.n.c',
  ],
  'command': [
    nanopb,
    '-q',
    '-s', 'packed_struct:0',
    '-H.n.h',
    '-S.n.c',
    '-I' + import('fs').relative_to(meson.current_source_dir(), meson.global_build_root()),
    '-D' + import('fs').relative_to(meson.current_build_dir(), meson.global_build_root()),
    '@INPUT@',
  ],
}

tgt = custom_target(
  'metricblob.pb.n.hc',
  input: 'metricblob.proto',
  kwargs: nanopb_kwargs)
metrics_nanopb_hdr = tgt[0]
metrics_nanopb_src = tgt[1]

metrics_nanopb_pre = declare_dependency(
  include_directories: include_directories('.'),
  sources: metrics_nanopb_hdr,
  dependencies: [
    nanopb_dep,
  ])

metrics_nanopb_lib = static_library(
  'metrics_nanopb',
  metrics_nanopb_src,
  implicit_include_directories: false,
  dependencies: metrics_nanopb_pre)

metrics_nanopb_dep = declare_dependency(
  dependencies: metrics_nanopb_pre,
  link_with: metrics_nanopb_lib)

pre = declare_dependency(
  include_directories: include_directories('.'),
  dependencies: [
    metrics_nanopb_dep,
    dependency('phosphor-logging'),
    dependency('phosphor-ipmi-blobs'),
    dependency('sdbusplus'),
  ])

lib = static_library(
  'metricsblob',
  'util.cpp',
  'handler.cpp',
  'metric.cpp',
  implicit_include_directories: false,
  dependencies: pre)

dep = declare_dependency(
  dependencies: pre,
  link_with: lib)

shared_module(
  'metricsblob',
  'main.cpp',
  dependencies: dep,
  implicit_include_directories: false,
  install: true,
  install_dir: get_option('libdir') / 'blob-ipmid')

if not get_option('tests').disabled()
  subdir('test')
endif
