Add meson support
Add meson as an alternative build system.
Change-Id: If58674e6fd19d0165ecc73ae677c2a5ad6b30075
Signed-off-by: Kun Yi <kunyi731@gmail.com>
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..8bda862
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,88 @@
+project(
+ 'phosphor-host-postd',
+ 'cpp',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++17'
+ ],
+ license: 'Apache-2.0',
+ version: '1.0',
+)
+
+build_tests = get_option('tests')
+
+postd_headers = include_directories('.')
+
+phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
+sdbusplus = dependency('sdbusplus')
+sdeventplus = dependency('sdeventplus')
+systemd = dependency('systemd')
+
+conf_data = configuration_data()
+conf_data.set('bindir', get_option('prefix') / get_option('bindir'))
+conf_data.set('SNOOP_DEVICE', get_option('snoop-device'))
+conf_data.set('POST_CODE_BYTES', get_option('post-code-bytes'))
+conf_data.set('SYSTEMD_TARGET', get_option('systemd-target'))
+
+configure_file(
+ input: 'lpcsnoop.service.in',
+ output: 'lpcsnoop.service',
+ configuration: conf_data,
+ install: true,
+ install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'))
+
+executable(
+ 'snoopd',
+ 'main.cpp',
+ dependencies: [
+ sdbusplus,
+ sdeventplus,
+ phosphor_dbus_interfaces,
+ ],
+ install: true,
+)
+
+executable(
+ 'snooper',
+ 'example.cpp',
+ dependencies: [
+ sdbusplus,
+ sdeventplus,
+ phosphor_dbus_interfaces,
+ ],
+ install: true,
+)
+
+if get_option('7seg').enabled()
+ udevdir = dependency('udev', required : false).get_pkgconfig_variable('udevdir')
+ assert(udevdir != '', 'Cannot find udevdir')
+ install_data(['80-7seg.rules'], install_dir : udevdir)
+
+ install_data(
+ ['postcode-7seg@.service'],
+ install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir')
+ )
+
+ executable(
+ 'postcode_7seg',
+ '7seg.cpp',
+ dependencies: [
+ sdbusplus,
+ phosphor_dbus_interfaces,
+ ],
+ link_args : [
+ '-lstdc++fs',
+ ],
+ install: true,
+ )
+endif
+
+install_headers(
+ 'lpcsnoop/snoop.hpp',
+ 'lpcsnoop/snoop_listen.hpp',
+ subdir: 'lpcsnoop')
+
+if not build_tests.disabled()
+ subdir('test')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..763c73e
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,22 @@
+option(
+ 'snoop-device',
+ description: 'Linux module name of the snoop device.',
+ type: 'string',
+)
+option(
+ 'post-code-bytes',
+ description: 'Post code byte size.',
+ type: 'integer',
+ value: 1,
+)
+option(
+ 'systemd-target',
+ description: 'Target for starting this service.',
+ type: 'string'
+)
+option(
+ '7seg', type: 'feature', description: 'Enable building 7seg POST daemon.',
+)
+option(
+ 'tests', type: 'feature', description: 'Build tests.',
+)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..13809f1
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,20 @@
+gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+gmock = dependency('gmock', disabler: true, required: build_tests)
+phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
+sdbusplus = dependency('sdbusplus')
+
+tests = [
+ 'post_reporter_test',
+]
+
+foreach t : tests
+ test(t, executable(t.underscorify(), t + '.cpp',
+ include_directories: postd_headers,
+ implicit_include_directories: false,
+ dependencies: [
+ gtest,
+ gmock,
+ phosphor_dbus_interfaces,
+ sdbusplus,
+ ]))
+endforeach