Rearrange folder 22/242422/1
authorYu <jiung.yu@samsung.com>
Thu, 27 Aug 2020 00:08:43 +0000 (09:08 +0900)
committerYu <jiung.yu@samsung.com>
Thu, 27 Aug 2020 00:09:07 +0000 (09:09 +0900)
Change-Id: I34c301ae4dbff30d25e66e12c9b7ddec91be466d
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
13 files changed:
CMakeLists.txt
capi-network-uwb.pc.in [deleted file]
include/CMakeLists.txt [new file with mode: 0644]
packaging/capi-network-uwb.spec
pkgconfig/CMakeLists.txt [new file with mode: 0644]
pkgconfig/capi-network-uwb.pc.in [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/gen.sh [deleted file]
src/uwb-log.h [moved from include/uwb_log.h with 100% similarity]
src/uwb-private.h [moved from include/uwb_private.h with 98% similarity]
src/uwb-util.c [moved from src/uwb_util.c with 97% similarity]
src/uwb-util.h [moved from include/uwb_util.h with 97% similarity]
src/uwb.c

index 4425f65..516c32f 100644 (file)
@@ -1,84 +1,41 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+# Copyright (c) 2020 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.
+#
+# @file        CMakeLists.txt
+#
+
+############################# Check minimum CMake version #####################
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
 SET(CAPI_UWB "capi-network-uwb")
+PROJECT(${CAPI_UWB})
 
-PROJECT(${CAPI_UWB} C CXX)
+############################# cmake packages ##################################
 
-MESSAGE(" - Defining...configuration variables")
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-SET(LIB ${LIB_PATH})
-SET(LIBDIR ${PREFIX}/${LIB_PATH})
-
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-
-MESSAGE(" - Checking...packages dependency")
-SET(COMMON_DEPS dlog gio-2.0 glib-2.0 gio-unix-2.0 capi-system-info)
-SET(PC_DEPS "")
-
-MESSAGE(" - Making...build configuration")
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${CAPI_UWB} REQUIRED ${COMMON_DEPS})
-FOREACH(flag ${${CAPI_UWB}_CFLAGS})
-    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(DEFAULT_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC -Werror -g -fvisibility=hidden")
-IF(BUILD_GCOV)
-       SET(GCOV_C_FLAGS "-fprofile-arcs -ftest-coverage")
-ENDIF(BUILD_GCOV)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEFAULT_CFLAGS} ${GCOV_C_FLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-IF("${ARCH}" STREQUAL "arm")
-    ADD_DEFINITIONS("-DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DTIZEN_DEBUG")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie -Wl,--rpath=${LIBDIR}")
-
-MESSAGE(" - Generating...d-bus code")
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-                " \\
-                --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/uwb_gdbus \\
-                --interface-prefix org.tizen.uwb. \\
-                ${CMAKE_CURRENT_SOURCE_DIR}/src/uwb-gdbuslib.xml \\
-                ")
-
-MESSAGE(" - Building...shared library")
-SET(SOURCES src/uwb.c
-            src/uwb_gdbus.c
-            src/uwb_util.c)
-
-ADD_LIBRARY(${CAPI_UWB} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${CAPI_UWB} ${${CAPI_UWB}_LDFLAGS} pthread)
-
-SET_TARGET_PROPERTIES(${CAPI_UWB}
-     PROPERTIES
-     VERSION ${FULLVER}
-     SOVERSION ${MAJORVER}
-     CLEAN_DIRECT_OUTPUT 1
-)
 
-MESSAGE(" - Installing...the library and header files")
-INSTALL(TARGETS ${CAPI_UWB} DESTINATION ${LIB})
-INSTALL(
-        DIRECTORY include/ DESTINATION include
-        FILES_MATCHING
-        PATTERN "include/*.h"
-        )
+SET(COMMON_DEPS "dlog glib-2.0 gio-2.0 gio-unix-2.0 capi-system-info")
+SET(PC_DEPS "capi-base-common")
+SET(TEST_DEPS "glib-2.0")
+SET(GTEST_DEPS "gmock")
 
-SET(PC_NAME ${CAPI_UWB})
-SET(PC_REQUIRED ${PC_DEPS})
-SET(PC_LDFLAGS -l${CAPI_UWB})
+SET(TARGET_UWB "capi-network-uwb")
+SET(TARGET_UWB_TEST "capi-network-uwb-test")
+SET(TARGET_UWB_GTEST "capi-network-uwb-gtest")
 
-CONFIGURE_FILE(
-    ${CAPI_UWB}.pc.in
-    ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_UWB}.pc
-    @ONLY
-)
+ADD_DEFINITIONS("-DUSE_DLOG")
 
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_UWB}.pc DESTINATION ${LIB}/pkgconfig)
+ADD_SUBDIRECTORY(include)
+ADD_SUBDIRECTORY(pkgconfig)
+ADD_SUBDIRECTORY(src)
diff --git a/capi-network-uwb.pc.in b/capi-network-uwb.pc.in
deleted file mode 100644 (file)
index c45e5b2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=/usr
-libdir=@libdir@
-includedir=/usr/include/
-
-Name: @PC_NAME@
-Description: @PACKAGE_DESCRIPTION@
-Version: @VERSION@
-Requires: @PC_REQUIRED@
-Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir}
-
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100644 (file)
index 0000000..55a2db4
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (c) 2020 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.
+#
+# @file        CMakeLists.txt
+#
+
+INSTALL(FILES
+    ${CMAKE_SOURCE_DIR}/include/uwb.h
+    DESTINATION ${INCLUDE_DIR}
+    )
index 55149ca..48b5eee 100644 (file)
@@ -2,7 +2,7 @@ Name:       capi-network-uwb
 Summary:    UWB CAPI
 Version:    0.1.1
 Release:    0
-Group:      Network & Connectivity/Other
+Group:      Network & Connectivity/API
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    %{name}.manifest
@@ -17,19 +17,31 @@ BuildRequires: pkgconfig(capi-system-info)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
+%if 0%{?gcov:1}
+BuildRequires:  lcov
+BuildRequires:  tar
+%endif
+BuildRequires:  pkgconfig(gmock)
+
 %description
 UWB API library
-Group:    Network & Connectivity/Other
-Requires: %{name} = %{version}-%{release}
 
 %package devel
 Summary:  UWB API library (development library)
-Group:    Network & Connectivity/Other
+Group:    Development/Libraries
 Requires: %{name} = %{version}-%{release}
 
 %description devel
 This package contains the development files for %{name} API library.
 
+%package tests
+Summary:  Test Application UWB
+Group:    Network & Connectivity/Testing
+Requires: %{name} = %{version}-%{release}
+
+%description tests
+Test Application for UWB Framework
+
 %if 0%{?gcov:1}
 %package gcov
 Summary:    A UWB gcov Tool
@@ -40,48 +52,50 @@ UWB gcov objects
 %endif
 
 %prep
-%setup #-q
-chmod g-w %_sourcedir/*
+%setup -q
+chmod 644 %{SOURCE0}
 cp %{SOURCE1} ./%{name}.manifest
 
 %build
-CFLAGS=$(echo $CFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
-CXXFLAGS=$(echo $CXXFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
+
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
 %if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
 export LDFLAGS+=" -lgcov"
 %endif
 
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 
-%define NETWORK_FW_DATADIR %{TZ_SYS_GLOBALUSER_DATA}/network
-%define DBDIR %{TZ_SYS_GLOBALUSER_DATA}/
+cmake . \
+        -DCMAKE_VERBOSE_MAKEFILE=ON \
+        -DLIB_DIR:PATH=%{_libdir} \
+        -DBIN_DIR:PATH=%{_bindir} \
+        -DINCLUDE_DIR:PATH=%{_includedir} \
+        -DFULLVER=%{version} \
+        -DMAJORVER=${MAJORVER}
 
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-       -DLIB_INSTALL_DIR=%{_libdir} \
-       -DBIN_INSTALL_DIR=%{_bindir} \
-       -DINCLUDE_INSTALL_DIR=%{_includedir} \
-       -DLIB_PATH=%{_lib} \
-       -DFULLVER=%{version} \
-       -DMAJORVER=${MAJORVER} \
-       -DNETWORK_FW_DATADIR=%{NETWORK_FW_DATADIR} \
-       -DDBDIR=%{DBDIR} \
-       -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
+make %{?_smp_mflags}
 
-make %{?jobs:-j%jobs}
+%install
+
+%make_install
 
 %if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
+find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T -
+install -d -m 755 %{buildroot}%{_datadir}/gcov/obj
+tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
 %endif
 
-%install
-rm -rf %{buildroot}/BUILD/%{name}
-%make_install
-
+%check
+#tests/%{name}-gtest
 %if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
 %endif
 
 %post -p /sbin/ldconfig
@@ -91,8 +105,8 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
 
 %files
 %manifest %{name}.manifest
-%defattr(-,root,root,-)
 %license LICENSE.APLv2
+%defattr(-,root,root,-)
 %attr(644,-,-) %{_libdir}/lib%{name}.so.*
 
 %files devel
@@ -101,6 +115,10 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
 %{_libdir}/pkgconfig/%{name}.pc
 %{_includedir}/*.h
 
+%files tests
+#%{_bindir}/%{name}-test
+#%{_bindir}/%{name}-gtest
+
 %if 0%{?gcov:1}
 %files gcov
 %{_datadir}/gcov/obj/*
diff --git a/pkgconfig/CMakeLists.txt b/pkgconfig/CMakeLists.txt
new file mode 100644 (file)
index 0000000..44ff5e3
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (c) 2020 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.
+#
+# @file        CMakeLists.txt
+#
+
+SET(PC_NAME ${CAPI_UWB})
+SET(PC_DESCRIPTION ${PACKAGE_DESCRIPTION})
+SET(PC_VERSION ${FULLVER})
+SET(PC_REQUIRED ${PC_DEPS})
+SET(PC_LDFLAGS -l${CAPI_UWB})
+
+CONFIGURE_FILE(${PC_NAME}.pc.in ${PC_NAME}.pc @ONLY)
+
+INSTALL(FILES
+    ${CMAKE_BINARY_DIR}/pkgconfig/${PC_NAME}.pc
+    DESTINATION
+    ${LIB_DIR}/pkgconfig
+    )
diff --git a/pkgconfig/capi-network-uwb.pc.in b/pkgconfig/capi-network-uwb.pc.in
new file mode 100644 (file)
index 0000000..72dcd2b
--- /dev/null
@@ -0,0 +1,11 @@
+# Package Information for pkg-config
+
+libdir=@LIB_DIR@
+includedir=@INCLUDE_DIR@
+
+Name: @PC_NAME@
+Description: @PC_DESCRIPTION@
+Version: @PC_VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3c99212
--- /dev/null
@@ -0,0 +1,43 @@
+########################## search for packages ################################
+
+PKG_CHECK_MODULES(UWB_DEPS REQUIRED ${COMMON_DEPS})
+
+############################# compiler flags ##################################
+
+SET(EXTRA_FLAGS "-fPIC -Wall -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread -pie")
+
+########################  directory configuration  ############################
+
+INCLUDE_DIRECTORIES(${UWB_DEPS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${UWB_DEPS_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
+
+MESSAGE(" - Generating...d-bus code")
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+                " \\
+                --generate-c-code ${CMAKE_SOURCE_DIR}/src/uwb-gdbus \\
+                --interface-prefix org.tizen.uwb. \\
+                ${CMAKE_SOURCE_DIR}/src/uwb-gdbuslib.xml \\
+                ")
+# Build
+SET(SRCS
+       uwb.c
+       uwb-util.c
+       uwb-gdbus.c
+)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${UWB_DEPS_LIBRARIES})
+SET_TARGET_PROPERTIES(${PROJECT_NAME}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+)
+
+# Install
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_DIR})
diff --git a/src/gen.sh b/src/gen.sh
deleted file mode 100755 (executable)
index c41531f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-gdbus-codegen --interface-prefix org.tizen.uwb \
-        --generate-c-code uwb_gdbus \
-        --c-generate-object-manager \
-        uwb-gdbuslib.xml \
similarity index 100%
rename from include/uwb_log.h
rename to src/uwb-log.h
similarity index 98%
rename from include/uwb_private.h
rename to src/uwb-private.h
index d0e8d2b..b317bb9 100755 (executable)
@@ -21,8 +21,7 @@
 #include <gio/gio.h>
 #include <glib.h>
 #include <uwb.h>
-#include <uwb_log.h>
-#include <uwb_gdbus.h>
+#include <uwb-log.h>
 #include <system_info.h>
 
 #define UWB_FEATURE "http://tizen.org/feature/network.uwb"
similarity index 97%
rename from src/uwb_util.c
rename to src/uwb-util.c
index ecaae35..5a4a563 100755 (executable)
@@ -16,8 +16,8 @@
  */
 #include <glib.h>
 #include <uwb.h>
-#include <uwb_log.h>
-#include <uwb_private.h>
+#include <uwb-log.h>
+#include <uwb-private.h>
 #include <stdlib.h>
 
 void _node_free_func(gpointer data)
similarity index 97%
rename from include/uwb_util.h
rename to src/uwb-util.h
index de78287..c30859c 100755 (executable)
@@ -18,8 +18,6 @@
 #ifndef __UWB_UTIL_H__
 #define __UWB_UTIL_H__
 
-#include <uwb_private.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
index 4c46893..b5bac02 100755 (executable)
--- a/src/uwb.c
+++ b/src/uwb.c
 
 #include <dlog.h>
 #include <uwb.h>
-#include <uwb_log.h>
-#include <uwb_private.h>
-#include <uwb_gdbus.h>
-#include <uwb_util.h>
+#include <uwb-log.h>
+#include <uwb-private.h>
+#include <uwb-gdbus.h>
+#include <uwb-util.h>
 #include <inttypes.h>
 
 #define UWB_DBUS_SERVICE "org.tizen.uwb"               /**< For uwb dbus */