build: enable meson builds
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I2f56761421ee765bc616397c0ad5b88f4e5bc0e9
diff --git a/.gitignore b/.gitignore
index 04eba2e..6da54be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,58 +1,3 @@
-ar-lib
-compile
-config.guess
-config.sub
-depcomp
-install-sh
-ltmain.sh
-missing
-
-extra-properties-gen.cpp
-fru-gen.cpp
-phosphor-read-eeprom
-
-# Python build artifacts
-*.swp
-__pycache__
-*.pyc
-*.pyo
-/tools/build
-/tools/setup.py
-
-# Test suite logs
-*.log
-
-# Code Coverage
-*.gcda
-*.gcno
-*.trs
-*-coverage*
-
-# Compiler
-*.o
-
-# Libtool
-*.la
-*.lo
-*.sw*
-*.so
-*.so.*
-
-# Autotools
-autom4te.cache/
-.deps
-.dirstamp
-.libs
-/aclocal.m4
-/build-aux
-/config.h
-/config.h.in
-/config.h.in~
-/config.log
-/config.status
-/configure
-/m4
-/libtool
-Makefile
-Makefile.in
-/stamp-h1
+build*/
+subprojects/*
+!subprojects/*.wrap
diff --git a/README.md b/README.md
index d34a1ff..99672ce 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,10 @@
# ipmi-fru-parser
-## To Build
+## Building
To build this package, do the following steps:
-1. `./bootstrap.sh`
-2. `./configure ${CONFIGURE_FLAGS}`
-3. `make`
-
-To full clean the repository again run `./bootstrap.sh clean`.
+```sh
+meson setup builddir
+ninja -C builddir
+```
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..77df916
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,99 @@
+project(
+ 'ipmi-fru-parser',
+ 'cpp',
+ version: '1.0',
+ default_options: [
+ 'buildtype=debugoptimized',
+ 'cpp_std=c++23',
+ 'warning_level=3',
+ 'werror=true',
+ ],
+ meson_version: '>=1.1.1',
+)
+
+cxx = meson.get_compiler('cpp')
+
+phosphor_logging_dep = dependency('phosphor-logging')
+sdbusplus_dep = dependency('sdbusplus')
+ipmid_dep = dependency('libipmid')
+
+if cxx.has_header('CLI/CLI.hpp')
+ CLI11_dep = declare_dependency()
+else
+ CLI11_dep = dependency('CLI11')
+endif
+
+python_prog = find_program('python3', native: true)
+
+fru_gen = custom_target(
+ 'fru-gen.cpp'.underscorify(),
+ input: [
+ 'scripts/fru_gen.py',
+ get_option('fru_yaml'),
+ ],
+ output: 'fru-gen.cpp',
+ command: [
+ python_prog, '@INPUT0@',
+ '-i', '@INPUT1@',
+ '-o', meson.current_build_dir(),
+ 'generate-cpp',
+ ],
+)
+
+properties_gen = custom_target(
+ 'extra-properties-gen.cpp'.underscorify(),
+ input: [
+ 'scripts/extra-properties.py',
+ get_option('properties_yaml'),
+ ],
+ output: 'extra-properties-gen.cpp',
+ command: [
+ python_prog, '@INPUT0@',
+ '-e', '@INPUT1@',
+ ],
+)
+
+writefrudata_lib = library(
+ 'writefrudata',
+ fru_gen,
+ properties_gen,
+ 'fru_area.cpp',
+ 'frup.cpp',
+ 'writefrudata.cpp',
+ dependencies: [
+ sdbusplus_dep,
+ phosphor_logging_dep,
+ ipmid_dep,
+ ],
+ version: meson.project_version(),
+ install: true,
+)
+
+writefrudata_dep = declare_dependency(
+ link_with: writefrudata_lib,
+)
+
+strgfnhandler_lib = library(
+ 'strgfnhandler',
+ 'strgfnhandler.cpp',
+ dependencies: [
+ writefrudata_dep,
+ phosphor_logging_dep,
+ ipmid_dep,
+ ],
+ override_options: [ 'b_lundef=false' ],
+ version: meson.project_version(),
+ install: true,
+)
+
+executable(
+ 'phosphor-read-eeprom',
+ 'readeeprom.cpp',
+ dependencies: [
+ CLI11_dep,
+ phosphor_logging_dep,
+ sdbusplus_dep,
+ writefrudata_dep,
+ ],
+ install: true,
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..aaec71f
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,13 @@
+option(
+ 'fru_yaml',
+ type: 'string',
+ value: 'scripts/example.yaml',
+ description: 'Path to FRU YAML',
+)
+
+option(
+ 'properties_yaml',
+ type: 'string',
+ value: 'scripts/extra-properties-example.yaml',
+ description: 'Path to Properties YAML',
+)
diff --git a/subprojects/CLI11.wrap b/subprojects/CLI11.wrap
new file mode 100644
index 0000000..2e5a95b
--- /dev/null
+++ b/subprojects/CLI11.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/CLIUtils/CLI11.git
+revision = HEAD
+
+[provide]
+CLI11 = CLI11_dep
diff --git a/subprojects/phosphor-host-ipmid.wrap b/subprojects/phosphor-host-ipmid.wrap
new file mode 100644
index 0000000..29bb550
--- /dev/null
+++ b/subprojects/phosphor-host-ipmid.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-host-ipmid.git
+revision = HEAD
+
+[provide]
+libipmid = ipmid_dep
+libchannellayer = channellayer_dep
+libuserlayer = userlayer_dep
diff --git a/subprojects/phosphor-logging.wrap b/subprojects/phosphor-logging.wrap
new file mode 100644
index 0000000..71eee8b
--- /dev/null
+++ b/subprojects/phosphor-logging.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-logging.git
+revision = HEAD
+
+[provide]
+phosphor-logging = phosphor_logging_dep
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
new file mode 100644
index 0000000..7b076d0
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdbusplus.git
+revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep