mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
cmake: Configure source via cmake
silently fixing a bad malloc here too shhhhhhhhh
This commit is contained in:
parent
53799eb390
commit
0909fce2e3
8 changed files with 86 additions and 13 deletions
|
@ -69,10 +69,19 @@ endif()
|
||||||
set(SRB2_SDL2_EXE_NAME srb2)
|
set(SRB2_SDL2_EXE_NAME srb2)
|
||||||
set(SRB2_WIN_EXE_NAME srb2dd)
|
set(SRB2_WIN_EXE_NAME srb2dd)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(assets)
|
add_subdirectory(assets)
|
||||||
|
|
||||||
|
|
||||||
|
## config.h generation
|
||||||
|
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
||||||
|
include(GitUtilities)
|
||||||
|
git_describe(SRB2_COMP_REVISION "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### PACKAGE CONFIGURATION #####
|
##### PACKAGE CONFIGURATION #####
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,16 @@ set(SRB2_ASSET_ALL
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRB2_ASSET_HASHED
|
set(SRB2_ASSET_HASHED
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/srb2.srb
|
srb2.srb
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/player.dta
|
player.dta
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/rings.dta
|
rings.dta
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/zones.dta
|
zones.dta
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/patch.dta
|
patch.dta
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(SRB2_ASSET ${SRB2_ASSET_HASHED})
|
foreach(SRB2_ASSET ${SRB2_ASSET_HASHED})
|
||||||
file(MD5 ${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH")
|
file(MD5 ${CMAKE_CURRENT_SOURCE_DIR}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH")
|
||||||
|
set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
22
cmake/Modules/GitUtilities.cmake
Normal file
22
cmake/Modules/GitUtilities.cmake
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Git utilities
|
||||||
|
|
||||||
|
if(__GitUtilities)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(__GitUtilities ON)
|
||||||
|
|
||||||
|
function(git_describe variable path)
|
||||||
|
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe"
|
||||||
|
WORKING_DIRECTORY "${path}"
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
OUTPUT_VARIABLE output
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
#if(NOT result EQUAL 0)
|
||||||
|
# set(${variable} "GITERROR-${result}-NOTFOUND" CACHE STRING "revision" FORCE)
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
set(${variable} "${output}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
|
@ -160,6 +160,8 @@ set(SRB2_CORE_HEADERS
|
||||||
prepend_sources(SRB2_CORE_SOURCES)
|
prepend_sources(SRB2_CORE_SOURCES)
|
||||||
prepend_sources(SRB2_CORE_HEADERS)
|
prepend_sources(SRB2_CORE_HEADERS)
|
||||||
|
|
||||||
|
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
|
||||||
set(SRB2_HWRENDER_SOURCES
|
set(SRB2_HWRENDER_SOURCES
|
||||||
hardware/hw_bsp.c
|
hardware/hw_bsp.c
|
||||||
hardware/hw_cache.c
|
hardware/hw_cache.c
|
||||||
|
@ -358,4 +360,6 @@ if(NOT CLANG AND NOT MSVC)
|
||||||
add_compile_options(-mno-ms-bitfields)
|
add_compile_options(-mno-ms-bitfields)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DCMAKECONFIG)
|
||||||
|
|
||||||
add_subdirectory(sdl)
|
add_subdirectory(sdl)
|
||||||
|
|
|
@ -7,10 +7,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef COMPVERSION
|
#if (defined(CMAKECONFIG))
|
||||||
|
#include "config.h"
|
||||||
|
const char *comprevision = SRB2_COMP_REVISION;
|
||||||
|
|
||||||
|
#elif (defined(COMPVERSION))
|
||||||
#include "comptime.h"
|
#include "comptime.h"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
const char *comprevision = "illegal";
|
const char *comprevision = "illegal";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *compdate = __DATE__;
|
const char *compdate = __DATE__;
|
||||||
|
|
25
src/config.h.in
Normal file
25
src/config.h.in
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/** SRB2 CMake Configuration */
|
||||||
|
|
||||||
|
#ifndef __CONFIG_H__
|
||||||
|
#define __CONFIG_H__
|
||||||
|
|
||||||
|
#ifdef CMAKECONFIG
|
||||||
|
|
||||||
|
#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}"
|
||||||
|
#define ASSET_HASH_PLAYER_DTA "${SRB2_ASSET_player.dta_HASH}"
|
||||||
|
#define ASSET_HASH_RINGS_DTA "${SRB2_ASSET_rings.dta_HASH}"
|
||||||
|
#define ASSET_HASH_ZONES_DTA "${SRB2_ASSET_zones.dta_HASH}"
|
||||||
|
#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}"
|
||||||
|
|
||||||
|
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
|
||||||
|
#define ASSET_HASH_ZONES_DTA "303838c6c534d9540288360fa49cca60"
|
||||||
|
#define ASSET_HASH_PLAYER_DTA "cfca0f1c73023cbbd8f844f45480f799"
|
||||||
|
#define ASSET_HASH_RINGS_DTA "85901ad4bf94637e5753d2ac2c03ea26"
|
||||||
|
|
||||||
|
#define
|
||||||
|
#endif
|
||||||
|
#endif
|
14
src/d_main.c
14
src/d_main.c
|
@ -74,6 +74,12 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||||
#include "m_cond.h" // condition initialization
|
#include "m_cond.h" // condition initialization
|
||||||
#include "fastcmp.h"
|
#include "fastcmp.h"
|
||||||
|
|
||||||
|
#ifdef CMAKECONFIG
|
||||||
|
#include "config.h"
|
||||||
|
#else
|
||||||
|
#include "config.h.in"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#include "sdl/SRB2XBOX/xboxhelp.h"
|
#include "sdl/SRB2XBOX/xboxhelp.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1115,10 +1121,10 @@ void D_SRB2Main(void)
|
||||||
#if 1 // md5s last updated 12/14/14
|
#if 1 // md5s last updated 12/14/14
|
||||||
|
|
||||||
// Check MD5s of autoloaded files
|
// Check MD5s of autoloaded files
|
||||||
W_VerifyFileMD5(0, "c1b9577687f8a795104aef4600720ea7"); // srb2.srb/srb2.wad
|
W_VerifyFileMD5(0, ASSET_HASH_SRB2_SRB); // srb2.srb/srb2.wad
|
||||||
W_VerifyFileMD5(1, "303838c6c534d9540288360fa49cca60"); // zones.dta
|
W_VerifyFileMD5(1, ASSET_HASH_ZONES_DTA); // zones.dta
|
||||||
W_VerifyFileMD5(2, "cfca0f1c73023cbbd8f844f45480f799"); // player.dta
|
W_VerifyFileMD5(2, ASSET_HASH_PLAYER_DTA); // player.dta
|
||||||
W_VerifyFileMD5(3, "85901ad4bf94637e5753d2ac2c03ea26"); // rings.dta
|
W_VerifyFileMD5(3, ASSET_HASH_RINGS_DTA); // rings.dta
|
||||||
//W_VerifyFileMD5(4, "0c66790502e648bfce90fdc5bb15722e"); // patch.dta
|
//W_VerifyFileMD5(4, "0c66790502e648bfce90fdc5bb15722e"); // patch.dta
|
||||||
// don't check music.dta because people like to modify it, and it doesn't matter if they do
|
// don't check music.dta because people like to modify it, and it doesn't matter if they do
|
||||||
// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
|
// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
|
||||||
|
|
|
@ -210,8 +210,8 @@ static void F_DoWipe(fademask_t *fademask)
|
||||||
UINT32 draw_linestogo, draw_rowstogo;
|
UINT32 draw_linestogo, draw_rowstogo;
|
||||||
|
|
||||||
// rectangle coordinates, etc.
|
// rectangle coordinates, etc.
|
||||||
UINT16* scrxpos = (UINT16*)malloc(fademask->width + 1); //[fademask->width + 1];
|
UINT16* scrxpos = (UINT16*)malloc((fademask->width + 1) * sizeof(UINT16));
|
||||||
UINT16* scrypos = (UINT16*)malloc(fademask->height + 1);// [fademask->height + 1];
|
UINT16* scrypos = (UINT16*)malloc((fademask->height + 1) * sizeof(UINT16));
|
||||||
UINT16 maskx, masky;
|
UINT16 maskx, masky;
|
||||||
UINT32 relativepos;
|
UINT32 relativepos;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue