Skip to content

Commit

Permalink
Specify quotes in target_compile_definitions properly, fix potential …
Browse files Browse the repository at this point in the history
…issue with set_git_info
  • Loading branch information
Masterkatze committed Mar 20, 2024
1 parent 3fc4188 commit 71b9a3b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function(target_sources_grouped)
source_group(${PARSED_ARGS_NAME} FILES ${PARSED_ARGS_FILES})
endfunction()

function(set_git_info)
macro(set_git_info)
execute_process(COMMAND git rev-parse --verify HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_SHA1
Expand All @@ -40,7 +40,7 @@ function(set_git_info)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "git branch: ${GIT_BRANCH}")
endfunction()
endmacro()

function(calculate_xray_build_id output)
set(XRAY_START_DAY 31)
Expand Down
8 changes: 4 additions & 4 deletions src/xrCore/.GitInfo.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
echo | set /p dummyName=#define GIT_INFO_CURRENT_COMMIT > .GitInfo.hpp
git rev-parse --verify HEAD >> .GitInfo.hpp
@FOR /f "delims=" %%i in ('git rev-parse --verify HEAD') DO set COMMIT=%%i
echo #define GIT_INFO_CURRENT_COMMIT "%COMMIT%" > .GitInfo.hpp

echo | set /p dummyName=#define GIT_INFO_CURRENT_BRANCH >> .GitInfo.hpp
git rev-parse --abbrev-ref HEAD >> .GitInfo.hpp
@FOR /f "delims=" %%i in ('git rev-parse --abbrev-ref HEAD') DO set BRANCH=%%i
echo #define GIT_INFO_CURRENT_BRANCH "%BRANCH%" >> .GitInfo.hpp
14 changes: 7 additions & 7 deletions src/xrCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ endif()
target_compile_definitions(xrCore
PRIVATE
XRCORE_EXPORTS
CMAKE_INSTALL_FULL_LIBDIR=${CMAKE_INSTALL_FULL_LIBDIR}
CMAKE_INSTALL_FULL_DATAROOTDIR=${CMAKE_INSTALL_FULL_DATAROOTDIR}
CMAKE_INSTALL_FULL_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"
CMAKE_INSTALL_FULL_DATAROOTDIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\"
CI=$ENV{CI}
GITHUB_ACTIONS=$ENV{GITHUB_ACTIONS}
GITHUB_RUN_ID=$ENV{GITHUB_RUN_ID}
GITHUB_RUN_NUMBER=$ENV{GITHUB_RUN_NUMBER}
GITHUB_REPOSITORY=$ENV{GITHUB_REPOSITORY}
GIT_INFO_CURRENT_COMMIT=${GIT_SHA1}
GIT_INFO_CURRENT_BRANCH=${GIT_BRANCH}
GITHUB_RUN_ID=\"$ENV{GITHUB_RUN_ID}\"
GITHUB_RUN_NUMBER=\"$ENV{GITHUB_RUN_NUMBER}\"
GITHUB_REPOSITORY=\"$ENV{GITHUB_REPOSITORY}\"
GIT_INFO_CURRENT_COMMIT=\"${GIT_SHA1}\"
GIT_INFO_CURRENT_BRANCH=\"${GIT_BRANCH}\"
)

if (MEMORY_ALLOCATOR STREQUAL "mimalloc")
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ void CLocatorAPI::setup_fs_path(pcstr fs_name)
* I propose adding shaders from <CMAKE_INSTALL_FULL_DATAROOTDIR>/openxray/gamedata/shaders so that we remove unnecessary questions from users who want to start
* the game using resources not from the proposed ~/.local/share/GSC Game World/Game in this case, this section of code can be safely removed */
chdir(pref_path);
static constexpr pcstr install_dir = MACRO_TO_STRING(CMAKE_INSTALL_FULL_DATAROOTDIR);
static constexpr pcstr install_dir = CMAKE_INSTALL_FULL_DATAROOTDIR;
string_path tmp, tmp_link;
xr_sprintf(tmp, "%sfsgame.ltx", pref_path);
struct stat statbuf;
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/Threading/Lock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Common/Noncopyable.hpp"

#ifdef CONFIG_PROFILE_LOCKS
#include "xrCore.h"
typedef void (*add_profile_portion_callback)(LPCSTR id, const u64& time);
void XRCORE_API set_add_profile_portion(add_profile_portion_callback callback);

