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

CMake: Keep git info up-to-date without reconfiguration #3841

Merged
merged 4 commits into from May 8, 2021

Conversation

Holzhaus
Copy link
Member

@Holzhaus Holzhaus commented May 7, 2021

Based on #3831.

Hopefully replaces #3837 #3822 #3259 #3832 (EDIT: Also added setting the patched flag from git describe from #3817 in 09e5ee4)

This should avoid reconfiguration due to git state changes reliably:

  • All git info stuff removed from CMakeLists.txt
  • Add build time, this always runs a script that configures a file with the git version info as a build job. That file is then included by the source code. This means that the build system can figure out if it needs to rebuild/relink and we don't have any unnecessary rebuilds/reconfigurations.
  • For CPack, the git information is retrieved at CPack time, not at configuration time. This also ensure that the git info is always up to date.

@Holzhaus Holzhaus added the build label May 7, 2021
@Holzhaus Holzhaus added this to the 2.3.0 milestone May 7, 2021
@Holzhaus Holzhaus requested a review from daschuer May 7, 2021 11:54
@Holzhaus Holzhaus added this to In progress in 2.3 release via automation May 7, 2021
@Holzhaus Holzhaus changed the title Cmake gitinfo without reconfig CMake: Keep git info up-to-date without reconfiguration May 7, 2021
@Holzhaus Holzhaus force-pushed the cmake-gitinfo-without-reconfig branch 2 times, most recently from 09e5ee4 to 8c78569 Compare May 7, 2021 12:54
@Holzhaus Holzhaus moved this from In progress to Needs Review in 2.3 release May 7, 2021
@Holzhaus Holzhaus force-pushed the cmake-gitinfo-without-reconfig branch 2 times, most recently from 76641c5 to d192455 Compare May 7, 2021 14:56
@daschuer
Copy link
Member

daschuer commented May 7, 2021

I am gad we are getting close, thank you. What a work for this tiny flag, not used for DJ-ing :-/ .. but at least interesting to lean cmake ...

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

The big solution ... Thank you.
I have left some comments.

CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
@@ -1705,9 +1648,12 @@ if(WIN32)
"${CMAKE_CURRENT_BINARY_DIR}/src/mixxx.rc.include"
@ONLY
)
add_dependencies(mixxx mixxx-gitinfo)
Copy link
Member

Choose a reason for hiding this comment

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

We should do this for all targets and remove the git dependency from mixxx-lib.

Did you consider to configure a cpp file instead of a header, like did in the first attempt? This will speed up recompiling even more?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will speed up recompiling even more?

How so?

Copy link
Member

Choose a reason for hiding this comment

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

I can take care after merge.

CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
endif()
set(CPACK_PACKAGE_FILE_NAME "mixxx-${PACKAGE_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-source")
set(CPACK_DEBIAN_GIT_DESCRIBE "${GIT_DESCRIBE}")
Copy link
Member

Choose a reason for hiding this comment

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

The code patching the source tree with CPACK_DEBIAN_GIT_DESCRIBE in CPackDebUploadPPA.cmake does no longer work.

Copy link
Member Author

Choose a reason for hiding this comment

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

I hopefully fixed it now. But I can't test (no debian system).

#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@"
#cmakedefine GIT_COMMIT_YEAR @GIT_COMMIT_YEAR@
#cmakedefine GIT_COMMIT_COUNT @GIT_COMMIT_COUNT@
#cmakedefine GIT_DIRTY
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this should become a cpp file

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this file is also used from mixxx.rc.include.template which isn't C/CPP. And I think configuring header files is much cleaner than cpp files. Performance wise I doubt this makes a difference.

src/buildinfo.h.in Outdated Show resolved Hide resolved
@daschuer
Copy link
Member

daschuer commented May 7, 2021

Uhhh bad ....

This fails with ninja. Ninja does not recalculate files during build. All files that changes during the build must be added with DEPENDS directives. Some of these do not work for VisualStudio.

