Skip to content
Permalink
Browse files
Generate MOJOSHADER_VERSION, etc.
  • Loading branch information
icculus committed Nov 6, 2008
1 parent d62da71 commit 77e0d845087fb92b2ff45b4011daa77526f9816d
Showing with 55 additions and 1 deletion.
  1. +1 −0 .hgignore
  2. +27 −0 CMakeLists.txt
  3. +6 −0 mojoshader.c
  4. +21 −1 mojoshader.h
@@ -1,4 +1,5 @@
syntax:glob
mojoshader_version.h
CMakeCache.txt
CMakeFiles
Makefile
@@ -1,6 +1,33 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
PROJECT(MojoShader)

EXECUTE_PROCESS(
COMMAND hg tip --template {rev}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE HGVERSION_RC
OUTPUT_VARIABLE MOJOSHADER_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
COMMAND hg tip --template hg-{rev}:{node|short}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE HGVERSION_RC
OUTPUT_VARIABLE MOJOSHADER_CHANGESET
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

WRITE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
"/* This file was autogenerated. Do not edit! */\n"
"#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
"#define _INCL_MOJOSHADER_VERSION_H_\n"
"#define MOJOSHADER_VERSION ${MOJOSHADER_VERSION}\n"
"#define MOJOSHADER_CHANGESET \"${MOJOSHADER_CHANGESET}\"\n"
"#endif\n"
)

IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-Wall -ggdb3)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
@@ -7702,5 +7702,11 @@ int MOJOSHADER_version(void)
return MOJOSHADER_VERSION;
} // MOJOSHADER_version


const char *MOJOSHADER_changeset(void)
{
return MOJOSHADER_CHANGESET;
} // MOJOSHADER_changeset

// end of mojoshader.c ...

@@ -14,16 +14,36 @@
extern "C" {
#endif

/* You can define this if you aren't generating mojoshader_version.h */
#ifndef MOJOSHADER_NO_VERSION_INCLUDE
#include "mojoshader_version.h"
#else
#define MOJOSHADER_VERSION -1
#define MOJOSHADER_CHANGESET "???"
#endif

/*
* For determining the version of MojoShader you are using:
* const int compiled_against = MOJOSHADER_VERSION;
* const int linked_against = MOJOSHADER_version();
*
* The version is a single integer that increments, not a major/minor value.
*/
#define MOJOSHADER_VERSION 1
int MOJOSHADER_version(void);

/*
* For determining the revision control changeste of MojoShader you are using:
* const const *compiled_against = MOJOSHADER_CHANGESET;
* const char *linked_against = MOJOSHADER_changeset();
*
* The version is an arbitrary, null-terminated ASCII string. It is probably
* a hash that represents a revision control changeset, and can't be
* compared to any other string to determine chronology.
*
* Do not attempt to free this string; it's statically allocated.
*/
const char *MOJOSHADER_changeset(void);

/*
* These allocators work just like the C runtime's malloc() and free()
* (in fact, they probably use malloc() and free() internally if you don't

0 comments on commit 77e0d84

Please sign in to comment.