From bbcae4a61702d0ecefad9d8163404bc2c4bc92f3 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 16 Nov 2016 16:34:16 +0900 Subject: [PATCH] Clean up repository Fix CMakeLists.txt to make extendible. Clean build dependency of each components. Rename some files. Change-Id: I5fe6ee6d7618ec6da82ec717fec9e50cab6681c1 Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 12 +++----- packaging/app2sd.spec | 2 +- plugin/app2sd/CMakeLists.txt | 26 ++++++---------- .../app2sd/common/inc/app2sd_utils.h | 0 .../app2sd/common/src/app2sd_utils.c | 2 +- .../app2sd/{src => lib}/app2sd_client_interface.c | 2 +- .../app2sd/{inc => lib}/app2sd_client_interface.h | 0 plugin/app2sd/{src => server}/app2sd_interface.c | 0 plugin/app2sd/{inc => server}/app2sd_interface.h | 2 +- plugin/app2sd/{src => server}/app2sd_internals.c | 0 plugin/app2sd/{inc => server}/app2sd_internals.h | 0 .../{src => server}/app2sd_internals_registry.c | 0 .../{src => server}/app2sd_internals_utils.c | 0 plugin/app2sd/{src => server}/app2sd_server.c | 0 src/app2ext_debug.h | 36 ++++++++++++++++++++++ src/app2ext_interface.c | 3 +- test/src/test_app2ext.c | 4 ++- 17 files changed, 58 insertions(+), 31 deletions(-) rename common/inc/app2ext_utils.h => plugin/app2sd/common/inc/app2sd_utils.h (100%) rename common/src/app2ext_utils.c => plugin/app2sd/common/src/app2sd_utils.c (98%) rename plugin/app2sd/{src => lib}/app2sd_client_interface.c (99%) rename plugin/app2sd/{inc => lib}/app2sd_client_interface.h (100%) rename plugin/app2sd/{src => server}/app2sd_interface.c (100%) rename plugin/app2sd/{inc => server}/app2sd_interface.h (98%) rename plugin/app2sd/{src => server}/app2sd_internals.c (100%) rename plugin/app2sd/{inc => server}/app2sd_internals.h (100%) rename plugin/app2sd/{src => server}/app2sd_internals_registry.c (100%) rename plugin/app2sd/{src => server}/app2sd_internals_utils.c (100%) rename plugin/app2sd/{src => server}/app2sd_server.c (100%) create mode 100644 src/app2ext_debug.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e6c7a4c..56cfec8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,17 +27,13 @@ SET(CMAKE_C_FLAGS "${EXTRA_CFLAGS} ${APP2EXT_CFLAGS}") ADD_DEFINITIONS("-DLIBPREFIX=\"${LIB_INSTALL_DIR}\"") # Local include directories -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc - ${CMAKE_SOURCE_DIR}/common/inc) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc) # build app2ext library SET(APP2EXT "app2ext") -SET(app2ext_src_dir "${CMAKE_SOURCE_DIR}/src") -SET(libapp2ext_SOURCES - ${app2ext_src_dir}/app2ext_interface.c - ${CMAKE_SOURCE_DIR}/common/src/app2ext_utils.c) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src APP2EXT_SRCS) -ADD_LIBRARY(${APP2EXT} SHARED ${libapp2ext_SOURCES}) +ADD_LIBRARY(${APP2EXT} SHARED ${APP2EXT_SRCS}) SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES VERSION ${VERSION}) SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIC") @@ -48,7 +44,7 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/app2sd.pc.in ${CMAKE_BINARY_DIR}/app2sd.pc @O INSTALL(TARGETS ${APP2EXT} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/app2sd.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/app2ext_interface.h DESTINATION include) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include) IF(TIZEN_FEATURE_APP2SD_PLUGIN) ADD_SUBDIRECTORY(test) diff --git a/packaging/app2sd.spec b/packaging/app2sd.spec index bb040c9..088e5c6 100644 --- a/packaging/app2sd.spec +++ b/packaging/app2sd.spec @@ -90,7 +90,7 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} %files devel %defattr(-,root,root,-) -%{_includedir}/app2ext_interface.h +%{_includedir}/*.h %{_libdir}/pkgconfig/app2sd.pc %if 0%{?tizen_feature_app2sd_plugin} %{_libdir}/libapp2sd.so diff --git a/plugin/app2sd/CMakeLists.txt b/plugin/app2sd/CMakeLists.txt index 526a4b5..5d0138b 100644 --- a/plugin/app2sd/CMakeLists.txt +++ b/plugin/app2sd/CMakeLists.txt @@ -12,18 +12,16 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${EXTRA_CFLAGS} ${APP2SD_CFLAGS}") # Local include directories -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc - ${CMAKE_SOURCE_DIR}/common/inc - ${CMAKE_SOURCE_DIR}/plugin/app2sd/inc) +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/inc + ${CMAKE_SOURCE_DIR}/plugin/app2sd/common/inc) + +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/src APP2SD_COMMON_SRCS) # build app2sd library SET(APP2SD "app2sd") -SET(app2sd_src_dir "${CMAKE_SOURCE_DIR}/plugin/app2sd/src") -SET(libapp2sd_SOURCES - ${app2sd_src_dir}/app2sd_client_interface.c - ${CMAKE_SOURCE_DIR}/common/src/app2ext_utils.c) - -ADD_LIBRARY(${APP2SD} SHARED ${libapp2sd_SOURCES}) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/lib APP2SD_LIB_SRCS) +ADD_LIBRARY(${APP2SD} SHARED ${APP2SD_LIB_SRCS} ${APP2SD_COMMON_SRCS}) SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES VERSION ${VERSION}) SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIC") @@ -33,14 +31,8 @@ INSTALL(TARGETS ${APP2SD} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibrar # build app2sd-server binary SET(APP2SD_SERVER "app2sd-server") -SET(app2sd_server_SOURCES - ${app2sd_src_dir}/app2sd_internals.c - ${app2sd_src_dir}/app2sd_interface.c - ${app2sd_src_dir}/app2sd_internals_registry.c - ${app2sd_src_dir}/app2sd_internals_utils.c - ${app2sd_src_dir}/app2sd_server.c - ${CMAKE_SOURCE_DIR}/common/src/app2ext_utils.c) -ADD_EXECUTABLE(${APP2SD_SERVER} ${app2sd_server_SOURCES}) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/server APP2SD_SERVER_SRCS) +ADD_EXECUTABLE(${APP2SD_SERVER} ${APP2SD_SERVER_SRCS} ${APP2SD_COMMON_SRCS}) SET_TARGET_PROPERTIES(${APP2SD_SERVER} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE ") SET_TARGET_PROPERTIES(${APP2SD_SERVER} PROPERTIES LINK_FLAGS "-pie") TARGET_LINK_LIBRARIES(${APP2SD_SERVER} app2sd ${app2sd_pkgs_LDFLAGS} "-lm") diff --git a/common/inc/app2ext_utils.h b/plugin/app2sd/common/inc/app2sd_utils.h similarity index 100% rename from common/inc/app2ext_utils.h rename to plugin/app2sd/common/inc/app2sd_utils.h diff --git a/common/src/app2ext_utils.c b/plugin/app2sd/common/src/app2sd_utils.c similarity index 98% rename from common/src/app2ext_utils.c rename to plugin/app2sd/common/src/app2sd_utils.c index 54d54dc..e2e1a8d 100644 --- a/common/src/app2ext_utils.c +++ b/plugin/app2sd/common/src/app2sd_utils.c @@ -20,7 +20,7 @@ #include #include -#include "app2ext_utils.h" +#include "app2sd_utils.h" int _is_global(uid_t uid) { diff --git a/plugin/app2sd/src/app2sd_client_interface.c b/plugin/app2sd/lib/app2sd_client_interface.c similarity index 99% rename from plugin/app2sd/src/app2sd_client_interface.c rename to plugin/app2sd/lib/app2sd_client_interface.c index 0e34756..5c66bd5 100644 --- a/plugin/app2sd/src/app2sd_client_interface.c +++ b/plugin/app2sd/lib/app2sd_client_interface.c @@ -30,7 +30,7 @@ #include #include "app2sd_client_interface.h" -#include "app2ext_utils.h" +#include "app2sd_utils.h" #define CONNECTION_RETRY_MAX 5 #define CONNECTION_WAIT_USEC (1000000 / 2) /* 0.5 sec */ diff --git a/plugin/app2sd/inc/app2sd_client_interface.h b/plugin/app2sd/lib/app2sd_client_interface.h similarity index 100% rename from plugin/app2sd/inc/app2sd_client_interface.h rename to plugin/app2sd/lib/app2sd_client_interface.h diff --git a/plugin/app2sd/src/app2sd_interface.c b/plugin/app2sd/server/app2sd_interface.c similarity index 100% rename from plugin/app2sd/src/app2sd_interface.c rename to plugin/app2sd/server/app2sd_interface.c diff --git a/plugin/app2sd/inc/app2sd_interface.h b/plugin/app2sd/server/app2sd_interface.h similarity index 98% rename from plugin/app2sd/inc/app2sd_interface.h rename to plugin/app2sd/server/app2sd_interface.h index 99c1565..0e2d11a 100644 --- a/plugin/app2sd/inc/app2sd_interface.h +++ b/plugin/app2sd/server/app2sd_interface.h @@ -29,7 +29,7 @@ extern "C" { #endif #include "app2ext_interface.h" -#include "app2ext_utils.h" +#include "app2sd_utils.h" int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid_t uid); diff --git a/plugin/app2sd/src/app2sd_internals.c b/plugin/app2sd/server/app2sd_internals.c similarity index 100% rename from plugin/app2sd/src/app2sd_internals.c rename to plugin/app2sd/server/app2sd_internals.c diff --git a/plugin/app2sd/inc/app2sd_internals.h b/plugin/app2sd/server/app2sd_internals.h similarity index 100% rename from plugin/app2sd/inc/app2sd_internals.h rename to plugin/app2sd/server/app2sd_internals.h diff --git a/plugin/app2sd/src/app2sd_internals_registry.c b/plugin/app2sd/server/app2sd_internals_registry.c similarity index 100% rename from plugin/app2sd/src/app2sd_internals_registry.c rename to plugin/app2sd/server/app2sd_internals_registry.c diff --git a/plugin/app2sd/src/app2sd_internals_utils.c b/plugin/app2sd/server/app2sd_internals_utils.c similarity index 100% rename from plugin/app2sd/src/app2sd_internals_utils.c rename to plugin/app2sd/server/app2sd_internals_utils.c diff --git a/plugin/app2sd/src/app2sd_server.c b/plugin/app2sd/server/app2sd_server.c similarity index 100% rename from plugin/app2sd/src/app2sd_server.c rename to plugin/app2sd/server/app2sd_server.c diff --git a/src/app2ext_debug.h b/src/app2ext_debug.h new file mode 100644 index 0000000..a77f852 --- /dev/null +++ b/src/app2ext_debug.h @@ -0,0 +1,36 @@ +/* + * app2ext + * + * Copyright (c) 2016 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 _APP2EXT_DEBUG_H +#define _APP2EXT_DEBUG_H + +#include + +#define _E(fmt, arg...) LOGE(fmt, ##arg) +#define _D(fmt, arg...) LOGD(fmt, ##arg) +#define _W(fmt, arg...) LOGW(fmt, ##arg) +#define _I(fmt, arg...) LOGI(fmt, ##arg) + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "APP2EXT" + +#endif diff --git a/src/app2ext_interface.c b/src/app2ext_interface.c index 3407a7a..5ec1602 100644 --- a/src/app2ext_interface.c +++ b/src/app2ext_interface.c @@ -30,9 +30,10 @@ #include #include "app2ext_interface.h" -#include "app2ext_utils.h" +#include "app2ext_debug.h" #define APP2EXT_SD_PLUGIN_PATH LIBPREFIX "/libapp2sd.so" +#define REGULAR_USER 5000 app2ext_handle *app2ext_init(int storage_type) { diff --git a/test/src/test_app2ext.c b/test/src/test_app2ext.c index 737d486..69403f5 100644 --- a/test/src/test_app2ext.c +++ b/test/src/test_app2ext.c @@ -30,15 +30,17 @@ #include #include #include +#include #include "app2ext_interface.h" -#include "app2ext_utils.h" #define SUCCESS 0 #define FAIL 1 #define CMD_LEN 256 #define TEST_PKGNAME "org.example.basicuiapplication" #define TEST_PKGNAME_PATH "/tmp/org.example.basicuiapplication-1.0.0-arm.tpk" +#define OWNER_ROOT 0 +#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) app2ext_handle *handle = NULL; -- 2.7.4