Since the dirty flag is only relevant for home builds, this important.

Conclusion:
Let's remove the dirty flag entirely and carry one the important topics, like crash when changing effects on windows or the auto DJ stop issue.

What do you think?

I have given up to make ninja / msbuild and make work in #3837 it is probably not possible with build system independent code.

@Holzhaus Holzhaus force-pushed the cmake-gitinfo-without-reconfig branch from d192455 to 836d68b Compare May 7, 2021 15:50
@Holzhaus
Copy link
Member Author

Holzhaus commented May 7, 2021

Uhhh bad ....

This fails with ninja. Ninja does not recalculate files during build. All files that changes during the build must be added with DEPENDS directives. Some of these do not work for VisualStudio.

I cannot reproduce this, it works fine here:

$ ninja
[2/6] Update git version information in gitinfo.h
Git describe: 2.3-beta-3890-g836d68bcce
Git worktree modified: no
Git branch: cmake-gitinfo-without-reconfig
Git commit date: 2021-05-07T17:48:21+02:00
Git commit year: 2021
Git commit count: 8173
$ printf "\n" >> ../res/schema.xml
$ ninja
[2/10] Update git version information in gitinfo.h
Git describe: 2.3-beta-3890-g836d68bcce-modified
Git worktree modified: yes
Git branch: cmake-gitinfo-without-reconfig
Git commit date: 2021-05-07T17:48:21+02:00
Git commit year: 2021
Git commit count: 8173
[10/10] Linking CXX executable mixxx-test

@Holzhaus Holzhaus force-pushed the cmake-gitinfo-without-reconfig branch from 836d68b to dfea4f4 Compare May 7, 2021 16:10
@Holzhaus Holzhaus force-pushed the cmake-gitinfo-without-reconfig branch from dfea4f4 to a01f34e Compare May 7, 2021 16:18
@Holzhaus
Copy link
Member Author

Holzhaus commented May 7, 2021

@daschuer I also want to get this over with, but It works fine for me. Can you re-test or elaborate what exactly doesn't work?

@daschuer
Copy link
Member

daschuer commented May 7, 2021

Ninja does not rebuild, mixxx when the git work there becomes dirty due to a file that not triggers a rebuild anyway.

@Holzhaus
Copy link
Member Author

Holzhaus commented May 7, 2021

Ninja does not rebuild, mixxx when the git work there becomes dirty due to a file that not triggers a rebuild anyway.

Cannot reproduce this, works for me:

$ ninja
[2/6] Update git version information in gitinfo.h
Git describe: 2.3-beta-3897-ga01f34ec79
Git worktree modified: no
Git branch: cmake-gitinfo-without-reconfig
Git commit date: 2021-05-07T18:15:51+02:00
Git commit year: 2021
Git commit count: 8176
$ printf "\n" >> ../res/controllers/Roland_DJ-505-scripts.js
$ ninja
[2/6] Update git version information in gitinfo.h
Git describe: 2.3-beta-3897-ga01f34ec79-modified
Git worktree modified: yes
Git branch: cmake-gitinfo-without-reconfig
Git commit date: 2021-05-07T18:15:51+02:00
Git commit year: 2021
Git commit count: 8176
[6/6] Linking CXX executable mixxx
$ ninja --version
1.10.2

In any case, I think this PR improves the current situation.

@daschuer
Copy link
Member

daschuer commented May 8, 2021

I can no longer confirm the ninja build issues.

@Holzhaus
Copy link
Member Author

Holzhaus commented May 8, 2021

Maybe the worktree was already dirty. In that case, if you change something else, too, it stays dirty and won't recompile unnecessarily.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Thank you for this effort. It works now.

@daschuer daschuer merged commit 896b64a into mixxxdj:2.3 May 8, 2021
2.3 release automation moved this from Needs Review to Done May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
2.3 release
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants