Remove Profile Build Dependenceis: do it at runtime 38/99138/4
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 22 Nov 2016 04:47:36 +0000 (13:47 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 26 Jan 2017 01:25:02 +0000 (10:25 +0900)
- 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.

ps. added a code clean in spec file that removes a lot of rpmbuild
warnings:
...
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
[   30s] Warning: spec file parser  line 58: macro too deeply nested
...

Change-Id: I5c850a788826cc0cda1f1bf12dde7fc5df036271
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
configure.ac
packaging/e-mod-tizen-wm-policy.spec
src/Makefile.am
src/e_mod_main.c
src/e_mod_main.h

index bb0e86d..a8f4e76 100644 (file)
@@ -43,6 +43,10 @@ PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment])
 AC_SUBST(ENLIGHTENMENT_CFLAGS)
 AC_SUBST(ENLIGHTENMENT_LIBS)
 
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, [capi-system-info])
+AC_SUBST(CAPI_SYSTEM_INFO_CFLAGS)
+AC_SUBST(CAPI_SYSTEM_INFO_LIBS)
+
 # Checks for ttrace header files
 PKG_CHECK_MODULES(TTRACE,
                [ttrace],
@@ -67,20 +71,6 @@ if test "x${have_wayland_only}" != "xno"; then
   AC_DEFINE_UNQUOTED([HAVE_WAYLAND],[1],[enable wayland support])
 fi
 
-# IVI-HOME support
-enable_ivi_home=no
-AC_ARG_ENABLE([ivi-home],
-  [AS_HELP_STRING([--enable-ivi-home], [support ivi-home @<:@default=disabled@:>@])],
-  [enable_ivi_home=yes],
-  [enable_ivi_home=no])
-AC_MSG_CHECKING([whether ivi-home is enabled])
-AC_MSG_RESULT([${enable_ivi_home}])
-if test "x${enable_ivi_home}" == "xyes"; then
-  AC_DEFINE_UNQUOTED([ENABLE_IVI_HOME],[1],[enable ivi-home])
-fi
-AM_CONDITIONAL(ENABLE_IVI_HOME, [test "x${enable_ivi_home}" = xyes])
-# end of  IVI_HOME support
-
 #### WM Rotation
 want_auto_rotation=
 have_auto_rotation=
index c6c70bf..105a0b1 100644 (file)
@@ -20,8 +20,13 @@ BuildRequires: pkgconfig(eina)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(edje)
 %endif
+BuildRequires: pkgconfig(capi-system-info)
 
-%global TZ_SYS_RO_SHARE  %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share}
+%if 0%{?TZ_SYS_RO_SHARE:1}
+# TZ_SYS_RO_SHARE is defined
+%else
+%global TZ_SYS_RO_SHARE /usr/share
+%endif
 
 %description
 The Enlightenment WM Policy Module for Tizen
@@ -33,9 +38,6 @@ The Enlightenment WM Policy Module for Tizen
 export CFLAGS+=" -DE_LOGGING=1 -Werror-implicit-function-declaration"
 %if %{with wayland}
 %reconfigure \
-%if "%{profile}" == "ivi"
-      --enable-ivi-home \
-%endif
       --enable-wayland-only \
       --enable-auto-rotation
 %else
index 7b07435..f4c90b5 100644 (file)
@@ -12,10 +12,8 @@ pkg_LTLIBRARIES        = module.la
 
 WL_SRC   =
 
-if ENABLE_IVI_HOME
 WL_SRC   += e_mod_ivi_home.c \
            e_mod_ivi_home.h
-endif
 
 ROT_SRC  = rotation/e_mod_rotation.c \
            rotation/e_mod_rotation.h \
@@ -40,8 +38,8 @@ module_la_SOURCES      = e_mod_config.c \
                          $(ROT_SRC)
 
 module_la_LIBADD       =
