Get HAL transport from HAL manifest on library constructor 15/320515/1 accepted/tizen/unified/20250311.134552 accepted/tizen/unified/x/20250312.054009
authorChanwoo Choi <cw00.choi@samsung.com>
Tue, 4 Mar 2025 11:00:14 +0000 (20:00 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 4 Mar 2025 11:18:02 +0000 (20:18 +0900)
Get HAL transport from HAL manifest on library constructor dynamically
instead of constant build config setting.
- HAL manifest : /etc/hal/hal-api-device-manifest.xml

Change-Id: Idbed802737dc9c3d906de2828dc87967d207e195
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
packaging/hal-api-device.spec
src/hal-api-device-display.c
src/hal-api-device-led.c

index e6758070a1ea81722e513ab97b8407bae6f1ae1e..040f443ddc60a7b46cf0b70b5222983f6d7be72e 100644 (file)
@@ -37,7 +37,6 @@ ENDIF("${ARCH}" STREQUAL "arm")
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DFEATURE_DEVICE_DLOG")
 ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}/hal\"")
-ADD_DEFINITIONS(-DHAL_TRANSPORT=${HAL_TRANSPORT})
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}/hal")
 
index dfe105d0c3e8872d982ce41711dc1f6d8b9eaff0..079facfa18d36df9aae3cfc088c89a784987a0c5 100644 (file)
@@ -1,4 +1,3 @@
-%define            hal_transport 1
 Name:       hal-api-device
 Summary:    API library for HAL device modules
 Version:    1.0.0
@@ -52,8 +51,7 @@ cp %{SOURCE1} .
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . -DFULLVER=%{version} \
                 -DMAJORVER=${MAJORVER} \
-                -DHALTEST=on \
-                -DHAL_TRANSPORT=%{hal_transport}
+                -DHALTEST=on
 
 %__make %{?jobs:-j%jobs}
 
index e6c748b1695a065a50ba900fb0a632f9ba03900b..e6884346293903e59c65fbcf812439ddc45fb5d6 100644 (file)
 
 #include "common.h"
 
-static enum hal_common_transport g_hal_transport = HAL_TRANSPORT;
+static enum hal_common_transport g_hal_transport = HAL_COMMON_TRANSPORT_UNKNOWN;
+
+static void __attribute__((constructor)) hal_device_display_constructor(void)
+{
+       int ret = hal_common_get_transport(HAL_MODULE_DEVICE_DISPLAY,
+                                               &g_hal_transport);
+       if (ret < 0) {
+               _W("Failed to get HAL transport from HAL manifest\n");
+               g_hal_transport = HAL_COMMON_TRANSPORT_PASSTHROUGH;
+       }
+}
 
 int hal_device_display_get_backend(void)
 {
index 58aa57e494c081b3d815ef34d5b852730803b9ae..43b286728d2dce4509964facca3513a7a7f18197 100644 (file)
 #include "hal-api-device-led-ipc.h"
 #include "hal-api-device-led-passthrough.h"
 
-static enum hal_common_transport g_hal_transport = HAL_TRANSPORT;
+static enum hal_common_transport g_hal_transport = HAL_COMMON_TRANSPORT_UNKNOWN;
+
+static void __attribute__((constructor)) hal_device_led_constructor(void)
+{
+       int ret = hal_common_get_transport(HAL_MODULE_DEVICE_LED,
+                                               &g_hal_transport);
+       if (ret < 0) {
+               _W("Failed to get HAL transport from HAL manifest\n");
+               g_hal_transport = HAL_COMMON_TRANSPORT_PASSTHROUGH;
+       }
+}
 
 int hal_device_led_get_backend(void)
 {