From 5f009524a38b9d69768d062d150d6258f92d5d06 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 16:08:24 +0300 Subject: [PATCH 1/9] Add user enviroment for localization script --- xcode/build_phases/localization.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xcode/build_phases/localization.sh b/xcode/build_phases/localization.sh index dea12e3..e277f58 100644 --- a/xcode/build_phases/localization.sh +++ b/xcode/build_phases/localization.sh @@ -19,6 +19,8 @@ # . localization.sh common/strings Resources/Localization/ .main # +. ${SCRIPT_DIR}/../aux_scripts/install_env.sh php + STRINGS_FOLDER=${1:-"common/strings"} LOCALIZATION_PATH=${2:-"${PRODUCT_NAME}/Resources/Localization/"} BUNDLE=${3:-".main"} From 6b21a9845a411d428101b32bb5d3698997608a97 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 16:13:46 +0300 Subject: [PATCH 2/9] Add php installation check --- xcode/build_phases/localization.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xcode/build_phases/localization.sh b/xcode/build_phases/localization.sh index e277f58..7d6b3b2 100644 --- a/xcode/build_phases/localization.sh +++ b/xcode/build_phases/localization.sh @@ -35,4 +35,10 @@ if ! [ -e "${STRINGS_FOLDER}" ]; then exit 1 fi -php ${SCRIPT_DIR}/../aux_scripts/import_strings.php ${LOCALIZATION_PATH} ${STRINGS_FOLDER} ${BUNDLE} +if which php >/dev/null; then + php ${SCRIPT_DIR}/../aux_scripts/import_strings.php ${LOCALIZATION_PATH} ${STRINGS_FOLDER} ${BUNDLE} +else + echo "warning: php not installed, install using 'brew install php'" + + exit ${EXIT_FAILURE} +fi \ No newline at end of file From 1db4cfc771f8c077e029371a493c6c1e3af13c0e Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 16:18:04 +0300 Subject: [PATCH 3/9] Fix identation --- xcode/build_phases/localization.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcode/build_phases/localization.sh b/xcode/build_phases/localization.sh index 7d6b3b2..0c75ebe 100644 --- a/xcode/build_phases/localization.sh +++ b/xcode/build_phases/localization.sh @@ -38,7 +38,7 @@ fi if which php >/dev/null; then php ${SCRIPT_DIR}/../aux_scripts/import_strings.php ${LOCALIZATION_PATH} ${STRINGS_FOLDER} ${BUNDLE} else - echo "warning: php not installed, install using 'brew install php'" + echo "warning: php not installed, install using 'brew install php'" - exit ${EXIT_FAILURE} + exit ${EXIT_FAILURE} fi \ No newline at end of file From 22abe5a7925437664cb3c00f6c01b8d02ccaede4 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 16:19:44 +0300 Subject: [PATCH 4/9] Add failure exit code --- xcode/build_phases/localization.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xcode/build_phases/localization.sh b/xcode/build_phases/localization.sh index 0c75ebe..3229498 100644 --- a/xcode/build_phases/localization.sh +++ b/xcode/build_phases/localization.sh @@ -19,6 +19,9 @@ # . localization.sh common/strings Resources/Localization/ .main # +readonly EXIT_SUCCESS=0 +readonly EXIT_FAILURE=1 + . ${SCRIPT_DIR}/../aux_scripts/install_env.sh php STRINGS_FOLDER=${1:-"common/strings"} From 2ec3289b5b9d4d056f71520f24b0688dbb3ba3e4 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 17:37:09 +0300 Subject: [PATCH 5/9] Fix PR issues from @petropavel13 --- xcode/build_phases/localization.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcode/build_phases/localization.sh b/xcode/build_phases/localization.sh index 3229498..1b3d6e8 100644 --- a/xcode/build_phases/localization.sh +++ b/xcode/build_phases/localization.sh @@ -30,12 +30,12 @@ BUNDLE=${3:-".main"} if ! [ -e ${LOCALIZATION_PATH} ]; then echo "${LOCALIZATION_PATH} path does not exist. Add these folders and try again." - exit 1 + exit ${EXIT_FAILURE} fi if ! [ -e "${STRINGS_FOLDER}" ]; then echo "${STRINGS_FOLDER} path does not exist. Submodule with strings should be named common and contain strings folder." - exit 1 + exit ${EXIT_FAILURE} fi if which php >/dev/null; then From 514524526617d686e9b8781ed4b9473e75f02911 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 20:52:59 +0300 Subject: [PATCH 6/9] Fix executes only export commands --- xcode/aux_scripts/install_env.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xcode/aux_scripts/install_env.sh b/xcode/aux_scripts/install_env.sh index d1c1fc0..c37fdaa 100644 --- a/xcode/aux_scripts/install_env.sh +++ b/xcode/aux_scripts/install_env.sh @@ -1,3 +1,5 @@ +#!/bin/sh + # Description: # Add user defined enviroment if programm not found # @@ -14,7 +16,21 @@ function source_home_file { file="$HOME/$1" - [[ -f "${file}" ]] && source "${file}" + + #echo $file + + if [[ -f "${file}" ]]; then + paathes="$(cat "${file}" | grep "^export PATH=")" + + while read paath + do + eval "$paath" + done <<< "$paathes" + else + return 1 + fi + + return 0 } # Use specific exec due to Xcode has custom value of $PATH From d7acbb0080aec1c32f233780f4fa48976b548b8b Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 20:55:16 +0300 Subject: [PATCH 7/9] Fix variable names --- xcode/aux_scripts/install_env.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xcode/aux_scripts/install_env.sh b/xcode/aux_scripts/install_env.sh index c37fdaa..8f4c6ef 100644 --- a/xcode/aux_scripts/install_env.sh +++ b/xcode/aux_scripts/install_env.sh @@ -17,15 +17,13 @@ function source_home_file { file="$HOME/$1" - #echo $file - if [[ -f "${file}" ]]; then - paathes="$(cat "${file}" | grep "^export PATH=")" + export_commands="$(cat "${file}" | grep "^export PATH=")" - while read paath + while read export_command do - eval "$paath" - done <<< "$paathes" + eval "$export_command" + done <<< "$export_commands" else return 1 fi From d96c126fe2615d6b7469daf6542a87aeb1803beb Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Mon, 6 Dec 2021 21:15:47 +0300 Subject: [PATCH 8/9] Fix adding all paths --- xcode/aux_scripts/install_env.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xcode/aux_scripts/install_env.sh b/xcode/aux_scripts/install_env.sh index 8f4c6ef..2b6feec 100644 --- a/xcode/aux_scripts/install_env.sh +++ b/xcode/aux_scripts/install_env.sh @@ -24,11 +24,9 @@ function source_home_file { do eval "$export_command" done <<< "$export_commands" - else - return 1 fi - return 0 + return 1 } # Use specific exec due to Xcode has custom value of $PATH From 8991f8c2b81cd7f10f800268d0790a6f3b6feb97 Mon Sep 17 00:00:00 2001 From: Aleksandr Shushkov Date: Tue, 7 Dec 2021 16:05:29 +0300 Subject: [PATCH 9/9] Fix PR issues from @petropavel13 --- xcode/aux_scripts/install_env.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xcode/aux_scripts/install_env.sh b/xcode/aux_scripts/install_env.sh index 2b6feec..379c640 100644 --- a/xcode/aux_scripts/install_env.sh +++ b/xcode/aux_scripts/install_env.sh @@ -18,12 +18,14 @@ function source_home_file { file="$HOME/$1" if [[ -f "${file}" ]]; then - export_commands="$(cat "${file}" | grep "^export PATH=")" + if ! source "${file}"; then + export_commands="$(cat "${file}" | grep "^export PATH=")" - while read export_command - do - eval "$export_command" - done <<< "$export_commands" + while read export_command + do + eval "$export_command" + done <<< "$export_commands" + fi fi return 1