实现基础断言 添加 Release 构建版本
This commit is contained in:
parent
f53211ef50
commit
6e3c008936
@ -26,6 +26,10 @@ endif ()
|
|||||||
add_compile_definitions ("BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
add_compile_definitions ("BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
||||||
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
add_compile_definitions ("BUILD_DEBUG=1")
|
add_compile_definitions ("BUILD_DEBUG=1")
|
||||||
|
elseif (CMAKE_BUILD_TYPE MATCHES "Release")
|
||||||
|
add_compile_definitions ("BUILD_RELEASE=1")
|
||||||
|
else ()
|
||||||
|
add_compile_definitions ("BUILD_UNKNOWN=1")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Add subproject
|
# Add subproject
|
||||||
|
@ -9,8 +9,18 @@
|
|||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"buildCommandArgs": "",
|
"buildCommandArgs": "",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
"inheritEnvironments": [ "msvc_x64_x64" ]
|
||||||
"variables": []
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Release",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Release",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "msvc_x64_x64" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Linux-GCC-Debug",
|
"name": "Linux-GCC-Debug",
|
||||||
@ -29,8 +39,26 @@
|
|||||||
"remoteCopySources": true,
|
"remoteCopySources": true,
|
||||||
"rsyncCommandArgs": "-t --delete --delete-excluded",
|
"rsyncCommandArgs": "-t --delete --delete-excluded",
|
||||||
"remoteCopyBuildOutput": false,
|
"remoteCopyBuildOutput": false,
|
||||||
"remoteCopySourcesMethod": "rsync",
|
"remoteCopySourcesMethod": "rsync"
|
||||||
"variables": []
|
},
|
||||||
|
{
|
||||||
|
"name": "Linux-GCC-Release",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Release",
|
||||||
|
"cmakeExecutable": "cmake",
|
||||||
|
"remoteCopySourcesExclusionList": [ ".vs", ".git", "out" ],
|
||||||
|
"cmakeCommandArgs": "-D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "linux_x64" ],
|
||||||
|
"remoteMachineName": "${defaultRemoteMachineName}",
|
||||||
|
"remoteCMakeListsRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/src",
|
||||||
|
"remoteBuildRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/out/build/${name}",
|
||||||
|
"remoteInstallRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/out/install/${name}",
|
||||||
|
"remoteCopySources": true,
|
||||||
|
"rsyncCommandArgs": "-t --delete --delete-excluded",
|
||||||
|
"remoteCopyBuildOutput": false,
|
||||||
|
"remoteCopySourcesMethod": "rsync"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "Templates/Alignment.h"
|
#include "Templates/Alignment.h"
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
#include <corecrt_malloc.h>
|
#include <corecrt_malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ void* Malloc(size_t Count, uint32 Alignment)
|
|||||||
|
|
||||||
void* Result = nullptr;
|
void* Result = nullptr;
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
if (Count != 0) Result = _aligned_malloc(Count, Alignment);
|
if (Count != 0) Result = _aligned_malloc(Count, Alignment);
|
||||||
#else
|
#else
|
||||||
void* Ptr = SystemMalloc(Count + Alignment + sizeof(void*) + sizeof(size_t));
|
void* Ptr = SystemMalloc(Count + Alignment + sizeof(void*) + sizeof(size_t));
|
||||||
@ -36,7 +36,7 @@ void* Realloc(void* Ptr, size_t Count, uint32 Alignment)
|
|||||||
|
|
||||||
if (Ptr && Count)
|
if (Ptr && Count)
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
return _aligned_realloc(Ptr, Count, Alignment);
|
return _aligned_realloc(Ptr, Count, Alignment);
|
||||||
#else
|
#else
|
||||||
void* Result = Malloc(Count, Alignment);
|
void* Result = Malloc(Count, Alignment);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreTypes.h"
|
#include "CoreTypes.h"
|
||||||
|
#include "Misc/AssertionMacros.h"
|
||||||
|
@ -9,6 +9,40 @@
|
|||||||
|
|
||||||
NS_REDCRAFT_BEGIN
|
NS_REDCRAFT_BEGIN
|
||||||
|
|
||||||
|
// Build information macro.
|
||||||
|
|
||||||
|
#ifndef PLATFORM_NAME
|
||||||
|
#define PLATFORM_NAME Unknown
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_WINDOWS
|
||||||
|
#define PLATFORM_WINDOWS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_LINUX
|
||||||
|
#define PLATFORM_LINUX 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_UNKNOWN
|
||||||
|
#define PLATFORM_UNKNOWN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUILD_TYPE
|
||||||
|
#define BUILD_TYPE Unknown
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUILD_DEBUG
|
||||||
|
#define BUILD_DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUILD_RELEASE
|
||||||
|
#define BUILD_RELEASE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUILD_UNKNOWN
|
||||||
|
#define BUILD_UNKNOWN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// Function type macros.
|
// Function type macros.
|
||||||
|
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
|
52
Redcraft.Core/Source/Public/Misc/AssertionMacros.h
Normal file
52
Redcraft.Core/Source/Public/Misc/AssertionMacros.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreTypes.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
NS_REDCRAFT_BEGIN
|
||||||
|
|
||||||
|
NS_PRIVATE_BEGIN
|
||||||
|
|
||||||
|
class FRecursionScopeMarker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
FRecursionScopeMarker(uint8& InCounter) : Counter(InCounter) { ++Counter; }
|
||||||
|
~FRecursionScopeMarker() { --Counter; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint8& Counter;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_PRIVATE_END
|
||||||
|
|
||||||
|
#if BUILD_DEBUG
|
||||||
|
|
||||||
|
#define check_code(InCode) do { InCode; } while (false)
|
||||||
|
#define check(InExpr) assert(InExpr)
|
||||||
|
#define checkf(InExpr, InFormat, ...) assert(InExpr)
|
||||||
|
#define check_no_entry() checkf(false, "Enclosing block should never be called.")
|
||||||
|
#define check_no_reentry() { static bool bBeenHere##__LINE__ = false; checkf(!bBeenHere##__LINE__, "Enclosing block was called more than once."); bBeenHere##__LINE__ = true; }
|
||||||
|
#define check_no_recursion() static uint8 RecursionCounter##__LINE__ = 0; checkf(RecursionCounter##__LINE__ == 0, "Enclosing block was entered recursively."); const NS_PRIVATE::FRecursionScopeMarker ScopeMarker##__LINE__(RecursionCounter##__LINE__)
|
||||||
|
#define verify(InExpr) assert(InExpr)
|
||||||
|
#define verifyf(InExpr, InFormat, ...) assert(InExpr)
|
||||||
|
#define unimplemented() check(false, "Unimplemented function called.")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define check_code(...)
|
||||||
|
#define check(InExpr)
|
||||||
|
#define checkf(InExpr, InFormat, ...)
|
||||||
|
#define check_no_entry()
|
||||||
|
#define check_no_reentry()
|
||||||
|
#define check_no_recursion()
|
||||||
|
#define verify(InExpr) { if(InExpr) { } }
|
||||||
|
#define verifyf(InExpr, InFormat, ...) { if(InExpr) { } }
|
||||||
|
#define unimplemented()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_REDCRAFT_END
|
@ -10,9 +10,7 @@ NS_REDCRAFT_USING
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int32* Ptr = new int32;
|
check_no_entry();
|
||||||
*Ptr = 13;
|
cout << "Done!" << endl;
|
||||||
cout << *Ptr << endl;
|
|
||||||
delete Ptr;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user