Remove Profile Build Dependency: Do it at runtime 33/98433/2 accepted/tizen/common/20161128.064258 accepted/tizen/ivi/20161129.000600 accepted/tizen/mobile/20161129.000506 accepted/tizen/tv/20161129.000523 accepted/tizen/wearable/20161129.000541 submit/tizen/20161128.050026
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 17 Nov 2016 08:56:03 +0000 (17:56 +0900)
committerSeechan Kim <cbible.kim@samsung.com>
Fri, 25 Nov 2016 03:55:27 +0000 (19:55 -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)

- It is recommended to distinguish features/profiles at runtime.
 unless it incurs too much overhead, which requires you to
 create multiple binaries and subpackages.

Change-Id: Ie152163ca83de32b081912e9fce66df55ad91cbe
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
heremaps-uc/CMakeLists.txt
heremaps-uc/src/heremaps-uc.c
packaging/maps-plugin-here.spec

index 6261d20..f6fb07a 100644 (file)
@@ -28,11 +28,6 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
-IF(TIZEN_WEARABLE)
-       MESSAGE(TIZEN_WEARABLE)
-       ADD_DEFINITIONS("-DTIZEN_WEARABLE")
-ENDIF(TIZEN_WEARABLE)
-
 INCLUDE(FindPkgConfig)
 
 # Check external libraries
index bedadbd..48c2130 100644 (file)
  */
 
 #include "heremaps-uc-common.h"
+#include <stdlib.h>
+#include <system_info.h>
 
 #define EDJE_PATH "/usr/apps/org.tizen.heremaps-uc/res/edje/heremaps-uc.edj"
 
+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;
+
+static 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;
+}
+
 static Evas_Object *create_conformant(Evas_Object * parent)
 {
        LS_FUNC_ENTER
@@ -75,7 +119,6 @@ static void save_vconf(int value)
        }
 }
 
-#ifndef TIZEN_WEARABLE
 static void disagree_btn_cb(void *data, Evas_Object * obj, void *event)
 {
        LS_FUNC_ENTER
@@ -84,7 +127,6 @@ static void disagree_btn_cb(void *data, Evas_Object * obj, void *event)
 
        elm_exit();
 }
-#endif
 
 static void agree_btn_cb(void *data, Evas_Object * obj, void *event)
 {
@@ -122,7 +164,6 @@ static Evas_Object *create_win(const char *name)
        return eo;
 }
 
-#ifdef TIZEN_WEARABLE
 static Evas_Object *create_popup_wearable(Evas_Object *layout, heremaps_uc_app_data *ad)
 {
        LS_FUNC_ENTER
@@ -177,7 +218,6 @@ static Evas_Object *create_popup_wearable(Evas_Object *layout, heremaps_uc_app_d
        return popup;
 }
 
-#else
 static Evas_Object *create_popup(Evas_Object *layout, heremaps_uc_app_data *ad)
 {
        LS_FUNC_ENTER
@@ -217,7 +257,6 @@ static Evas_Object *create_popup(Evas_Object *layout, heremaps_uc_app_data *ad)
        LS_FUNC_EXIT
        return popup;
 }
-#endif
 
 static bool _app_create_cb(void *user_data)
 {
@@ -271,11 +310,10 @@ static void _app_control_cb(app_control_h app_control, void *user_data)
        ad->conformant = create_conformant(ad->win_main);
        ad->layout_main = create_layout(ad->conformant);
 
-#ifdef TIZEN_WEARABLE
-       ad->popup = create_popup_wearable(ad->layout_main, ad);
-#else
-       ad->popup = create_popup(ad->layout_main, ad);
-#endif
+       if (_get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
+               ad->popup = create_popup_wearable(ad->layout_main, ad);
+       else
+               ad->popup = create_popup(ad->layout_main, ad);
 
        evas_object_show(ad->win_main);
        LS_FUNC_EXIT
index 985222d..6427511 100644 (file)
@@ -68,11 +68,7 @@ This package provides Plugin APIs capsulating HERE Maps Engine Library for Maps
 %build
 
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%if "%{profile}" == "wearable"
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DLIBDIR=%{_libdir} -DARCH=%{ARCH} -DSYSCONF_DIR=%{_sysconfdir} -DTIZEN_WEARABLE=YES
-%else
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DLIBDIR=%{_libdir} -DARCH=%{ARCH} -DSYSCONF_DIR=%{_sysconfdir}
-%endif
 make %{?jobs:-j%jobs}
 
 %install