From: Hwankyu Jhun Date: Fri, 3 Jun 2016 00:08:07 +0000 (+0900) Subject: Set environment variables X-Git-Tag: submit/tizen/20160607.082137^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3fa515d873720b9ec38ab8af68075d8b35c70374;p=platform%2Fcore%2Fappfw%2Fdebug-launchpad.git Set environment variables - 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 --- diff --git a/include/defs.h b/include/defs.h index 024555b..698c2a7 100644 --- a/include/defs.h +++ b/include/defs.h @@ -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" diff --git a/src/common.c b/src/common.c index 23fae86..25e7aec 100644 --- a/src/common.c +++ b/src/common.c @@ -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;