Replace Version with Git Hash#33
Conversation
|
It looks like this can be easily applied to the other *.vcxproj files, meaning that VS2003, 2005, and 2008 will be broken. I guess I'm okay with that? |
I wouldn't have a problem making those changes but it would take some time setting up systems with those installs. |
|
Do we even have a reason to keep those old projects around? IMO, we should start moving the code towards making use of modern c++17/20 |
|
|
It looks like the GitHub build does invoke So I guess one solution would be "Capture |
|
several issues
|
You are doing that in your GitHub workflow yml.
That's fine but building locally should still work and now the version info in game is useless.
That doesn't solve anything. I'm withdrawing this PR but I think it's a really stupid idea to assume things in code that rely on GitHub as a build system. |
Thats because git is installed by the build machine image thats defined in the workflow yml. One can't demand that git is available on the PATH on every developer machine.
No not that, I wanted to emphesize that you need more than a hash. You need to specify where that hash is located, what the repo is called. Build information when built in github includes the name "github" the owner/repo and even the branch if applicable. I would try to include at least some information about the remote (git remote -v) as build information for local builds. Also now that you mention hash,
I assume you mean cmake? Once cmake is used, you just search google and find a good solution and use that. So it helps a lot. Yes it still requires the git exe but it has a fallback implemented. Point is, now its easy to find a solution that covers many cases and you only need to modify it marginally. Well once we have cmake.
2 things:
If 1dot13 would be a .NET project, I would have said to just add <PackageReference Include="GitVersion.MsBuild" Version="5.6.10*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>to your csproj file and be done with it. That would just do everything automatically: download a git library to use (instead of relying git on path), set the official assembly versions numbers based on the current git state, provide additional git related attributes in the code and metadata. But alas we are in CPP and dont have that option. |
Using a method found here I updated the VS 2017 and 2019 project files to add pre-build events to update a file
rev.hto include a macro that contains 10 digits of the git hash of the working copy.Some notes, this means that older VS projects will not be able to build and thus will need to backport the changes from 2017/2019 and that
gitmust be available when the build runs, else the pre-build event will fail to execute.