Skip to content

Include explicit git commit hash in config.h#1175

Closed
ischoegl wants to merge 3 commits intoCantera:mainfrom
ischoegl:explicit-git-commit
Closed

Include explicit git commit hash in config.h#1175
ischoegl wants to merge 3 commits intoCantera:mainfrom
ischoegl:explicit-git-commit

Conversation

@ischoegl
Copy link
Copy Markdown
Member

@ischoegl ischoegl commented Jan 18, 2022

Changes proposed in this pull request

During compilation, the git commit hash is currently passed through the commandline:

g++ -o build/src/base/global.os -c -std=c++11 -pthread -O3 -Wno-inline -Wall -include src/pch/system.h -fPIC -DNDEBUG -DGIT_COMMIT=\"fcff59292\" -Iinclude -Iinclude/cantera/ext -Ibuild/src src/base/global.cpp

which is, however, hard to locate. As an example, the git hash for the last successful build for #1174 would have been much easier to find.

The proposed change adds a CANTERA_GIT_COMMIT to the configuration summary, e.g.

ConfigBuilder(["build/src/config.h.build"], ["include/cantera/base/config.h.in"])
INFO: Generating build/src/config.h.build with the following settings:
    CANTERA_GIT_COMMIT                  "fcff59292"
    CANTERA_SHORT_VERSION               "2.6"
    CANTERA_VERSION                     "2.6.0a4"
[...]

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@ischoegl ischoegl marked this pull request as draft January 18, 2022 17:25
@ischoegl ischoegl marked this pull request as ready for review January 18, 2022 17:41
@ischoegl ischoegl requested a review from a team January 18, 2022 17:41
@ischoegl ischoegl marked this pull request as draft January 18, 2022 17:49
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 18, 2022

Codecov Report

Merging #1175 (3971fe4) into main (fcff592) will decrease coverage by 0.11%.
The diff coverage is 80.00%.

❗ Current head 3971fe4 differs from pull request most recent head e841f1b. Consider uploading reports for the commit e841f1b to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1175      +/-   ##
==========================================
- Coverage   65.35%   65.23%   -0.12%     
==========================================
  Files         315      315              
  Lines       45999    45999              
  Branches    19531    19531              
==========================================
- Hits        30062    30007      -55     
  Misses      13445    13445              
- Partials     2492     2547      +55     
Impacted Files Coverage Δ
include/cantera/base/global.h 84.21% <ø> (ø)
src/base/global.cpp 74.50% <ø> (-0.33%) ⬇️
src/clib/ct.cpp 7.39% <0.00%> (ø)
include/cantera/cython/wrappers.h 85.71% <100.00%> (+0.23%) ⬆️
src/base/YamlWriter.cpp 99.09% <100.00%> (ø)
src/oneD/Sim1D.cpp 73.63% <100.00%> (ø)
src/base/units.h 37.60% <0.00%> (-47.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcff592...e841f1b. Read the comment docs.

@ischoegl ischoegl marked this pull request as ready for review January 18, 2022 18:07
@ischoegl
Copy link
Copy Markdown
Member Author

Also eliminated Cantera::gitCommit as having the define in config.h makes things easier to follow. Should be good now (as long as CI passes).

Comment on lines -130 to -138
std::string gitCommit()
{
#ifdef GIT_COMMIT
return GIT_COMMIT;
#else
return "unknown";
#endif
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not keep this function around? It can still use the macro from config.h, but keeping this would save a lot of the other churn here, I think.

Copy link
Copy Markdown
Member Author

@ischoegl ischoegl Jan 18, 2022

Choose a reason for hiding this comment

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

The reason for eliminating this was to ensure that both CANTERA_VERSION and CANTERA_GIT_COMMIT are handled the same. It probably should be deprecated though ... (Edit: done)

@ischoegl ischoegl force-pushed the explicit-git-commit branch from f145d42 to 988e08c Compare January 18, 2022 18:26
This change ensures that CANTERA_GIT_COMMIT is accessed in a similar way as
CANTERA_VERSION. Cantera::gitCommit is deprecated.
@ischoegl ischoegl force-pushed the explicit-git-commit branch from 988e08c to e841f1b Compare January 18, 2022 18:32
@speth
Copy link
Copy Markdown
Member

speth commented Jan 18, 2022

The current approach is used for a reason -- this way, each time you make a local git commit, rebuilding Cantera only requires recompiling global.cpp and re-linking. If this is defined in config.h, then every single source file will need to be recompiled.

Printing out the discovered git commit somewhere near the start of the build process isn't a bad idea, though.

@ischoegl
Copy link
Copy Markdown
Member Author

The current approach is used for a reason -- this way, each time you make a local git commit, rebuilding Cantera only requires recompiling global.cpp and re-linking. If this is defined in config.h, then every single source file will need to be recompiled.

Makes a lot of sense (in hindsight 😂)! Closing this as much of the work here is rendered moot.

@ischoegl ischoegl closed this Jan 18, 2022
@ischoegl ischoegl deleted the explicit-git-commit branch January 31, 2022 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants