From d13767254d486961ef4ccf47b05817142e59eb2d Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Tue, 22 Nov 2016 15:26:25 +0900 Subject: [PATCH] [4.0] Remove Profile Build Dependencies: do it at runtime - This is for Tizen 4.0. : Tizen 4.0 Configurability and Build Blocks require to remove all profile-depending build options in spec files. (No More profile macros) : Because per-profile difference could be resolved in runtime in this package, the subpackaging has not become complex. - The differences in binary size for non-TV profiels is about 2kiB. Change-Id: I61cd193744cdf1976a18be700e77da62ef2b66c0 Signed-off-by: MyungJoo Ham --- CMakeLists.txt | 6 ------ packaging/capi-system-device.spec | 11 +---------- src/common.c | 35 +++++++++++++++++++++++++++++++++++ src/common.h | 12 ++++++++++++ src/power.c | 19 +++++++------------ 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index feb4090..75181f5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,14 +16,8 @@ SET(PKG_MODULES capi-base-common capi-system-info gio-2.0 -) - -IF("${TIZEN_FEATURE_TRACKER}" STREQUAL "on") -SET(PKG_MODULES ${PKG_MODULES} tracker ) -ADD_DEFINITIONS("-DTIZEN_FEATURE_TRACKER") -ENDIF("${TIZEN_FEATURE_TRACKER}" STREQUAL "on") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${PKG_MODULES}) diff --git a/packaging/capi-system-device.spec b/packaging/capi-system-device.spec index 28302d0..7cc1169 100644 --- a/packaging/capi-system-device.spec +++ b/packaging/capi-system-device.spec @@ -1,9 +1,3 @@ -%define TIZEN_FEATURE_TRACKER on - -%if "%{?profile}" == "tv" -%define TIZEN_FEATURE_TRACKER off -%endif - Name: capi-system-device Summary: A Device library in TIZEN C API Version: 0.1.0 @@ -18,9 +12,7 @@ BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(gio-2.0) -%if %{?TIZEN_FEATURE_TRACKER} == "on" BuildRequires: pkgconfig(tracker) -%endif %description A Device library in TIZEN C API package. @@ -41,8 +33,7 @@ A Device library in TIZEN C API (Development) package. cp %{SOURCE1} . MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} \ - -DMAJORVER=${MAJORVER} \ - -DTIZEN_FEATURE_TRACKER=%{TIZEN_FEATURE_TRACKER} + -DMAJORVER=${MAJORVER} %__make %{?jobs:-j%jobs} diff --git a/src/common.c b/src/common.c index 4936577..63481dc 100644 --- a/src/common.c +++ b/src/common.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include "common.h" #define MAX_LINE 128 @@ -126,3 +128,36 @@ error: _E("Failed to read %s:%d!", file_name, lineno); return ret; } + +tizen_profile_t _get_tizen_profile() +{ + static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN; + if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1)) + return profile; + + char *profileName; + system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + switch (*profileName) { + case 'm': + case 'M': + profile = TIZEN_PROFILE_MOBILE; + break; + case 'w': + case 'W': + profile = TIZEN_PROFILE_WEARABLE; + break; + case 't': + case 'T': + profile = TIZEN_PROFILE_TV; + break; + case 'i': + case 'I': + profile = TIZEN_PROFILE_IVI; + break; + default: // common or unknown ==> ALL ARE COMMON. + profile = TIZEN_PROFILE_COMMON; + } + free(profileName); + + return profile; +} \ No newline at end of file diff --git a/src/common.h b/src/common.h index 1f8a96c..0fe6bc2 100644 --- a/src/common.h +++ b/src/common.h @@ -66,4 +66,16 @@ int config_parse(const char *file_name, int cb(struct parse_result *result, void *data), void *user_data); +typedef enum { + TIZEN_PROFILE_UNKNOWN = 0, + TIZEN_PROFILE_MOBILE = 0x1, + TIZEN_PROFILE_WEARABLE = 0x2, + TIZEN_PROFILE_TV = 0x4, + TIZEN_PROFILE_IVI = 0x8, + TIZEN_PROFILE_COMMON = 0x10, +} tizen_profile_t; +extern tizen_profile_t _get_tizen_profile(); + +#define TIZEN_FEATURE_TRACKER (_get_tizen_profile() == TIZEN_PROFILE_TV) + #endif /* __COMMON_H__ */ diff --git a/src/power.c b/src/power.c index 7e7cc30..fa72469 100644 --- a/src/power.c +++ b/src/power.c @@ -21,10 +21,7 @@ #include #include #include - -#ifdef TIZEN_FEATURE_TRACKER #include -#endif /* TIZEN_FEATURE_TRACKER */ #include "power.h" #include "display.h" @@ -75,15 +72,12 @@ #define POWER_CONF "/etc/deviced/device/power.conf" -#ifdef TIZEN_FEATURE_TRACKER static guint off_lock_timeout; static guint padding_timeout; static int prev_count; static GList *request_id_list; -#endif - static struct _lock_timeout { unsigned int release; unsigned int padding; @@ -107,9 +101,10 @@ static char *get_state_str(display_state_e state) return NULL; } -#ifdef TIZEN_FEATURE_TRACKER static void remove_off_lock_timeout(void) { + if (!TIZEN_FEATURE_TRACKER) + return; if (off_lock_timeout) { _I("Power lock timeout handler removed"); g_source_remove(off_lock_timeout); @@ -119,6 +114,8 @@ static void remove_off_lock_timeout(void) static void remove_padding_timeout(void) { + if (!TIZEN_FEATURE_TRACKER) + return; if (padding_timeout) { _I("Padding timeout handler removed"); g_source_remove(padding_timeout); @@ -296,6 +293,9 @@ static void add_off_lock_timeout(void) { guint id; + if (!TIZEN_FEATURE_TRACKER) + return; + remove_off_lock_timeout(); remove_padding_timeout(); @@ -308,11 +308,6 @@ static void add_off_lock_timeout(void) else _E("Failed to add Power Lock timeout handler"); } -#else -#define add_off_lock_timeout() do {} while (0) -#define remove_off_lock_timeout() do {} while (0) -#define remove_padding_timeout() do {} while (0) -#endif /* TIZEN_FEATURE_TRACKER */ static void lock_cb(void *data, GVariant *result, GError *err) { -- 2.7.4