Remove Profile Build Dependenceis: do it at runtime 84/99184/3
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 22 Nov 2016 06:35:25 +0000 (15:35 +0900)
committerSeechan Kim <cbible.kim@samsung.com>
Thu, 15 Dec 2016 04:07:17 +0000 (20:07 -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: I69bec406414f23086edd4ba4d0ccb173babf5953
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
CMakeLists.txt
packaging/capi-maps-service.spec
src/api/maps_condition.cpp
src/maps_util.cpp
src/maps_util.h

index 43ffc6d..d7cf1e3 100644 (file)
@@ -61,10 +61,6 @@ IF("${ARCH}" STREQUAL "arm")
        ADD_DEFINITIONS("-DTARGET")
 ENDIF("${ARCH}" STREQUAL "arm")
 
-IF("${PROFILE}" STREQUAL "wearable")
-       ADD_DEFINITIONS("-DTIZEN_WEARABLE")
-ENDIF("${PROFILE}" STREQUAL "wearable")
-
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))")
 #ADD_DEFINITIONS("-DTIZEN_DEBUG")
index 29f6169..a633229 100644 (file)
@@ -50,7 +50,7 @@ export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
 
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
-       -DLIBDIR=%{_libdir} -DPROFILE=%{?profile} -DTIZEN_VER=0x030000
+       -DLIBDIR=%{_libdir} -DTIZEN_VER=0x030000
 make %{?jobs:-j%jobs}
 
 %install
index 0936090..d6b0442 100644 (file)
@@ -96,15 +96,13 @@ bool maps_condition_check_maps_feature(void)
 bool maps_condition_check_internet_feature(void)
 {
        static bool is_supported = true;
-#ifdef TIZEN_WEARABLE
        static bool is_read = false;
 
-       if (!is_read) {
+       if (_get_tizen_profile() == TIZEN_PROFILE_WEARABLE && !is_read) {
                system_info_get_platform_bool(INTERNET_FEATURE, &is_supported);
                MAPS_LOGD("internet feature is%ssupported", (is_supported ? " " : " not "));
                is_read = true;
        }
-#endif
        return is_supported;
 }
 
@@ -148,4 +146,4 @@ bool maps_condition_check_view_data_supported(maps_view_h view, maps_service_dat
        if (maps_service_provider_is_data_supported(maps, data, &supported) != MAPS_ERROR_NONE)
                return false;
        return supported;
-}
\ No newline at end of file
+}
index 652e9e0..e3a31b1 100644 (file)
@@ -18,6 +18,7 @@
 #include "maps_error.h"
 #include <glib.h>
 #include <system_info.h>
+#include <stdlib.h>
 
 #define DEFAULT_UNKNOWN_DPI 132
 
@@ -50,3 +51,36 @@ int maps_get_screen_dpi(int *dpi)
        *dpi = __dpi;
        return MAPS_ERROR_NONE;
 }
+
+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;
+}
index 1f08715..74037fe 100755 (executable)
@@ -219,4 +219,13 @@ public:
        }
 };
 
+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();
 #endif                         /* __MAPS_UTIL_H__ */