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

Git info store object #3848

Merged
merged 12 commits into from May 17, 2021
Merged

Git info store object #3848

merged 12 commits into from May 17, 2021

Conversation

daschuer
Copy link
Member

@daschuer daschuer commented May 8, 2021

This adds a git Info store project to speed up building when only the git info is updated.
This uses also the build date in case of tar ball builds unless a GIT_COMMIT_DATE is passed to cmake along with a GIT _DESCRIBE

@@ -1,4 +1,5 @@
<!--

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

if (gitVersion.isEmpty()) {
gitVersion = QStringLiteral("unknown");
}

QString gitBranch = VersionStore::gitBranch();
if (!gitBranch.isEmpty()) {
gitVersion.append(QStringLiteral(" (") + gitBranch + QStringLiteral(" branch)"));
gitVersion.append(QStringLiteral(" (") + gitBranch + QChar(')'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this change to make the about window a bit less wide.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can even remove the branch name if it matches the version

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may, but I don't think it's necessary. In any case this should happen in the cpp code, not in the CMake code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you already did.

@Holzhaus
Copy link
Member

Holzhaus commented May 8, 2021

Some pre-commit issues.

@daschuer
Copy link
Member Author

daschuer commented May 8, 2021

Done

@Holzhaus
Copy link
Member

Holzhaus commented May 8, 2021

Done

Still pre-commit issues.

@daschuer
Copy link
Member Author

daschuer commented May 9, 2021

No idea why this passes locally the second time. :-/
Anyway, should work now.

#ifdef GIT_COMMIT_COUNT
return GIT_COMMIT_COUNT;
#else
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 maybe? or use std::optional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 fits, because we have 0 commits if we are off the git worktree

static const char* branch();
static const char* describe();
static const char* date();
int commitCount();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static?

Comment on lines +1616 to +1617
-DGIT_DESCRIBE="${GIT_DESCRIBE}"
-DGIT_COMMIT_DATE="${GIT_COMMIT_DATE}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about CPackConfig? I think you need to copy these variables into the CPack domain as well, and set them before including the GitInfo module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daschuer ping.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, we should allow to use the override values in cpack as well.

@uklotzde uklotzde added this to the 2.3.0 milestone May 9, 2021
@Holzhaus
Copy link
Member

There are merge conflicts now.

@daschuer
Copy link
Member Author

Done.

-DINPUT_FILE="${CMAKE_CURRENT_SOURCE_DIR}/src/gitinfo.h.in"
-DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/src/gitinfo.h"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/scripts/gitinfo.cmake"
COMMENT "Update git version information in gitinfo.h"
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/src/gitinfo.h"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
add_dependencies(mixxx-lib mixxx-gitinfo)

add_library(mixxx-gitinfostore STATIC EXCLUDE_FROM_ALL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for making this a separate library? Why not add it to mixxx-lib instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve build time. Re-linking it to mixxx-lib takes long, even if just the git info changes.
From this point of view it is better to have more lbs than less. This will also reduce the memory requirements on Windows.

@Holzhaus Holzhaus merged commit 82dc1a7 into mixxxdj:2.3 May 17, 2021
@uklotzde
Copy link
Contributor

Building a local branch fails now:

CMake Error at CMakeLists.txt:1628 (message):
  GIT_COMMIT_DATE requires strict ISO 8601 format %Y-%m-%dT%H:%M:%SZ

@uklotzde
Copy link
Contributor

Do we have updated build instructions for this use case??

@uklotzde
Copy link
Contributor

This is what I have added to my build script:

GIT_COMMIT_DESCRIPTION=$(git describe --tags --always --dirty=-modified)
GIT_COMMIT_DATE=$(git show --quiet --format=%cd --date=short)
GIT_COMMIT_DESCRIPTION=2.4-alpha-5721-g528306e196
GIT_COMMIT_DATE=2021-05-17

@Holzhaus
Copy link
Member

@uklotzde can you run the git commit date command directly and post the output?

@uklotzde
Copy link
Contributor

--date=iso-strict works

@Holzhaus
Copy link
Member

Holzhaus commented May 17, 2021

Ah, please use --format=%cI, not %cd.

@Holzhaus
Copy link
Member

Is this for Fedora? If you're building from the git tree setting those variables locally should not be necessary at all.

@uklotzde
Copy link
Contributor

The --date argument could be omitted.

We need to build from a plain file archive, no Git repo available. I added them explicitly for continuously testing the build. Just to notice early when the build breaks because of invalid assumptions.

@uklotzde
Copy link
Contributor

Ok, I copied the new variables and their commands literally.

@daschuer daschuer deleted the dirty-fix branch August 1, 2021 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants