Enable Meson Build system for phoshphor-time-manager
- This commit enables the meson build system for the
phoshphor-time-manager repo.
Tested By:
- Code compiles both in arm & x86 sdks without errors or warnings.
- All the unit test cases are getting passed.
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Change-Id: I311bf33f34c6c71860e9c845b6ca3c591af8fa6a
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..af453fe
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,82 @@
+project('phosphor-time-manager',
+ 'cpp',
+ version: '0.1',
+ meson_version: '>=0.53.2',
+ default_options: [ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++17',
+ 'buildtype=debugoptimized' ])
+
+########################################################################
+
+# Project Links
+
+project_pretty_name = 'phosphor-time-manager'
+project_url = 'https://github.com/openbmc/' + project_pretty_name
+project_issues_url = project_url + '/issues/new'
+
+summary('Issue', project_issues_url, section : 'Report Issues')
+
+#####################################################################
+
+# Validate the c++ Standard
+
+if get_option('cpp_std') != 'c++17'
+ error('This project requires cpp std to be in c++17 mode')
+endif
+
+#########################################################################
+
+# Get Compiler and default build type
+
+compiler = meson.get_compiler('cpp')
+
+#########################################################################
+
+# Find the dependencies
+
+sdbusplus = dependency ('sdbusplus')
+logging = dependency ('phosphor-logging')
+dbus = dependency ('phosphor-dbus-interfaces')
+deps = [sdbusplus, logging, dbus]
+
+###########################################################################
+
+# Get the config data and enable options
+
+conf_data = configuration_data()
+conf_data.set_quoted('BUSNAME', get_option('busname'))
+conf_data.set_quoted('OBJPATH_BMC', get_option('obj_path_bmc'))
+conf_data.set('DEFAULT_TIME_MODE', get_option('default_time_mode'))
+
+configure_file(output: 'config.h', configuration: conf_data)
+
+
+############################################################################
+
+# Gather sources for the target binaries
+
+phosphor_time_manager_sources = [
+ 'epoch_base.cpp',
+ 'bmc_epoch.cpp',
+ 'manager.cpp',
+ 'utils.cpp',
+ 'settings.cpp',
+ ]
+
+libtimemanager = static_library('libtimemanager',
+ phosphor_time_manager_sources,
+ dependencies : deps)
+############################################################################
+
+# Build binaries
+
+executable('phosphor-time-manager',
+ 'main.cpp',
+ link_with : libtimemanager,
+ dependencies : deps,
+ install : true)
+
+if get_option('tests').enabled()
+ subdir('test')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..8f03101
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,27 @@
+# Features List
+
+# command : meson configure -Dfeature_name=enabled
+
+option( 'tests', type : 'feature',
+ description: 'Build unit tests'
+ )
+
+# Commandline variables list
+# Value can be assigned from commandline to below variables
+# otherwise default value will be considered
+# Command: meson configure -Doption=value
+
+# Ex: meson configure -Dobj_path_bmc=path
+
+option ( 'busname', type : 'string',
+ value : 'xyz.openbmc_project.Time.Manager',
+ description : 'The Time Manager DBus busname to own')
+
+option ( 'obj_path_bmc', type : 'string',
+ value : '/xyz/openbmc_project/time/bmc',
+ description : 'The bmc epoch Dbus root')
+
+option ( 'default_time_mode', type : 'combo',
+ choices: ['Mode::Manual', 'Mode::NTP'],
+ value : 'Mode::Manual',
+ description : 'The default time mode')
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..e43a27b
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,27 @@
+#################################################################################
+# Enforce the test dependencies when tests are enabled
+gtest = dependency('gtest', main: true, disabler: true,required : get_option('tests'))
+gmock = dependency('gmock',required : get_option('tests'))
+
+##################################################################################
+# declare the test sources
+test_list = [
+ 'TestBmcEpoch.cpp',
+ 'TestManager.cpp',
+ 'TestUtils.cpp',
+ 'mocked_property_change_listener.hpp',
+]
+
+###################################################################################
+# Run the tests
+foreach tests:test_list
+ test_name = tests.split('.')[0]
+ test(test_name,
+ executable(test_name,tests,
+ include_directories : ['.','../'],
+ link_with : libtimemanager,
+ dependencies : [ gtest,
+ gmock,
+ ] + deps))
+endforeach
+