switching from cmakeLists to meson build scripts
Nearly all OBMC subprojects are using MESON. This change brings this
repo in line with other active OBMC repos, in addition to clarifying
the build process for easier future additions via simpler build
configuration scripting requirements in MESON.
The MESON scripts used here are primed to allow multiple separate
'features' to be enabled/disabled at build time via the recipe.
For now, the only 'feature' is the u-boot-env-mgr daemon, but
(at least one) more services are expected to be added in the future.
Change-Id: Id10d49aea4d488e81f459221bfa5755e29d60608
Signed-off-by: Chris Sides <Christopher.Sides@hpe.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index c8146b0..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-project(phosphor-u-boot-env-mgr CXX)
-set(CMAKE_CXX_STANDARD 20)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-find_package(Boost REQUIRED)
-include_directories(${Boost_INCLUDE_DIRS})
-add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
-add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
-add_definitions(-DBOOST_ALL_NO_LIB)
-add_definitions(-DBOOST_NO_RTTI)
-add_definitions(-DBOOST_NO_TYPEID)
-add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
-
-set(SRC_FILES src/mainapp.cpp src/u-boot-env-mgr.cpp)
-
-# import sdbusplus
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
-include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
-link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
-find_program(SDBUSPLUSPLUS sdbus++)
-
-# phosphor-dbus-interfaces
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
-include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
-link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
-
-# import phosphor-logging
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(LOGGING phosphor-logging REQUIRED)
-include_directories(${LOGGING_INCLUDE_DIRS})
-link_directories(${LOGGING_LIBRARY_DIRS})
-
-add_executable(${PROJECT_NAME} ${SRC_FILES})
-target_link_libraries(${PROJECT_NAME} ${SDBUSPLUSPLUS_LIBRARIES})
-target_link_libraries(${PROJECT_NAME} ${DBUSINTERFACE_LIBRARIES})
-target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
-target_link_libraries(${PROJECT_NAME} phosphor_logging)
-
-pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir)
-
-set(SERVICE_FILES
- ${PROJECT_SOURCE_DIR}/xyz.openbmc_project.U_Boot.Environment.Manager.service
- )
-
-install(TARGETS ${PROJECT_NAME} DESTINATION bin)
-install(FILES ${SERVICE_FILES} DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}")
-
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 0000000..5930fe2
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1,3 @@
+if get_option('phosphor-u-boot-env-mgrd').allowed()
+ install_headers('u-boot-env-mgr.hpp')
+endif
\ No newline at end of file
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..18f4f42
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,38 @@
+project(
+ 'phosphor-u-boot-env-mgr',
+ 'cpp',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++20' #highly suspect there should be more entries tied to line 4-6 of CMakeLists.txt.old
+ ],
+ license: 'Apache-2.0',
+ version: '0.1',
+ meson_version: '>=0.64.0',
+)
+add_project_arguments('-Wno-psabi', #no idea what this line is about or where it came from
+ '-DBOOST_ERROR_CODE_HEADER_ONLY',
+ '-DBOOST_SYSTEM_NO_DEPRECATED',
+ '-DBOOST_ALL_NO_LIB',
+ '-DBOOST_NO_RTTI',
+ '-DBOOST_NO_TYPEID',
+ '-DBOOST_ASIO_DISABLE_THREADS',
+ language: 'cpp')
+
+boost = dependency('boost', version: '>=1.75.0', include_type: 'system', required : true)
+sdbusplus = dependency('sdbusplus', include_type: 'system', required : true)
+dbusinterface = dependency('phosphor-dbus-interfaces', include_type: 'system', required : true)
+phosphor_logging_dep = dependency('phosphor-logging', required : true)
+
+default_deps =[
+ boost,
+ phosphor_logging_dep,
+ sdbusplus,
+ dbusinterface,
+ ]
+
+incdir = include_directories('include')
+
+subdir('src')
+subdir('include')
+subdir('service_files')
\ No newline at end of file
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..93ddb23
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('phosphor-u-boot-env-mgrd', type: 'feature', value: 'enabled', description: 'Enable u-Boot env vars -> D-Bus daemon',)
\ No newline at end of file
diff --git a/service_files/meson.build b/service_files/meson.build
new file mode 100644
index 0000000..b8d0dcb
--- /dev/null
+++ b/service_files/meson.build
@@ -0,0 +1,20 @@
+systemd = dependency('systemd')
+systemd_system_unit_dir = systemd.get_variable(
+ 'systemdsystemunitdir',
+ pkgconfig_define: ['prefix', get_option('prefix')],
+)
+
+unit_files = [
+ ['phosphor-u-boot-env-mgrd', 'xyz.openbmc_project.U_Boot.Environment.Manager.service'],
+]
+
+fs = import('fs')
+foreach tuple : unit_files
+ if get_option(tuple[0]).allowed()
+ fs.copyfile(
+ tuple[1],
+ install: true,
+ install_dir: systemd_system_unit_dir,
+ )
+ endif
+endforeach
\ No newline at end of file
diff --git a/xyz.openbmc_project.U_Boot.Environment.Manager.service b/service_files/xyz.openbmc_project.U_Boot.Environment.Manager.service
similarity index 100%
rename from xyz.openbmc_project.U_Boot.Environment.Manager.service
rename to service_files/xyz.openbmc_project.U_Boot.Environment.Manager.service
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..b1541f8
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,10 @@
+if get_option('phosphor-u-boot-env-mgrd').allowed()
+ executable(
+ 'phosphor-u-boot-env-mgr',
+ 'u-boot-env-mgr.cpp',
+ 'mainapp.cpp',
+ include_directories : incdir,
+ dependencies: default_deps,
+ install: true,
+ )
+endif
\ No newline at end of file