-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a mixxx-build-date library that has a reliable dirty result and b…
…uild date in case of dirty
- Loading branch information
Showing
6 changed files
with
74 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Check if the worktree is dirty | ||
execute_process( | ||
COMMAND git diff --quiet | ||
RESULT_VARIABLE DIRTY | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR_} | ||
ERROR_QUIET | ||
) | ||
|
||
if(DIRTY EQUAL "1") | ||
message(STATUS "Git worktree is dirty") | ||
# This depends on mixxx-lib so it will pick a new date | ||
# Whenever mixxx-lib has changed. | ||
string(TIMESTAMP BUILD_DATE "%Y-%m-%dT%H:%M:%SZ" UTC) | ||
else() | ||
message(STATUS "Git worktree is clean") | ||
# Get the current commit date in case the build tree is unchanged | ||
# The leads to reproducible builds | ||
execute_process( | ||
COMMAND git show --quiet --format=%cI --date=short | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR_} | ||
OUTPUT_VARIABLE BUILD_DATE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET | ||
) | ||
endif() | ||
|
||
configure_file(${CMAKE_SOURCE_DIR_}/src/builddate.cpp.in ${CMAKE_BINARY_DIR_}/src/builddate.cpp @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "builddate.h" | ||
|
||
//static | ||
const char* BuildDate::date() { | ||
return "@BUILD_DATE@"; | ||
}; | ||
|
||
//static | ||
bool BuildDate::dirty() { | ||
return static_cast<bool>(1); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
class BuildDate { | ||
public: | ||
static const char* date(); | ||
static bool dirty(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters