From 978b93aa640fdccc8621de589ba3b0d707a283b6 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Fri, 24 Mar 2023 14:42:12 +0700 Subject: [PATCH] refactor(common): move keymanversion_build.in to /common/include --- common/include/.gitignore | 2 + common/include/build.sh | 41 +++++++++++++++++++ .../cpp => }/include/keymanversion_build.in | 0 common/windows/cpp/include/.gitignore | 1 - common/windows/cpp/include/keymanversion.h | 2 +- common/windows/delphi/Makefile | 5 +-- developer/src/Makefile | 2 +- developer/src/kmc/build.sh | 1 + windows/src/Makefile | 2 +- windows/src/Target.mak | 2 +- windows/src/global/Makefile | 2 +- 11 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 common/include/.gitignore create mode 100755 common/include/build.sh rename common/{windows/cpp => }/include/keymanversion_build.in (100%) delete mode 100644 common/windows/cpp/include/.gitignore diff --git a/common/include/.gitignore b/common/include/.gitignore new file mode 100644 index 0000000000..39eb38049f --- /dev/null +++ b/common/include/.gitignore @@ -0,0 +1,2 @@ +keymanversion_build.h +.keymanversion_build.configured \ No newline at end of file diff --git a/common/include/build.sh b/common/include/build.sh new file mode 100755 index 0000000000..43d8c51a51 --- /dev/null +++ b/common/include/build.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Creates keymanversion_build.h +# + +# Exit on command failure and when using unset variables: +set -eu + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../resources/build/build-utils.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +cd "$THIS_SCRIPT_PATH" + +builder_describe "Build keymanversion_build.h" configure build clean + +builder_describe_outputs \ + configure /common/include/.keymanversion_build.configured \ + build /common/include/keymanversion_build.h + +builder_parse "$@" + +#------------------------------------------------------------------------------------------------------------------- + +if builder_start_action clean; then + rm -f keymanversion_build.h .keymanversion_build.configured + builder_finish_action success clean +fi + +if builder_start_action configure; then + # no-op, keeping 'configure' for deps + touch .keymanversion_build.configured + builder_finish_action success configure +fi + +if builder_start_action build; then + replaceVersionStrings_Mkver keymanversion_build.in keymanversion_build.h + builder_finish_action success build +fi diff --git a/common/windows/cpp/include/keymanversion_build.in b/common/include/keymanversion_build.in similarity index 100% rename from common/windows/cpp/include/keymanversion_build.in rename to common/include/keymanversion_build.in diff --git a/common/windows/cpp/include/.gitignore b/common/windows/cpp/include/.gitignore deleted file mode 100644 index 69ffc835cd..0000000000 --- a/common/windows/cpp/include/.gitignore +++ /dev/null @@ -1 +0,0 @@ -keymanversion_build.h diff --git a/common/windows/cpp/include/keymanversion.h b/common/windows/cpp/include/keymanversion.h index a35421a2de..e9d39defba 100644 --- a/common/windows/cpp/include/keymanversion.h +++ b/common/windows/cpp/include/keymanversion.h @@ -1,7 +1,7 @@ #ifndef _KEYMANVERSION_H #define _KEYMANVERSION_H -#include "keymanversion_build.h" +#include "../../../include/keymanversion_build.h" // We should not need to add to these hard-coded version numbers for future versions, unless // we have a back-compat need to refer to a specific version. diff --git a/common/windows/delphi/Makefile b/common/windows/delphi/Makefile index 6241b54379..2a8258f07b 100644 --- a/common/windows/delphi/Makefile +++ b/common/windows/delphi/Makefile @@ -1,10 +1,9 @@ !include Defines.mak global-versions: -# Build our root version.txt +# Build our root version.txt; TODO: replace with build.sh deps cd $(KEYMAN_ROOT)\common\windows - - $(MKVER_U) $(KEYMAN_ROOT)\common\windows\cpp\include\keymanversion_build.in $(KEYMAN_ROOT)\common\windows\cpp\include\keymanversion_build.h $(MKVER_U) $(KEYMAN_ROOT)\common\windows\delphi\general\keymanversion_build.in $(KEYMAN_ROOT)\common\windows\delphi\general\keymanversion_build.inc + $(GIT_BASH_FOR_KEYMAN) $(KEYMAN_ROOT)/common/include/build.sh clean configure build !include Target.mak \ No newline at end of file diff --git a/developer/src/Makefile b/developer/src/Makefile index 854296e233..c1ab53cce0 100644 --- a/developer/src/Makefile +++ b/developer/src/Makefile @@ -257,7 +257,7 @@ build-tools: global-versions: cd $(COMMON_ROOT) - @if not exist $(KEYMAN_ROOT)\common\windows\cpp\include\keymanversion_build.h $(MAKE) global-versions + @if not exist $(KEYMAN_ROOT)\include\keymanversion_build.h $(MAKE) global-versions cd $(DEVELOPER_ROOT)\src build-tools-internal: diff --git a/developer/src/kmc/build.sh b/developer/src/kmc/build.sh index 55cacf656e..5a2622fdb3 100755 --- a/developer/src/kmc/build.sh +++ b/developer/src/kmc/build.sh @@ -17,6 +17,7 @@ cd "$THIS_SCRIPT_PATH" . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" builder_describe "Build Keyman Keyboard Compiler kmc" \ + "@/common/include" \ "@/common/web/keyman-version" \ "@/common/web/types" \ "@/developer/src/kmc-keyboard" \ diff --git a/windows/src/Makefile b/windows/src/Makefile index 5ff33a3fb1..7dda885263 100644 --- a/windows/src/Makefile +++ b/windows/src/Makefile @@ -276,7 +276,7 @@ build-tools: global-versions: cd $(COMMON_ROOT) - @if not exist $(KEYMAN_ROOT)\common\windows\cpp\include\keymanversion_build.h $(MAKE) global-versions + @if not exist $(KEYMAN_ROOT)\include\keymanversion_build.h $(MAKE) global-versions cd $(ROOT)\src message-constants: build-tools diff --git a/windows/src/Target.mak b/windows/src/Target.mak index 42ec5a4923..f115f5ac04 100644 --- a/windows/src/Target.mak +++ b/windows/src/Target.mak @@ -17,7 +17,7 @@ versionhistory-app2: devtools-app: dirs cd $(COMMON_ROOT) - @if not exist $(KEYMAN_ROOT)\common\windows\cpp\include\keymanversion_build.h $(MAKE) global-versions + @if not exist $(KEYMAN_ROOT)\include\keymanversion_build.h $(MAKE) global-versions cd $(COMMON_ROOT)\tools\devtools $(MAKE) cd $(ROOT)\src diff --git a/windows/src/global/Makefile b/windows/src/global/Makefile index 907a0235c5..081a907cfb 100644 --- a/windows/src/global/Makefile +++ b/windows/src/global/Makefile @@ -20,7 +20,7 @@ build-release: clean: -del $(ROOT)\src\global\delphi\general\keymanversion_build.inc - -del $(KEYMAN_ROOT)\common\windows\cpp\include\keymanversion_build.h + $(GIT_BASH_FOR_KEYMAN) $(KEYMAN_ROOT)/common/include/build.sh clean cd $(ROOT)\src\global\delphi $(MAKE) clean