From: Chanwoo Choi Date: Tue, 4 Mar 2025 11:00:14 +0000 (+0900) Subject: Get HAL transport from HAL manifest on library constructor X-Git-Tag: accepted/tizen/unified/20250311.134552^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ec17d72b16e1cbdc8f86a8040fa12ed54cd40de;p=platform%2Fhal%2Fapi%2Fdevice.git Get HAL transport from HAL manifest on library constructor 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e675807..040f443 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/packaging/hal-api-device.spec b/packaging/hal-api-device.spec index dfe105d..079facf 100644 --- a/packaging/hal-api-device.spec +++ b/packaging/hal-api-device.spec @@ -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} diff --git a/src/hal-api-device-display.c b/src/hal-api-device-display.c index e6c748b..e688434 100644 --- a/src/hal-api-device-display.c +++ b/src/hal-api-device-display.c @@ -24,7 +24,17 @@ #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) { diff --git a/src/hal-api-device-led.c b/src/hal-api-device-led.c index 58aa57e..43b2867 100644 --- a/src/hal-api-device-led.c +++ b/src/hal-api-device-led.c @@ -22,7 +22,17 @@ #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) {