Make NVIDIA shared memory (shmem) feature optional adding conditional compilation guards around shmem-related headers, making the shmem feature optional in build configurations, and changing the default value from enabled to disabled. Fixes JIRA https://jirasw.nvidia.com/browse/DGXOPENBMC-18776 Google-Bug-Id: 437731307 Change-Id: Ie1a6ef625abd720dff262bd581c705a0a9b05cc6 Signed-off-by: Akshat Jain <akshatzen@google.com>
diff --git a/meson_options.txt b/meson_options.txt index 671e8cc..289b6fc 100644 --- a/meson_options.txt +++ b/meson_options.txt
@@ -9,7 +9,7 @@ 'shmem', type: 'feature', description: 'Use NVIDIA Shared-Memory IPC', - value: 'disabled', + value: 'enabled', ) option( 'reset-metrics',
diff --git a/nsmd/nsmChassis/test/meson.build b/nsmd/nsmChassis/test/meson.build index 7bf8bac..c29b123 100644 --- a/nsmd/nsmChassis/test/meson.build +++ b/nsmd/nsmChassis/test/meson.build
@@ -11,7 +11,6 @@ '../nsmWriteProtectedJumper.cpp', '../nsmAERError.cpp', '../../nsmSensorAggregator.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmCommon/nsmCommon.cpp', '../../nsmLongRunning/nsmLongRunningSensor.cpp', '../../nsmSensors/nsmInventoryProperty.cpp', @@ -45,6 +44,10 @@ '../../nsmProcessor/nsmOemResetStatistics.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..', @@ -84,11 +87,14 @@ sdbusplus, sdeventplus, phosphor_logging, - nvidia_shmem, gtest, gmock, ] +if get_option('shmem').enabled() + tests_deps += dependency('nvidia-tal', required: true) +endif + foreach t : tests test( t,
diff --git a/nsmd/nsmCommon/meson.build b/nsmd/nsmCommon/meson.build index 3ccaa51..e351740 100644 --- a/nsmd/nsmCommon/meson.build +++ b/nsmd/nsmCommon/meson.build
@@ -1,4 +1,8 @@ -sources += ['nsmCommon/nsmCommon.cpp', 'nsmCommon/sharedMemCommon.cpp'] +sources += ['nsmCommon/nsmCommon.cpp'] + +if get_option('shmem').enabled() + sources += 'nsmCommon/sharedMemCommon.cpp' +endif nsmd_headers += ['.', '..', 'nsmCommon']
diff --git a/nsmd/nsmFwSwInventory/test/meson.build b/nsmd/nsmFwSwInventory/test/meson.build index f1b567f..87130c3 100644 --- a/nsmd/nsmFwSwInventory/test/meson.build +++ b/nsmd/nsmFwSwInventory/test/meson.build
@@ -2,7 +2,6 @@ '../NVLinkManagementNICSWInventory.cpp', '../nsmFirmwareInventory.cpp', '../nsmWriteProtectedControl.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmDevice.cpp', '../../nsmObjectFactory.cpp', '../../sensorManager.cpp', @@ -28,6 +27,10 @@ '../GPUSWInventory.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..', @@ -57,11 +60,14 @@ sdbusplus, sdeventplus, phosphor_logging, - nvidia_shmem, gtest, gmock, ] +if get_option('shmem').enabled() + tests_deps += dependency('nvidia-tal', required: true) +endif + foreach t : tests test( t,
diff --git a/nsmd/nsmGPM/test/meson.build b/nsmd/nsmGPM/test/meson.build index 016c3ee..44024da 100644 --- a/nsmd/nsmGPM/test/meson.build +++ b/nsmd/nsmGPM/test/meson.build
@@ -15,11 +15,14 @@ '../../../libnsm/requester/mctp.c', '../../../libnsm/instance-id.c', '../../../requester/request_timeout_tracker.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmFwSwInventory/GPUSWInventory.cpp', '../../nsmDbusIfaceOverride/nsmAssetIntf.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..', @@ -38,7 +41,19 @@ ) tests_files = ['nsmGpmOem_test.cpp'] - +tests_deps = [ + test_src, + CLI11_dep, + nlohmann_json, + sdbusplus, + sdeventplus, + phosphor_logging, + gtest, + gmock, +] +if get_option('shmem').enabled() + tests_deps += dependency('nvidia-tal', required: true) +endif test( 'nsmGpmOem_test', executable( @@ -47,17 +62,7 @@ implicit_include_directories: false, link_args: dynamic_linker, build_rpath: '', - dependencies: [ - test_src, - CLI11_dep, - nlohmann_json, - sdbusplus, - sdeventplus, - phosphor_logging, - nvidia_shmem, - gtest, - gmock, - ], + dependencies: tests_deps, ), workdir: meson.current_source_dir(), )
diff --git a/nsmd/nsmMemory/test/meson.build b/nsmd/nsmMemory/test/meson.build index 90d61fb..0509888 100644 --- a/nsmd/nsmMemory/test/meson.build +++ b/nsmd/nsmMemory/test/meson.build
@@ -2,7 +2,6 @@ '../nsmMemory.cpp', '../../nsmDevice.cpp', '../../nsmCommon/nsmCommon.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmObjectFactory.cpp', '../../sensorManager.cpp', '../../deviceManager.cpp', @@ -23,6 +22,10 @@ '../../nsmDbusIfaceOverride/nsmAssetIntf.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..', @@ -42,6 +45,19 @@ ) tests = ['nsmMemory_test'] +tests_deps = [ + test_src, + CLI11_dep, + nlohmann_json, + sdbusplus, + sdeventplus, + phosphor_logging, + gtest, + gmock, +] +if get_option('shmem').enabled() + tests_deps += dependency('nvidia-tal', required: true) +endif foreach t : tests test( @@ -52,17 +68,7 @@ implicit_include_directories: false, link_args: dynamic_linker, build_rpath: '', - dependencies: [ - test_src, - CLI11_dep, - nlohmann_json, - sdbusplus, - sdeventplus, - phosphor_logging, - nvidia_shmem, - gtest, - gmock, - ], + dependencies: tests_deps, ), workdir: meson.current_source_dir(), )
diff --git a/nsmd/nsmNumericSensor/test/meson.build b/nsmd/nsmNumericSensor/test/meson.build index d99453c..7af999f 100644 --- a/nsmd/nsmNumericSensor/test/meson.build +++ b/nsmd/nsmNumericSensor/test/meson.build
@@ -26,7 +26,6 @@ '../../nsmSensor.cpp', '../../nsmEvent.cpp', '../../deviceManager.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmEvent/nsmLongRunningEventHandler.cpp', '../../../common/utils.cpp', '../../../common/test/mockDBusHandler.cpp', @@ -39,6 +38,10 @@ '../../nsmDbusIfaceOverride/nsmAssetIntf.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..',
diff --git a/nsmd/nsmPort/test/meson.build b/nsmd/nsmPort/test/meson.build index 59cfb54..ad54277 100644 --- a/nsmd/nsmPort/test/meson.build +++ b/nsmd/nsmPort/test/meson.build
@@ -12,7 +12,6 @@ '../../deviceManager.cpp', '../../socket_handler.cpp', '../../nsmEvent/nsmLongRunningEventHandler.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmHistograms/nsmHistogramInfo.cpp', '../../nsmSensors/nsmPCIeLinkSpeed.cpp', '../../../common/utils.cpp', @@ -30,6 +29,10 @@ '../../nsmSensorAggregator.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..',
diff --git a/nsmd/nsmProcessor/test/meson.build b/nsmd/nsmProcessor/test/meson.build index a8a685c..813cf77 100644 --- a/nsmd/nsmProcessor/test/meson.build +++ b/nsmd/nsmProcessor/test/meson.build
@@ -25,7 +25,6 @@ '../../nsmChassis/nsmWriteProtectedJumper.cpp', '../../nsmChassis/nsmAERError.cpp', '../../nsmCommon/nsmCommon.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmMemory/nsmMemory.cpp', '../../nsmPort/nsmPortDisableFuture.cpp', '../../nsmSensors/nsmInventoryProperty.cpp', @@ -61,6 +60,10 @@ '../../nsmDbusIfaceOverride/nsmAssetIntf.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..',
diff --git a/nsmd/nsmRawCommand/test/meson.build b/nsmd/nsmRawCommand/test/meson.build index e36b63a..99ff214 100644 --- a/nsmd/nsmRawCommand/test/meson.build +++ b/nsmd/nsmRawCommand/test/meson.build
@@ -20,11 +20,14 @@ '../../../libnsm/diagnostics.c', '../../../libnsm/requester/mctp.c', '../../../requester/request_timeout_tracker.cpp', - '../../nsmCommon/sharedMemCommon.cpp', '../../nsmFwSwInventory/GPUSWInventory.cpp', '../../nsmDbusIfaceOverride/nsmAssetIntf.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '..', '../../',
diff --git a/nsmd/test/meson.build b/nsmd/test/meson.build index 7e191b4..bb769ff 100644 --- a/nsmd/test/meson.build +++ b/nsmd/test/meson.build
@@ -7,7 +7,6 @@ '../nsmEvent.cpp', '../deviceManager.cpp', '../nsmEvent/nsmLongRunningEventHandler.cpp', - '../nsmCommon/sharedMemCommon.cpp', '../nsmFwSwInventory/GPUSWInventory.cpp', '../nsmDbusIfaceOverride/nsmAssetIntf.cpp', '../socket_handler.cpp', @@ -24,6 +23,10 @@ '../../requester/request_timeout_tracker.cpp', ] +if get_option('shmem').enabled() + dep_src_files += '../nsmCommon/sharedMemCommon.cpp' +endif + dep_src_headers = [ '.', '..',