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

Add git hash #235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
[submodule "3rdparty/freetype"]
path = 3rdparty/freetype
url = https://github.com/freetype/freetype
[submodule "3rdparty/cmake-git-version-tracking"]
path = 3rdparty/cmake-git-version-tracking
url = https://github.com/andrew-hardin/cmake-git-version-tracking.git
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"gitlens.currentLine.enabled": false
}
Copy link
Member

Choose a reason for hiding this comment

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

generally you should prefer having a trailing newline, to prevent tools like github from giving you angry red circles.

1 change: 1 addition & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ ADD_SUBDIRECTORY(toml11 EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY(spdlog EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY(longeronpp EXCLUDE_FROM_ALL)

ADD_SUBDIRECTORY(cmake-git-version-tracking EXCLUDE_FROM_ALL)
# For Windows: Prevent overriding the parent project's compiler/linker settings
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(googletest EXCLUDE_FROM_ALL)
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/cmake-git-version-tracking
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ SET(OSP_MAGNUM_DEPS_LIBS
dNewton dScene dModel dVehicle
toml11
spdlog
longeron)
longeron
cmake_git_version_tracking)
target_link_libraries(osp-magnum-deps INTERFACE ${OSP_MAGNUM_DEPS_LIBS})
add_dependencies(compile-osp-magnum-deps ${OSP_MAGNUM_DEPS_LIBS})

Expand Down
15 changes: 12 additions & 3 deletions src/test_application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
#include <string_view>
#include <thread>
#include <unordered_map>
#if __has_include("git.h")
#include "git.h"
Copy link
Member

Choose a reason for hiding this comment

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

Why wouldn't it have this header?

#define GIT_HASH git_Describe()
#define GIT_BRANCH git_Branch()
#else
#define GIT_HASH "00000"
#define GIT_BRANCH "n/a"
#endif

using namespace testapp;

Expand Down Expand Up @@ -491,10 +499,11 @@ void debug_print_help()
longestName = std::max(name.size(), longestName);
}

std::cout
<< "OSP-Magnum Temporary Debug CLI\n"
<< "Open a scenario:\n";
std::cout << "OSP-Magnum Temporary Debug CLI\n";

std::cout << "Version: " << GIT_HASH << " (" << GIT_BRANCH << ")\n\n";

std::cout << "Open a scenario:\n";
for (auto const& [name, rTestScn] : scenarios())
{
std::string spaces(longestName - name.length(), ' ');
Expand Down