Add hal-backend-device-common.h for common macro used in HAL 45/253445/8 accepted/tizen/unified/20210215.130858 submit/tizen/20210215.055935
authorlokilee73 <changjoo.lee@samsung.com>
Wed, 10 Feb 2021 05:33:27 +0000 (14:33 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 15 Feb 2021 04:58:58 +0000 (13:58 +0900)
Change-Id: Ia5f36dd43fdb1928a0913957a876f70f71fea4b9
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
CMakeLists.txt
hal-backend-device-common.pc.in
include/hal-backend-common.h [new file with mode: 0644]
packaging/hal-backend-device-common.spec

index bf21e4b..88d9222 100644 (file)
@@ -8,7 +8,7 @@ SET(SRCS
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-common_pkgs REQUIRED libusbgx libsyscommon)
+pkg_check_modules(hal-backend-device-common_pkgs REQUIRED libusbgx libsyscommon dlog)
 
 FOREACH(flag ${hal-backend-device-common_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -19,12 +19,17 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 
+IF(ENABLE_DLOG STREQUAL on)
+       ADD_DEFINITIONS("-DFEATURE_DLOG")
+ENDIF()
+
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-common_pkgs_LDFLAGS})
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.Apache-2.0 DESTINATION ${HAL_LICENSE_DIR}/${PROJECT_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-backend-common-usb_gadget.h DESTINATION ${HAL_INCLUDE_DIR}/device)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-backend-common.h DESTINATION ${HAL_INCLUDE_DIR}/device)
 
 CONFIGURE_FILE(hal-backend-device-common.pc.in hal-backend-device-common.pc @ONLY)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hal-backend-device-common.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
index 4fe410c..1980a37 100644 (file)
@@ -2,5 +2,7 @@
 
 Name: HAL backend device common
 Description: Library for HAL backend device modules
+Requires: dlog
 Version: 1.1
-Libs: -L@HAL_LIB_DIR@ -Wl,-rpath,@HAL_LIB_DIR@ -lhal-backend-device-common
\ No newline at end of file
+
+Libs: -L@HAL_LIB_DIR@ -Wl,-rpath,@HAL_LIB_DIR@ -lhal-backend-device-common -ldlog
diff --git a/include/hal-backend-common.h b/include/hal-backend-common.h
new file mode 100644 (file)
index 0000000..2e87697
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __HAL_BACKEND_COMMON_H__
+#define __HAL_BACKEND_COMMON_H__
+
+#ifdef FEATURE_DLOG
+    #define LOG_TAG "HAL_BACKEND_DEVICE"
+    #include <dlog.h>
+    #define _D(fmt, args...)    SLOGD(fmt, ##args)
+    #define _I(fmt, args...)    SLOGI(fmt, ##args)
+    #define _W(fmt, args...)    SLOGW(fmt, ##args)
+    #define _E(fmt, args...)    SLOGE(fmt, ##args)
+#else
+    #define _D(x, ...)
+    #define _I(x, ...)
+    #define _W(x, ...)
+    #define _E(x, ...)
+#endif
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#endif /* __HAL_BACKEND_COMMON_H__ */
index bbdec8f..3355a9b 100644 (file)
@@ -10,6 +10,7 @@ BuildRequires:  cmake
 BuildRequires:  pkgconfig(libusbgx)
 BuildRequires:  pkgconfig(hal-api-device)
 BuildRequires:  pkgconfig(libsyscommon)
+BuildRequires:  pkgconfig(dlog)
 
 %description
 Library for HAL backend device modules
@@ -28,7 +29,8 @@ cp %{SOURCE1} .
 %build
 %cmake . -DHAL_LIB_DIR=%{_hal_libdir} \
          -DHAL_INCLUDE_DIR=%{_hal_includedir} \
-         -DHAL_LICENSE_DIR=%{_hal_licensedir}
+         -DHAL_LICENSE_DIR=%{_hal_licensedir} \
+         -DENABLE_DLOG=on
 
 make %{?jobs:-j%jobs}
 
@@ -43,5 +45,5 @@ make %{?jobs:-j%jobs}
 %files devel
 %manifest %{name}.manifest
 %{_hal_licensedir}/%{name}/LICENSE.Apache-2.0
-%{_hal_includedir}/device/hal-backend-common-usb_gadget.h
+%{_hal_includedir}/device/hal-backend-common*.h
 %{_libdir}/pkgconfig/*.pc