From 8f3b08c826f1174019386c0bfe22627bb269123d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 4 Jan 2012 00:31:46 -0700 Subject: Attempt to generate version.h from git. --- default.bld | 25 +++++++++++++++++++++++++ src/.gitignore | 1 + src/main.cpp | 4 ++++ src/options.cpp | 25 +++++++++++++++++++++++++ src/options.h | 20 ++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 src/options.cpp create mode 100644 src/options.h diff --git a/default.bld b/default.bld index 0c7f50c..5c3d9b1 100644 --- a/default.bld +++ b/default.bld @@ -1,4 +1,29 @@ +target "src/version.h" +{ + requires ".git"; + profile "build" + { + fh = open("src/version.h.tmp"); + fh.write( +"#ifndef VERSION_H\n" +"#define VERSION_H\n" +"\n" +"#define FULLVER \"$(git describe)\"\n" +"\n" +"#endif"); + fh.close(); + if "$(cmp src/version.h.tmp src/version.h)" == "" then + { + execute("rm src/version.h.tmp"); + } + else + { + execute("mv src/version.h.tmp src/version.h"); + } + } +} + CC="g++"; target "stage" { diff --git a/src/.gitignore b/src/.gitignore index 6f29247..3492adb 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -2,3 +2,4 @@ parser.tab.c parser.tab.h parser.yy.c parser.yy.h +version.h diff --git a/src/main.cpp b/src/main.cpp index 6646d79..7e2ef7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include "gamebuilder.h" #include "game.h" #include "gamestate.h" +#include "options.h" #include #include @@ -14,6 +15,9 @@ using namespace Bu; int main( int argc, char *argv[] ) { + Options &opt = Options::getInstance(); + opt.parse( argc, argv ); + srandom( time( NULL ) ); GameBuilder bld; diff --git a/src/options.cpp b/src/options.cpp new file mode 100644 index 0000000..7953add --- /dev/null +++ b/src/options.cpp @@ -0,0 +1,25 @@ +#include "options.h" +#include "version.h" + +#include + +Options::Options() +{ +} + +Options::~Options() +{ +} + +void Options::parse( int argc, char *argv[] ) +{ + Bu::OptParser opt; + + opt.addHelpBanner("STAGE v" FULLVER + " - Simple, Textual, Adventure Game Environment"); + opt.addHelpBanner("usage: " + Bu::String(argv[0]) + + " [options] \n"); + opt.addHelpOption('h', "help"); + opt.parse( argc, argv ); +} + diff --git a/src/options.h b/src/options.h new file mode 100644 index 0000000..42caa53 --- /dev/null +++ b/src/options.h @@ -0,0 +1,20 @@ +#ifndef OPTIONS_H +#define OPTIONS_H + +#include +#include + +class Options : public Bu::Singleton +{ +friend class Bu::Singleton; +private: + Options(); + virtual ~Options(); + +public: + void parse( int argc, char *argv[] ); + + Bu::String sFile; +}; + +#endif -- cgit v1.2.3