meson: Add meson build
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I711ec60fe2ab459db1d31c7dedfb9d3ba64061ae
diff --git a/.gitignore b/.gitignore
index 19e6062..f475932 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+/build*/
+/subprojects/*
+!subprojects/*.wrap
Makefile
Makefile.in
aclocal.m4
@@ -25,4 +28,4 @@
.cscope/
*.orig
*.rej
-*~
+*~
\ No newline at end of file
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..05aa623
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,106 @@
+project(
+ 'phosphor-net-ipmid', 'cpp',
+ version : '1.0.0',
+ meson_version: '>=0.58.0',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++20',
+ 'buildtype=debugoptimized',
+ ]
+)
+
+conf_data = configuration_data()
+conf_data.set('RMCP_PING', get_option('rmcp_ping').enabled())
+
+configure_file(output: 'config.h',
+ configuration: conf_data
+)
+
+sdbusplus_dep = dependency('sdbusplus')
+phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
+phosphor_logging_dep = dependency('phosphor-logging')
+libsystemd_dep = dependency('libsystemd')
+libcrypto_dep = dependency('libcrypto')
+ipmid_dep = dependency('libipmid')
+userlayer_dep = dependency('libuserlayer')
+channellayer_dep = dependency('libchannellayer')
+mapper = dependency('libmapper')
+
+# Project Arguments
+cpp = meson.get_compiler('cpp')
+add_project_arguments(
+ cpp.get_supported_arguments([
+ '-DBOOST_ERROR_CODE_HEADER_ONLY',
+ '-DBOOST_SYSTEM_NO_DEPRECATED',
+ '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
+ '-DBOOST_ASIO_DISABLE_THREADS',
+ '-DBOOST_ALL_NO_LIB',
+ ]),
+ language : 'cpp')
+
+deps = [
+ ipmid_dep,
+ userlayer_dep,
+ channellayer_dep,
+ libcrypto_dep,
+ libsystemd_dep,
+ phosphor_dbus_interfaces_dep,
+ phosphor_logging_dep,
+ sdbusplus_dep,
+ mapper,
+]
+
+sources = [
+ 'auth_algo.cpp',
+ 'sessions_manager.cpp',
+ 'message_parsers.cpp',
+ 'message_handler.cpp',
+ 'command_table.cpp',
+ 'command/channel_auth.cpp',
+ 'command/guid.cpp',
+ 'command/open_session.cpp',
+ 'command/rakp12.cpp',
+ 'command/rakp34.cpp',
+ 'command/session_cmds.cpp',
+ 'comm_module.cpp',
+ 'main.cpp',
+ 'integrity_algo.cpp',
+ 'crypt_algo.cpp',
+ 'sd_event_loop.cpp',
+ 'sol/sol_manager.cpp',
+ 'sol/sol_context.cpp',
+ 'command/sol_cmds.cpp',
+ 'command/payload_cmds.cpp',
+ 'sol_module.cpp',
+]
+
+executable(
+ 'netipmid',
+ sources,
+ implicit_include_directories: true,
+ include_directories: ['command', 'sol'],
+ dependencies: deps,
+ install: true,
+ install_dir: get_option('bindir')
+)
+
+systemd = dependency('systemd')
+systemd_system_unit_dir = systemd.get_variable(
+ pkgconfig: 'systemdsystemunitdir',
+ pkgconfig_define: ['prefix', get_option('prefix')])
+
+configure_file(input: 'phosphor-ipmi-net@.service',
+ output: 'phosphor-ipmi-net@.service',
+ copy: true,
+ install_dir: systemd_system_unit_dir)
+
+configure_file(input: 'phosphor-ipmi-net@.socket',
+ output: 'phosphor-ipmi-net@.socket',
+ copy: true,
+ install_dir: systemd_system_unit_dir)
+
+build_tests = get_option('tests')
+if not build_tests.disabled()
+ subdir('test')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..097dc52
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,13 @@
+option(
+ 'tests',
+ type : 'feature',
+ value: 'enabled',
+ description : 'Build tests'
+)
+
+option(
+ 'rmcp_ping',
+ type : 'feature',
+ value: 'enabled',
+ description : 'Enable RMCP Ping support'
+)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..34f8c32
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,41 @@
+gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
+gmock_dep = dependency('gmock', disabler: true, required: false)
+if not gtest_dep.found() or not gmock_dep.found()
+ gtest_proj = import('cmake').subproject('googletest', required: false)
+ if gtest_proj.found()
+ gtest_dep = declare_dependency(
+ dependencies: [
+ dependency('threads'),
+ gtest_proj.dependency('gtest'),
+ gtest_proj.dependency('gtest_main'),
+ ]
+ )
+ gmock_dep = gtest_proj.dependency('gmock')
+ else
+ assert(
+ not get_option('tests').enabled(),
+ 'Googletest is required if tests are enabled'
+ )
+ endif
+endif
+
+test_sources = [
+ '../integrity_algo.cpp',
+ '../crypt_algo.cpp',
+]
+
+tests = [
+ 'cipher.cpp',
+]
+
+foreach t : tests
+ test(t, executable(t.underscorify(), t,
+ test_sources,
+ include_directories: ['..'],
+ dependencies: [
+ gtest_dep,
+ gmock_dep,
+ libcrypto_dep,
+ ]),
+ workdir: meson.current_source_dir())
+endforeach
\ No newline at end of file