Reproducible C++ builds by logging Git hashes
1–10 of 45 posts
Re: Reproducible C++ builds by logging Git hashes
#2Re: Reproducible C++ builds by logging Git hashes
#3Re: Reproducible C++ builds by logging Git hashes
#4 $ git describe --dirty
v1.4.1-1-gde18fe90-dirty
The format is --g-.If the repo isn't dirty, then the hash you get excludes that part:
$ git describe --dirty
v1.4.1-1-gde18fe90
If you're using lightweight tags (the default) and not annotated tags (with messages and signatures and etc) you may want to add `--tags` because otherwise it'll skip over any lightweight tags.The other nice thing about this is that, if the repo is not -dirty, you can use the output from `git describe` in other git commands to reference that commit:
$ git show -s v1.4.1-1-gde18fe90
commit de18fe907edda2f2854e9813fcfbda9df902d8f1 (HEAD -> 1.4.1-release, origin/HEAD, origin/1.4.1-release)
Author: rockowitz
Date: Sun May 28 17:09:46 2023 -0400
Create codacy.ymlRe: Reproducible C++ builds by logging Git hashes
#5Give Nix a look sometime, it takes this to a whole new level by including all of the build dependencies in the hash, and their build dependencies and so on. The standard flake workflow even includes the warning about having uncommitted files.
I absolutely can't imagine not using some kind of tool like this. Feels as vital as VCS to me now.
Re: Reproducible C++ builds by logging Git hashes
#6Give Nix a look sometime, it takes this to a whole new level by including all of the build dependencies in the hash, and their build dependencies and so on. The standard flake workflow even includes the warning about having uncommitted files.
It's quite odd to me that Nix or something similar like Mise isn't completely ubiquitous in software. I feel like I went from having issues with build dependencies to having that aspect of software development completely solved as soon as I adopted Nix. I absolutely can't imagine not using some kind of tool like this. Feels as vital as VCS to me now.
Re: Reproducible C++ builds by logging Git hashes
#7Re: Reproducible C++ builds by logging Git hashes
#8https://nikhilism.com/post/2020/windows-deterministic-builds... is a good resource on some of the other steps needed. It's... a non-trivial journey :)
Re: Reproducible C++ builds by logging Git hashes
#9had to be said
Re: Reproducible C++ builds by logging Git hashes
#10A simpler way to do this, especially if you do tagging in your repositories, is to use `git describe`. For example: $ git describe --dirty v1.4.1-1-gde18fe90-dirty The format is - -g - . If the repo isn't dirty, then the hash you get excludes that part: $ git describe --dirty v1.4.1-1-gde18fe90 If you're using lightweight tags (the default) and not annotated tags (with messages and signatures and etc) you may want to…
Also, if you don't feel ready to commit to tagging your repository you can start with the `--always` flag which falls back to just the short commit hash.
The article's script isn't far from `git describe --always --dirty`, which can be a good place to start, and then it gets better as you start tagging.