-module_la_CFLAGS       = @ENLIGHTENMENT_CFLAGS@  @TTRACE_CFLAGS@
-module_la_LDFLAGS      = -module -avoid-version @ENLIGHTENMENT_LIBS@ @TTRACE_LIBS@
+module_la_CFLAGS       = @ENLIGHTENMENT_CFLAGS@  @TTRACE_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@
+module_la_LDFLAGS      = -module -avoid-version @ENLIGHTENMENT_LIBS@ @TTRACE_LIBS@ @CAPI_SYSTEM_INFO_LIBS@
 module_la_DEPENDENCIES = $(top_builddir)/config.h
 
 if HAVE_AUTO_ROTATION
index 09d96d6..5f5ec7e 100644 (file)
@@ -1,13 +1,57 @@
 #include "e_mod_main.h"
 #include "e_mod_rotation.h"
-#if ENABLE_IVI_HOME
-# include "e_mod_ivi_home.h"
-#endif
+#include "e_mod_ivi_home.h"
+#include <stdlib.h>
+#include <system_info.h>
 
 E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Policy-Mobile" };
 
 Mod *_pol_mod = NULL;
 
+static Tz_Profile_Type
+_tz_profile_type_get(void)
+{
+   static Tz_Profile_Type p = TZ_PROFILE_TYPE_UNKNOWN;
+   char *name = NULL;
+
+   if (EINA_LIKELY(p != TZ_PROFILE_TYPE_UNKNOWN))
+     {
+        return p;
+     }
+
+   system_info_get_platform_string("http://tizen.org/feature/profile",
+                                   &name);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(name, p);
+
+   switch (*name)
+     {
+      case 'm':
+      case 'M':
+         p = TZ_PROFILE_TYPE_MOBILE;
+         break;
+      case 'w':
+      case 'W':
+         p = TZ_PROFILE_TYPE_WEARABLE;
+         break;
+      case 't':
+      case 'T':
+         p = TZ_PROFILE_TYPE_TV;
+         break;
+      case 'i':
+      case 'I':
+         p = TZ_PROFILE_TYPE_IVI;
+         break;
+      default: // common or unknown ==> ALL ARE COMMON.
+         p = TZ_PROFILE_TYPE_COMMON;
+         break;
+     }
+
+   free(name);
+
+   return p;
+}
+
+
 E_API void *
 e_modapi_init(E_Module *m)
 {
@@ -24,9 +68,8 @@ e_modapi_init(E_Module *m)
 
    e_mod_pol_conf_init(mod);
    e_mod_pol_rotation_init();
-#if ENABLE_IVI_HOME
-   e_mod_ivi_home_init();
-#endif
+   if (_tz_profile_type_get() == TZ_PROFILE_TYPE_IVI)
+     e_mod_ivi_home_init();
 
    return mod;
 }
@@ -38,9 +81,8 @@ e_modapi_shutdown(E_Module *m)
 
    e_mod_pol_rotation_shutdown();
    e_mod_pol_conf_shutdown(mod);
-#if ENABLE_IVI_HOME
-   e_mod_ivi_home_shutdown();
-#endif
+   if (_tz_profile_type_get() == TZ_PROFILE_TYPE_IVI)
+     e_mod_ivi_home_shutdown();
    E_FREE(mod);
    _pol_mod = NULL;
    return 1;
index 2fbcdba..58cfbf1 100644 (file)
@@ -25,6 +25,16 @@ struct _Mod
    Config          *conf;
 };
 
+typedef enum
+{
+   TZ_PROFILE_TYPE_UNKNOWN  = 0,
+   TZ_PROFILE_TYPE_MOBILE   = 0x1,
+   TZ_PROFILE_TYPE_WEARABLE = 0x2,
+   TZ_PROFILE_TYPE_TV       = 0x4,
+   TZ_PROFILE_TYPE_IVI      = 0x8,
+   TZ_PROFILE_TYPE_COMMON   = 0x10,
+} Tz_Profile_Type;
+
 #undef E_CLIENT_HOOK_APPEND
 #define E_CLIENT_HOOK_APPEND(l, t, cb, d) \
   do                                      \