[4.0] Remove Profile Build Dependencies: do it at runtime 81/99181/5
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 22 Nov 2016 06:26:25 +0000 (15:26 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 17 Jan 2017 01:59:52 +0000 (17:59 -0800)
- 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 <myungjoo.ham@samsung.com>
CMakeLists.txt
packaging/capi-system-device.spec
src/common.c
src/common.h
src/power.c

index feb4090..75181f5 100755 (executable)
@@ -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})
index 28302d0..7cc1169 100644 (file)
@@ -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}
 
index 4936577..63481dc 100644 (file)
@@ -17,6 +17,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <stdlib.h>
+#include <system_info.h>
 #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
index 1f8a96c..0fe6bc2 100644 (file)
@@ -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__ */
index 7e7cc30..fa72469 100644 (file)
 #include <errno.h>
 #include <glib.h>
 #include <limits.h>
-
-#ifdef TIZEN_FEATURE_TRACKER
 #include <tracker.h>
-#endif /* TIZEN_FEATURE_TRACKER */
 
 #include "power.h"
 #include "display.h"
 
 #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)
 {