Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generate MOJOSHADER_VERSION, etc.
  • Loading branch information
icculus committed Nov 6, 2008
1 parent d62da71 commit 77e0d84
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions .hgignore
@@ -1,4 +1,5 @@
syntax:glob
mojoshader_version.h
CMakeCache.txt
CMakeFiles
Makefile
Expand Down
27 changes: 27 additions & 0 deletions CMakeLists.txt
@@ -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)
Expand Down
6 changes: 6 additions & 0 deletions mojoshader.c
Expand Up @@ -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 ...

22 changes: 21 additions & 1 deletion mojoshader.h
Expand Up @@ -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
Expand Down

0 comments on commit 77e0d84

Please sign in to comment.