From f980cef006a30176f5096a16baef6a67ef8df9a7 Mon Sep 17 00:00:00 2001 From: su-ex Date: Sat, 29 May 2021 15:07:59 +0200 Subject: [PATCH] Add option to regenerate i18n, add make target for it, move stuff around, cleanup --- Makefile | 15 +++++++-------- merge_helpers.sh | 43 ++++++++++++++++++++++++++++++++++++++++++- merge_upstream.sh | 42 ++++++++---------------------------------- regenerate_i18n.sh | 25 +++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 43 deletions(-) create mode 100755 regenerate_i18n.sh diff --git a/Makefile b/Makefile index 10cbb35..9e111bc 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -.PHONY: all setup reskindex web desktop desktop-common linux debian pacman local-pkgbuild local-pkgbuild-install windows windows-portable -.PHONY: web-release debian-release pacman-release windows-setup-release windows-unpacked-release windows-portable-release windows-release release +.PHONY: all setup regenerate-i18n reskindex web desktop-common linux debian pacman local-pkgbuild local-pkgbuild-install windows windows-portable +.PHONY: web-release debian-release pacman-release windows-setup-release windows-unpacked-release windows-portable-release windows-release .PHONY: clean CFGDIR ?= configs/sc -all: release +all: web YARN ?= yarnpkg @@ -37,7 +37,9 @@ CURRENT_RELEASE_DIR := $(RELEASE_DIR)/$(VERSION) setup: if [ ! -L "element-desktop/webapp" ]; then ./setup.sh; fi - cp $(CFGDIR)/config.json element-web/ + +regenerate-i18n: setup + ./regenerate_i18n.sh reskindex: setup $(YARN) --cwd matrix-react-sdk reskindex @@ -45,6 +47,7 @@ reskindex: setup web: export DIST_VERSION=$(WEB_OUT_DIST_VERSION) web: setup reskindex + cp $(CFGDIR)/config.json element-web/ $(YARN) --cwd element-web dist echo "$(VERSION)" > element-web/webapp/version @@ -52,8 +55,6 @@ desktop-common: web $(YARN) --cwd element-desktop run fetch --cfgdir '' $(YARN) --cwd element-desktop run build:native -desktop: windows linux - linux: desktop-common $(YARN) --cwd element-desktop run build64linux @@ -114,8 +115,6 @@ macos-release: macos mkdir -p $(CURRENT_RELEASE_DIR) cp $(OUT_MACOS) $(CURRENT_RELEASE_DIR) -release: web-release debian-release pacman-release windows-release - clean: $(YARN) --cwd matrix-js-sdk clean $(YARN) --cwd matrix-react-sdk clean diff --git a/merge_helpers.sh b/merge_helpers.sh index ee3ecc4..a0d4bd4 100755 --- a/merge_helpers.sh +++ b/merge_helpers.sh @@ -2,6 +2,10 @@ SCHILDI_ROOT="$(dirname "$(realpath "$0")")" +i18n_helper_path="$SCHILDI_ROOT/i18n-helper/index.js" +i18n_path="src/i18n/strings" +i18n_overlay_path="$SCHILDI_ROOT/i18n-overlays" + add_upstream() { if git remote | grep -q upstream; then echo "Remote named upstream already exists!" @@ -64,9 +68,13 @@ check_clean_git() { revert_i18n_changes() { local i18n_path="$1" + local skip_commit="$2" git checkout upstream/master -- "$i18n_path" - git commit -m "Automatic i18n reversion" || true + + if [[ "$skip_commit" != [Yy]* ]]; then + git commit -m "Automatic i18n reversion" || true + fi } apply_i18n_changes() { @@ -75,3 +83,36 @@ apply_i18n_changes() { git add "$i18n_path" git commit -m "Automatic i18n adjustment" || true } + +automatic_i18n_reversion() { + local skip_commit="$1" + + pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null + revert_i18n_changes "$i18n_path" $skip_commit + popd > /dev/null + + pushd "$SCHILDI_ROOT/element-web" > /dev/null + revert_i18n_changes "$i18n_path" $skip_commit + popd > /dev/null + + pushd "$SCHILDI_ROOT/element-desktop" > /dev/null + revert_i18n_changes "$i18n_path" $skip_commit + popd > /dev/null +} + +automatic_i18n_adjustment() { + node "$i18n_helper_path" "$SCHILDI_ROOT/matrix-react-sdk/$i18n_path" "$i18n_overlay_path/matrix-react-sdk" + pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null + apply_i18n_changes "$i18n_path" + popd > /dev/null + + node "$i18n_helper_path" "$SCHILDI_ROOT/element-web/$i18n_path" "$i18n_overlay_path/element-web" + pushd "$SCHILDI_ROOT/element-web" > /dev/null + apply_i18n_changes "$i18n_path" + popd > /dev/null + + node "$i18n_helper_path" "$SCHILDI_ROOT/element-desktop/$i18n_path" "$i18n_overlay_path/element-desktop" + pushd "$SCHILDI_ROOT/element-desktop" > /dev/null + apply_i18n_changes "$i18n_path" + popd > /dev/null +} diff --git a/merge_upstream.sh b/merge_upstream.sh index 42f001d..db2b383 100755 --- a/merge_upstream.sh +++ b/merge_upstream.sh @@ -5,60 +5,34 @@ set -e mydir="$(dirname "$(realpath "$0")")" branch=${BRANCH:-"sc"} -i18n_helper="node i18n-helper/index.js" -i18n_path="src/i18n/strings" -i18n_overlay_path="i18n-overlays" - pushd "$mydir" > /dev/null source ./merge_helpers.sh +# Check branch check_branch $branch forall_repos check_branch $branch -# check_clean_git +# Ensure clean git state forall_repos check_clean_git # Automatic i18n reversion -pushd "matrix-react-sdk" > /dev/null -revert_i18n_changes "$i18n_path" -popd > /dev/null - -pushd "element-web" > /dev/null -revert_i18n_changes "$i18n_path" -popd > /dev/null - -pushd "element-desktop" > /dev/null -revert_i18n_changes "$i18n_path" -popd > /dev/null +automatic_i18n_reversion # Merge forall_repos git fetch upstream forall_repos git merge upstream/master +# Refresh environment +make clean +make setup + # Automatic i18n adjustment -$i18n_helper "matrix-react-sdk/$i18n_path" "$i18n_overlay_path/matrix-react-sdk" -pushd "matrix-react-sdk" > /dev/null -apply_i18n_changes "$i18n_path" -popd > /dev/null - -$i18n_helper "element-web/$i18n_path" "$i18n_overlay_path/element-web" -pushd "element-web" > /dev/null -apply_i18n_changes "$i18n_path" -popd > /dev/null - -$i18n_helper "element-desktop/$i18n_path" "$i18n_overlay_path/element-desktop" -pushd "element-desktop" > /dev/null -apply_i18n_changes "$i18n_path" -popd > /dev/null +automatic_i18n_adjustment # Automatic theme update pushd "matrix-react-sdk" > /dev/null ./theme.sh popd > /dev/null -# Refresh environment -make clean -make setup - popd > /dev/null diff --git a/regenerate_i18n.sh b/regenerate_i18n.sh new file mode 100755 index 0000000..8c13ab6 --- /dev/null +++ b/regenerate_i18n.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +mydir="$(dirname "$(realpath "$0")")" +branch=${BRANCH:-"sc"} + +pushd "$mydir" > /dev/null + +source ./merge_helpers.sh + +# Check branch +check_branch $branch +forall_repos check_branch $branch + +# Ensure clean git state +forall_repos check_clean_git + +# Automatic i18n reversion +automatic_i18n_reversion y + +# Automatic i18n adjustment +automatic_i18n_adjustment + +popd > /dev/null