From 9c32dc0b83a7bf8a67ec22c25a14eea0e82cdf99 Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Mon, 1 Aug 2016 17:25:04 +0100 Subject: [PATCH] Platform specific resource locations for dali demos "res" directory houses resources like images, models and videos. Change-Id: I7af9c4b1cf3aac06feb06113104c7f8fbc48867d --- build/tizen/CMakeLists.txt | 24 ++++++++++++++++-------- build/tizen/demo/CMakeLists.txt | 6 ++++++ build/tizen/examples/CMakeLists.txt | 3 +++ build/tizen/resources-location.in | 8 ++++++++ packaging/com.samsung.dali-demo.spec | 19 +++++++++++-------- resources/style/demo-theme.json.in | 7 +------ resources/style/style-example-theme-two.json.in | 14 +++++++------- 7 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 build/tizen/resources-location.in diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 89df63b..d7bc887 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -5,17 +5,22 @@ SET(dali-demo_VERSION_MAJOR 1) SET(dali-demo_VERSION_MINOR 0) SET(ROOT_SRC_DIR ${CMAKE_SOURCE_DIR}/../..) +SET(DEMO_SHARED ${CMAKE_SOURCE_DIR}/../../shared) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) IF(DEFINED DALI_APP_DIR) - SET(APP_DATA_DIR ${DALI_APP_DIR}) - SET(BINDIR ${APP_DATA_DIR}/bin) + SET(BINDIR ${DALI_APP_DIR}/bin) ELSE() - SET(APP_DATA_DIR ${PREFIX}/share/com.samsung.dali-demo) SET(BINDIR ${PREFIX}/bin) ENDIF() +IF(DEFINED DALI_APP_RES_DIR) + SET(APP_DATA_RES_DIR ${DALI_APP_RES_DIR}) +ELSE() + SET(APP_DATA_RES_DIR ${PREFIX}/share/com.samsung.dali-demo/res) +ENDIF() + MESSAGE( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} ) if(CMAKE_BUILD_TYPE MATCHES Debug) MESSAGE("Setting variable: DEBUG_ENABLED") @@ -31,11 +36,11 @@ IF(NOT DEFINED LOCAL_STYLE_DIR) SET(LOCAL_STYLE_DIR ${RESOURCE_DIR}/style) ENDIF() -SET(IMAGES_DIR ${APP_DATA_DIR}/images/) -SET(VIDEOS_DIR ${APP_DATA_DIR}/videos/) -SET(MODELS_DIR ${APP_DATA_DIR}/models/) -SET(SCRIPTS_DIR ${APP_DATA_DIR}/scripts/) -SET(STYLE_DIR ${APP_DATA_DIR}style/) +SET(IMAGES_DIR ${APP_DATA_RES_DIR}/images/) +SET(VIDEOS_DIR ${APP_DATA_RES_DIR}/videos/) +SET(MODELS_DIR ${APP_DATA_RES_DIR}/models/) +SET(SCRIPTS_DIR ${APP_DATA_RES_DIR}/scripts/) +SET(STYLE_DIR ${APP_DATA_RES_DIR}/style/) IF(NOT DEFINED LOCALE_DIR) SET(LOCALE_DIR ${PREFIX}/share/locale) @@ -83,6 +88,9 @@ FOREACH(flag ${LOCAL_SCRIPTS_LIST}) INSTALL(FILES ${LOCAL_SCRIPTS_DIR}/${flag} DESTINATION ${SCRIPTS_DIR}) ENDFOREACH(flag) +#Create resources location file +CONFIGURE_FILE( resources-location.in ${DEMO_SHARED}/resources-location.cpp ) + #Replace @DEMO_STYLE_IMAGE_DIR@ in following files CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/demo-theme.json.in ${LOCAL_STYLE_DIR}/demo-theme.json ) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-one.json.in ${LOCAL_STYLE_DIR}/style-example-theme-one.json ) diff --git a/build/tizen/demo/CMakeLists.txt b/build/tizen/demo/CMakeLists.txt index affd620..6aaf032 100644 --- a/build/tizen/demo/CMakeLists.txt +++ b/build/tizen/demo/CMakeLists.txt @@ -2,6 +2,12 @@ SET(DEMO_SRC_DIR ${ROOT_SRC_DIR}/demo) AUX_SOURCE_DIRECTORY(${DEMO_SRC_DIR} DEMO_SRCS) + +IF(NOT DEFINED DALI_APP_RES_DIR) + message([STATUS] "Setting application resource path from resource-location file") + SET( DEMO_SRCS ${DEMO_SRCS} "${ROOT_SRC_DIR}/shared/resources-location.cpp") +ENDIF() + ADD_EXECUTABLE(${PROJECT_NAME} ${DEMO_SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${REQUIRED_PKGS_LDFLAGS} -pie) diff --git a/build/tizen/examples/CMakeLists.txt b/build/tizen/examples/CMakeLists.txt index 7fa03fe..cc1183a 100644 --- a/build/tizen/examples/CMakeLists.txt +++ b/build/tizen/examples/CMakeLists.txt @@ -15,6 +15,9 @@ SUBDIRLIST(SUBDIRS ${EXAMPLES_SRC_DIR}) FOREACH(EXAMPLE ${SUBDIRS}) FILE(GLOB SRCS "${EXAMPLES_SRC_DIR}/${EXAMPLE}/*.cpp") + IF(NOT DEFINED DALI_APP_RES_DIR) + SET( DEMO_SRCS ${DEMO_SRCS} "${ROOT_SRC_DIR}/shared/resources-location.cpp") + ENDIF() ADD_EXECUTABLE(${EXAMPLE}.example ${SRCS}) TARGET_LINK_LIBRARIES(${EXAMPLE}.example ${REQUIRED_PKGS_LDFLAGS} -pie) INSTALL(TARGETS ${EXAMPLE}.example DESTINATION ${BINDIR}) diff --git a/build/tizen/resources-location.in b/build/tizen/resources-location.in new file mode 100644 index 0000000..89b0b87 --- /dev/null +++ b/build/tizen/resources-location.in @@ -0,0 +1,8 @@ +/** + * This file defines the location dali-demo resources + It is used exclusively for Ubuntu builds where an application resource directory is explicity defined. + */ + +#include + +int dali_demo_RESOURCE_DIR = setenv("DALI_APPLICATION_PACKAGE", "@APP_DATA_RES_DIR@" , 1); diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index c138b83..d0a49b2 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -53,8 +53,9 @@ of the capability of the toolkit. %define smack_rule_dir %TZ_SYS_SMACK/accesses2.d/ %endif +%define dali_app_res_dir %{dali_app_ro_dir}/res/ %define dali_app_exe_dir %{dali_app_ro_dir}/bin/ -%define locale_dir %{dali_app_ro_dir}/res/locale +%define locale_dir %{dali_app_res_dir}/locale %define local_style_dir ../../resources/style/mobile ############################## @@ -73,6 +74,7 @@ cd %{_builddir}/%{name}-%{version}/build/tizen cmake -DDALI_APP_DIR=%{dali_app_ro_dir} \ -DLOCALE_DIR=%{locale_dir} \ + -DDALI_APP_RES_DIR=%{dali_app_res_dir} \ %if 0%{?enable_debug} -DCMAKE_BUILD_TYPE=Debug \ %endif @@ -89,12 +91,13 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} cd build/tizen %make_install DALI_APP_DIR=%{dali_app_ro_dir} +%make_install DDALI_APP_RES_DIR=%{dali_app_res_dir} mkdir -p %{buildroot}%{dali_xml_file_dir} cp -f %{_builddir}/%{name}-%{version}/%{name}.xml %{buildroot}%{dali_xml_file_dir} mkdir -p %{buildroot}%{dali_icon_dir} -mv %{buildroot}/%{dali_app_ro_dir}/images/%{name}.png %{buildroot}%{dali_icon_dir} +mv %{buildroot}/%{dali_app_res_dir}/images/%{name}.png %{buildroot}%{dali_icon_dir} %if 0%{?enable_dali_smack_rules} && !%{with wayland} mkdir -p %{buildroot}%{smack_rule_dir} @@ -133,12 +136,12 @@ exit 0 %{dali_app_exe_dir}/dali-demo %{dali_app_exe_dir}/*.example %{dali_app_exe_dir}/dali-builder -%{dali_app_ro_dir}/images/* -%{dali_app_ro_dir}/videos/* -%{dali_app_ro_dir}/models/* -%{dali_app_ro_dir}/scripts/* -%{dali_app_ro_dir}/style/* -%{dali_app_ro_dir}/style/images/* +%{dali_app_res_dir}/images/* +%{dali_app_res_dir}/videos/* +%{dali_app_res_dir}/models/* +%{dali_app_res_dir}/scripts/* +%{dali_app_res_dir}/style/* +%{dali_app_res_dir}/style/images/* %{dali_xml_file_dir}/%{name}.xml %{dali_icon_dir}/* %{locale_dir}/* diff --git a/resources/style/demo-theme.json.in b/resources/style/demo-theme.json.in index 3e680ba..21e0f2e 100644 --- a/resources/style/demo-theme.json.in +++ b/resources/style/demo-theme.json.in @@ -15,15 +15,10 @@ */ { - "constants": - { - "DEMO_IMAGE_DIR":"@DEMO_STYLE_IMAGE_DIR@" - }, - "styles": { "confirmationpopup":{ - "popupBackgroundImage":"{DEMO_IMAGE_DIR}00_popup_bg.9.png" + "popupBackgroundImage":"{APPLICATION_RESOURCE_PATH}/images/00_popup_bg.9.png" }, "textlabel-Rosemary": diff --git a/resources/style/style-example-theme-two.json.in b/resources/style/style-example-theme-two.json.in index 884d1ca..61c78a9 100644 --- a/resources/style/style-example-theme-two.json.in +++ b/resources/style/style-example-theme-two.json.in @@ -1,7 +1,7 @@ { "constants": { - "DEMO_IMAGE_DIR":"@DEMO_STYLE_IMAGE_DIR@" + "STYLE_DIR":"{APPLICATION_RESOURCE_PATH}/style" }, "styles": { @@ -25,9 +25,9 @@ // Change an icon size, see if it gets properly re-sized "radiobutton":{ - "unselectedStateImage":"{DEMO_IMAGE_DIR}/radio-button-unselected.png", - "selectedStateImage":"{DEMO_IMAGE_DIR}/radio-button-selected.png", - "disabledStateImage":"{DEMO_IMAGE_DIR}/radio-button-unselected-disabled.png", + "unselectedStateImage":"{STYLE_DIR}/images/radio-button-unselected.png", + "selectedStateImage":"{STYLE_DIR}/images/radio-button-selected.png", + "disabledStateImage":"{STYLE_DIR}/images/radio-button-unselected-disabled.png", "imageLabelGap":10, "label":{ "textColor": [0.1,1,1,1] @@ -78,19 +78,19 @@ "colorSlider1":{ "styles":["thinslider"], "progressVisual":{ - "url":"{DEMO_IMAGE_DIR}/slider-skin-progress-red.9.png" + "url":"{STYLE_DIR}/images/slider-skin-progress-red.9.png" } }, "colorSlider2":{ "styles":["thinslider"], "progressVisual":{ - "url":"{DEMO_IMAGE_DIR}/slider-skin-progress-green.9.png" + "url":"{STYLE_DIR}/images/slider-skin-progress-green.9.png" } }, "colorSlider3":{ "styles":["thinslider"], "progressVisual":{ - "url":"{DEMO_IMAGE_DIR}/slider-skin-progress-blue.9.png" + "url":"{STYLE_DIR}/images/slider-skin-progress-blue.9.png" } } } -- 2.7.4