Set environment variables 70/72870/3 accepted/tizen/common/20160607.194644 accepted/tizen/ivi/20160607.235327 accepted/tizen/mobile/20160607.235300 accepted/tizen/tv/20160607.235319 accepted/tizen/wearable/20160607.235310 submit/tizen/20160607.082137
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 3 Jun 2016 00:08:07 +0000 (09:08 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 6 Jun 2016 23:57:21 +0000 (08:57 +0900)
- Add WAYLAND_DISPLAY and XDG_RUNTIME_DIR, TIZEN_API_VERSION
to the environment for using wayland
- Add LD_LIBRARY_PATH to the environment for backward compatibility

Change-Id: I9d6526da9ca398ebb04346eb577080a91b01241a
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/defs.h
src/common.c

index 024555b..698c2a7 100644 (file)
@@ -32,6 +32,9 @@
 #define AUL_K_CALLER_PID "__AUL_CALLER_PID__"
 #define AUL_K_COMP_TYPE "__AUL_COMP_TYPE__"
 #define AUL_K_PRIVACY_APPID "__AUL_PRIVACY_APPID__"
+#define AUL_K_WAYLAND_DISPLAY "__AUL_WAYLAND_DISPLAY__"
+#define AUL_K_WAYLAND_WORKING_DIR "__AUL_WAYLAND_WORKING_DIR__"
+#define AUL_K_API_VERSION "__AUL_API_VERSION__"
 
 #define SDK_CODE_COVERAGE "CODE_COVERAGE"
 #define SDK_DEBUG "DEBUG"
index 23fae86..25e7aec 100644 (file)
@@ -449,6 +449,28 @@ void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *appinfo, int cmd)
        }
 }
 
+static char *__get_libdir(const char *path)
+{
+       char *path_dup;
+       char buf[PATH_MAX];
+       char *ptr;
+
+       path_dup = strdup(path);
+       if (path_dup == NULL)
+               return NULL;
+
+       ptr = strrchr(path_dup, '/');
+       *ptr = '\0';
+
+       snprintf(buf, sizeof(buf), "%s/../lib/", path_dup);
+       free(path_dup);
+
+       if (access(buf, F_OK) == -1)
+               return NULL;
+
+       return strdup(buf);
+}
+
 static void __set_sdk_env(const char *appid, const char *value)
 {
        char buf[MAX_LOCAL_BUFSZ];
@@ -479,6 +501,7 @@ void _set_env(appinfo_t *appinfo, bundle *kb)
        const char **str_array = NULL;
        int len = 0;
        int i;
+       char *libdir;
 
        setenv("PKG_NAME", appinfo->appid, 1);
 
@@ -490,9 +513,27 @@ void _set_env(appinfo_t *appinfo, bundle *kb)
        if (appinfo->taskmanage)
                setenv("TASKMANAGE", appinfo->taskmanage, 1);
 
-       if (bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY)
+       str = bundle_get_val(kb, AUL_K_WAYLAND_DISPLAY);
+       if (str)
+               setenv("WAYLAND_DISPLAY", str, 1);
+
+       str = bundle_get_val(kb, AUL_K_WAYLAND_WORKING_DIR);
+       if (str)
+               setenv("XDG_RUNTIME_DIR", str, 1);
+
+       str = bundle_get_val(kb, AUL_K_API_VERSION);
+       if (str)
+               setenv("TIZEN_API_VERSION", str, 1);
+
+       libdir = __get_libdir(appinfo->app_path);
+       if (libdir) {
+               setenv("LD_LIBRARY_PATH", libdir, 1);
+               free(libdir);
+       }
+
+       if (bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
                str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
-       else {
+       else {
                str = bundle_get_val(kb, AUL_K_SDK);
                if (str) {
                        str_array = &str;