nixpkgs/pkgs/applications/misc/translatelocally/version_without_git.patch
pacien 7d79717584 translatelocally: init at unstable-2023-08-25
Upstream doesn't have proper version tags, so I'm using a commit hash
and date here. The CMake files are patched so they don't try using
the stripped .git repo data to generate a version string.

Github: closes #250867
2023-09-08 22:30:26 +02:00

67 lines
3.2 KiB
Diff

Submodule 3rd_party/bergamot-translator contains modified content
Submodule 3rd_party/marian-dev contains modified content
diff --git a/3rd_party/bergamot-translator/3rd_party/marian-dev/cmake/GetVersionFromFile.cmake b/3rd_party/bergamot-translator/3rd_party/marian-dev/cmake/GetVersionFromFile.cmake
index 31352565..d90a366d 100644
--- a/3rd_party/bergamot-translator/3rd_party/marian-dev/cmake/GetVersionFromFile.cmake
+++ b/3rd_party/bergamot-translator/3rd_party/marian-dev/cmake/GetVersionFromFile.cmake
@@ -22,10 +22,8 @@ else()
endif()
# Get current commit SHA from git
-execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE PROJECT_VERSION_GIT_SHA
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+# (dummy value for nix package without the .git)
+set(PROJECT_VERSION_GIT_SHA 000000000000)
# Get partial versions into a list
string(REGEX MATCHALL "-.*$|[0-9]+" PROJECT_PARTIAL_VERSION_LIST
diff --git a/3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeLists.txt b/3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeLists.txt
index 76aa0e2b..ca982bd3 100644
--- a/3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeLists.txt
+++ b/3rd_party/bergamot-translator/3rd_party/marian-dev/src/CMakeLists.txt
@@ -149,23 +149,8 @@ target_compile_options(marian PRIVATE ${ALL_WARNINGS})
#
# We set MARIAN_GIT_DIR to the appropriate path, depending on whether
# ${CMAKE_CURRENT_SOURCE_DIR}/../.git is a directory or file.
-set(MARIAN_GIT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
-if(NOT IS_DIRECTORY ${MARIAN_GIT_DIR}) # i.e., it's a submodule
- file(READ ${MARIAN_GIT_DIR} MARIAN_GIT_DIR)
- string(REGEX REPLACE "gitdir: (.*)\n" "\\1" MARIAN_GIT_DIR ${MARIAN_GIT_DIR})
- if(NOT IS_ABSOLUTE ${MARIAN_GIT_DIR})
- get_filename_component(MARIAN_GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${MARIAN_GIT_DIR}" ABSOLUTE)
- endif()
-endif(NOT IS_DIRECTORY ${MARIAN_GIT_DIR})
-
-add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/common/git_revision.h
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND git log -1 --pretty=format:\#define\ GIT_REVISION\ \"\%h\ \%ai\" > ${CMAKE_CURRENT_SOURCE_DIR}/common/git_revision.h
- DEPENDS ${MARIAN_GIT_DIR}/logs/HEAD
- VERBATIM
-)
-add_custom_target(marian_version DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/common/git_revision.h)
-add_dependencies(marian marian_version) # marian must depend on it so that it gets created first
+# (generated by nix package instead)
+
# make sure all local dependencies are installed first before this is built
add_dependencies(marian 3rd_party_installs)
diff --git a/cmake/GetVersionFromFile.cmake b/cmake/GetVersionFromFile.cmake
index 83b7975..71cd861 100644
--- a/cmake/GetVersionFromFile.cmake
+++ b/cmake/GetVersionFromFile.cmake
@@ -23,10 +23,8 @@ else()
endif()
# Get current commit SHA from git
-execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_VARIABLE PROJECT_VERSION_GIT_SHA
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+# (dummy value for nix package without the .git)
+set(PROJECT_VERSION_GIT_SHA 000000000000)
# Get partial versions into a list
string(REGEX MATCHALL "-.*$|[0-9]+" PROJECT_PARTIAL_VERSION_LIST