Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build issue from alpha 10 #851

Merged
merged 6 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- run: git rev-parse --short=5 HEAD > cmake/AutoRevision.txt
- run: git describe --tags `git rev-list --tags --max-count=1 master` >> cmake/AutoRevision.txt
- run: git describe --tags `git rev-list --tags --max-count=1` >> cmake/AutoRevision.txt
- run: cat cmake/AutoRevision.txt
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Release update of AutoRevision.txt"
Expand All @@ -23,6 +25,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- name: Make build directory
run: mkdir -p -v $PWD/build
- name: Create tar.gz
Expand Down
33 changes: 30 additions & 3 deletions cmake/AutoRevision.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ if(Git_FOUND)

if(STATUS AND NOT STATUS EQUAL 0)

# In case git is not found (for example the person uses the tarball) we still need the variables
# set. So we get them from AutoRevision.txt instead that is updated by a GitHub Action at Release
# In case git is found but we are not in a good repo we still need the variables set.
# So we get them from AutoRevision.txt instead that is updated by a GitHub Action at Release
# See .git/workflows/release.yaml

message("-- git was found, but we are not in a valid repository. Using AutoRevision.txt")
file(READ cmake/AutoRevision.txt FC21_REV_HEAD_HASH_H LIMIT 5)
string(REGEX REPLACE "\n$" "" FC21_REV_HEAD_HASH_H "${FC21_REV_HEAD_HASH_H}")

Expand All @@ -42,6 +43,7 @@ if(Git_FOUND)
# In this case, we have git and are in a good repo, so let's get the values we need from git directly

# Get the value of the git hash at HEAD to 5 chars
message("-- git was found and we are in a valid repository. Using git commands.")
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=.git rev-parse --short=5 HEAD
OUTPUT_VARIABLE FC21_REV_HEAD_HASH_H
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand All @@ -51,7 +53,7 @@ if(Git_FOUND)
message("-- Git HEAD Commit Hash: (hex) ${FC21_REV_HEAD_HASH_H} and (dec) ${FC21_REV_HEAD_HASH_D}")

# Get a temp value of the full commit hash of the latest tag that is active
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=.git rev-list --tags --max-count=1 master
execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=.git rev-list --tags --max-count=1
OUTPUT_VARIABLE _output
OUTPUT_STRIP_TRAILING_WHITESPACE)

Expand All @@ -70,4 +72,29 @@ if(Git_FOUND)
#message("-- Latest Git Tag List: ${FC21_REV_TAG_LIST}")

endif()

else()

# In this case git is not found at all, but we still need the variables set.
# So we get them from AutoRevision.txt instead that is updated by a GitHub Action at Release
# See .git/workflows/release.yaml

message("-- git was not found installed. Using AutoRevision.txt")
file(READ cmake/AutoRevision.txt FC21_REV_HEAD_HASH_H LIMIT 5)
string(REGEX REPLACE "\n$" "" FC21_REV_HEAD_HASH_H "${FC21_REV_HEAD_HASH_H}")

# Convert the hexadecimal hash to a decimal number to support the project()
math(EXPR FC21_REV_HEAD_HASH_D "0x${FC21_REV_HEAD_HASH_H}" OUTPUT_FORMAT DECIMAL)
message("-- AutoRevision HEAD Commit Hash: (hex) ${FC21_REV_HEAD_HASH_H} and (dec) ${FC21_REV_HEAD_HASH_D}")

file(READ cmake/AutoRevision.txt FC21_REV_TAG OFFSET 6)
string(REGEX REPLACE "\n$" "" FC21_REV_TAG "${FC21_REV_TAG}")

# Manipulate the tag so we can turn it into a list for use later
string(REPLACE "v" "" FC21_REV_TAG2 "${FC21_REV_TAG}")
string(REPLACE "." " " FC21_REV_TAG2 "${FC21_REV_TAG2}")
string(REPLACE "-" " " FC21_REV_TAG2 "${FC21_REV_TAG2}")
set(FC21_REV_TAG_LIST ${FC21_REV_TAG2})
separate_arguments(FC21_REV_TAG_LIST)

endif()
4 changes: 2 additions & 2 deletions cmake/AutoRevision.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
8c94b
v3.0-alpha.9
c6855
v3.0-alpha.10