Expand Down
25 changes: 16 additions & 9 deletions src/xrCore/xrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ static u32 init_counter = 0;
void SDLLogOutput(void* userdata, int category, SDL_LogPriority priority, const char* message);

const pcstr xrCore::buildDate = __DATE__;
const pcstr xrCore::buildCommit = MACRO_TO_STRING(GIT_INFO_CURRENT_COMMIT);
const pcstr xrCore::buildBranch = MACRO_TO_STRING(GIT_INFO_CURRENT_BRANCH);
const pcstr xrCore::buildCommit = GIT_INFO_CURRENT_COMMIT;
const pcstr xrCore::buildBranch = GIT_INFO_CURRENT_BRANCH;

xrCore::xrCore()
: ApplicationName{}, ApplicationPath{},
Expand Down Expand Up @@ -117,14 +117,14 @@ void xrCore::PrintBuildInfo()
#if defined(CI)
# if defined(APPVEYOR)
name = "AppVeyor";
buildUniqueId = MACRO_TO_STRING(APPVEYOR_BUILD_ID);
buildId = MACRO_TO_STRING(APPVEYOR_BUILD_VERSION);
builder = MACRO_TO_STRING(APPVEYOR_ACCOUNT_NAME);
buildUniqueId = APPVEYOR_BUILD_ID;
buildId = APPVEYOR_BUILD_VERSION;
builder = APPVEYOR_ACCOUNT_NAME;
# elif defined(GITHUB_ACTIONS)
name = "GitHub Actions";
buildUniqueId = MACRO_TO_STRING(GITHUB_RUN_ID);
buildId = MACRO_TO_STRING(GITHUB_RUN_NUMBER);
builder = MACRO_TO_STRING(GITHUB_REPOSITORY);
buildUniqueId = GITHUB_RUN_ID;
buildId = GITHUB_RUN_NUMBER;
builder = GITHUB_REPOSITORY;
#else
# pragma TODO("PrintBuildInfo for other CIs")
name = "CI";
Expand Down Expand Up @@ -271,7 +271,14 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, LogCallback c
flags &= ~CLocatorAPI::flCacheFiles;
#endif // _EDITOR

if (xr_stricmp(ApplicationPath, MACRO_TO_STRING(CMAKE_INSTALL_FULL_DATAROOTDIR)) != 0)
// TODO Add proper check for CMake Windows build
#if defined(XR_PLATFORM_LINUX) || defined(XR_PLATFORM_BSD) || defined(XR_PLATFORM_APPLE)
auto DataRootDir = CMAKE_INSTALL_FULL_DATAROOTDIR;
#else
auto DataRootDir = "";
#endif

if (xr_stricmp(ApplicationPath, DataRootDir) != 0)
flags |= CLocatorAPI::flScanAppRoot;

#ifndef _EDITOR
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/xrCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(xrExternals)lzo\include;$(xrSdkDir)include\mimalloc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_ID=$(APPVEYOR_BUILD_ID);APPVEYOR_BUILD_VERSION=$(APPVEYOR_BUILD_VERSION);APPVEYOR_ACCOUNT_NAME=$(APPVEYOR_ACCOUNT_NAME);GITHUB_ACTIONS=$(GITHUB_ACTIONS);GITHUB_RUN_ID=$(GITHUB_RUN_ID);GITHUB_RUN_NUMBER=$(GITHUB_RUN_NUMBER);GITHUB_REPOSITORY=$(GITHUB_REPOSITORY);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;XRCORE_EXPORTS;CRYPTO_BUILD;CI=$(CI);APPVEYOR=$(APPVEYOR);APPVEYOR_BUILD_ID="$(APPVEYOR_BUILD_ID)";APPVEYOR_BUILD_VERSION="$(APPVEYOR_BUILD_VERSION)";APPVEYOR_ACCOUNT_NAME="$(APPVEYOR_ACCOUNT_NAME)";GITHUB_ACTIONS=$(GITHUB_ACTIONS);GITHUB_RUN_ID="$(GITHUB_RUN_ID)";GITHUB_RUN_NUMBER="$(GITHUB_RUN_NUMBER)";GITHUB_REPOSITORY="$(GITHUB_REPOSITORY)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>DbgHelp.lib;FaultRep.lib;jpeg-static.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand Down

0 comments on commit 71b9a3b

Please sign in to comment.