cmake: Configure source via cmake

silently fixing a bad malloc here too shhhhhhhhh
This commit is contained in:
Ronald Kinard 2015-01-28 18:03:41 -06:00
parent 53799eb390
commit 0909fce2e3
8 changed files with 86 additions and 13 deletions

View file

@ -69,10 +69,19 @@ endif()
set(SRB2_SDL2_EXE_NAME srb2)
set(SRB2_WIN_EXE_NAME srb2dd)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
add_subdirectory(src)
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 #####

View file

@ -11,15 +11,16 @@ set(SRB2_ASSET_ALL
)
set(SRB2_ASSET_HASHED
${CMAKE_CURRENT_SOURCE_DIR}/srb2.srb
${CMAKE_CURRENT_SOURCE_DIR}/player.dta
${CMAKE_CURRENT_SOURCE_DIR}/rings.dta
${CMAKE_CURRENT_SOURCE_DIR}/zones.dta
${CMAKE_CURRENT_SOURCE_DIR}/patch.dta
srb2.srb
player.dta
rings.dta
zones.dta
patch.dta
)
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()
# Installation

View 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()

View file

@ -160,6 +160,8 @@ set(SRB2_CORE_HEADERS
prepend_sources(SRB2_CORE_SOURCES)
prepend_sources(SRB2_CORE_HEADERS)
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set(SRB2_HWRENDER_SOURCES
hardware/hw_bsp.c
hardware/hw_cache.c
@ -358,4 +360,6 @@ if(NOT CLANG AND NOT MSVC)
add_compile_options(-mno-ms-bitfields)
endif()
add_definitions(-DCMAKECONFIG)
add_subdirectory(sdl)

View file

@ -7,10 +7,16 @@
*
*/
#ifdef COMPVERSION
#if (defined(CMAKECONFIG))
#include "config.h"
const char *comprevision = SRB2_COMP_REVISION;
#elif (defined(COMPVERSION))
#include "comptime.h"
#else
const char *comprevision = "illegal";
#endif
const char *compdate = __DATE__;

25
src/config.h.in Normal file
View 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

View file

@ -74,6 +74,12 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "m_cond.h" // condition initialization
#include "fastcmp.h"
#ifdef CMAKECONFIG
#include "config.h"
#else
#include "config.h.in"
#endif
#ifdef _XBOX
#include "sdl/SRB2XBOX/xboxhelp.h"
#endif
@ -1115,10 +1121,10 @@ void D_SRB2Main(void)
#if 1 // md5s last updated 12/14/14
// Check MD5s of autoloaded files
W_VerifyFileMD5(0, "c1b9577687f8a795104aef4600720ea7"); // srb2.srb/srb2.wad
W_VerifyFileMD5(1, "303838c6c534d9540288360fa49cca60"); // zones.dta
W_VerifyFileMD5(2, "cfca0f1c73023cbbd8f844f45480f799"); // player.dta
W_VerifyFileMD5(3, "85901ad4bf94637e5753d2ac2c03ea26"); // rings.dta
W_VerifyFileMD5(0, ASSET_HASH_SRB2_SRB); // srb2.srb/srb2.wad
W_VerifyFileMD5(1, ASSET_HASH_ZONES_DTA); // zones.dta
W_VerifyFileMD5(2, ASSET_HASH_PLAYER_DTA); // player.dta
W_VerifyFileMD5(3, ASSET_HASH_RINGS_DTA); // rings.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
// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.

View file

@ -210,8 +210,8 @@ static void F_DoWipe(fademask_t *fademask)
UINT32 draw_linestogo, draw_rowstogo;
// rectangle coordinates, etc.
UINT16* scrxpos = (UINT16*)malloc(fademask->width + 1); //[fademask->width + 1];
UINT16* scrypos = (UINT16*)malloc(fademask->height + 1);// [fademask->height + 1];
UINT16* scrxpos = (UINT16*)malloc((fademask->width + 1) * sizeof(UINT16));
UINT16* scrypos = (UINT16*)malloc((fademask->height + 1) * sizeof(UINT16));
UINT16 maskx, masky;
UINT32 relativepos;