summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-10-18 16:09:51 -0700
committerMatthew Cline <zelgadis@sourceforge.net>2009-10-18 16:09:51 -0700
commitdee470bf63c25c3d99ea89e9d9f5979ab01d53bb (patch)
tree0b8a3a91c89e0ad6713e62702dfc23bf875ec9b7 /crawl-ref
parentb3475474824eb75feb901ed9fa3b5826626a185b (diff)
downloadcrawl-ref-dee470bf63c25c3d99ea89e9d9f5979ab01d53bb.tar.gz
crawl-ref-dee470bf63c25c3d99ea89e9d9f5979ab01d53bb.zip
Add compilation information to Version namespace
The Version namespace now provides the compiler which was used, the OS, machine type and processor type the compilation was done on, and the CFLAGS, CFLAGS_L and LDFLAGS which were used. If GCC was the compiler, it also provides the compiler version. This information is included in crash reports, and can be dumped using the new command line option "-version".
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/.gitignore2
-rw-r--r--crawl-ref/source/acr.cc1
-rw-r--r--crawl-ref/source/debug.cc32
-rw-r--r--crawl-ref/source/initfile.cc14
-rw-r--r--crawl-ref/source/makefile35
-rwxr-xr-xcrawl-ref/source/util/gen_ver.pl12
-rw-r--r--crawl-ref/source/version.cc69
-rw-r--r--crawl-ref/source/version.h47
8 files changed, 206 insertions, 6 deletions
diff --git a/crawl-ref/.gitignore b/crawl-ref/.gitignore
index cbc37c3f7a..2dc2260a9d 100644
--- a/crawl-ref/.gitignore
+++ b/crawl-ref/.gitignore
@@ -39,6 +39,8 @@ mapgen.log
# Makefile-generated junk
makefile.dep
/source/.contrib-ok
+/source/compflag.h
+/source/.compflag.h
# The Crawl executable.
/source/crawl
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 1dea38d6ad..6d576bb76d 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -302,6 +302,7 @@ static void _show_commandline_options_help()
puts(" -rcdir <dir> directory that contains (included) rc files");
puts(" -morgue <dir> directory to save character dumps");
puts(" -macro <dir> directory to save/find macro.txt");
+ puts(" -version Crawl version (and compilation info)");
puts("");
puts("Command line options override init file options, which override");
puts("environment options (CRAWL_NAME, CRAWL_DIR, CRAWL_RC).");
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 42abd42203..52c28e0dbc 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -6040,6 +6040,18 @@ static void _dump_levgen()
mpr("");
}
+static void _dump_compilation_info(FILE* file)
+{
+ std::string comp_info = compilation_info();
+ if (!comp_info.empty())
+ {
+ fprintf(file, "Compilation info:" EOL);
+ fprintf(file, "<<<<<<<<<<<" EOL);
+ fprintf(file, "%s", comp_info.c_str());
+ fprintf(file, ">>>>>>>>>>>" EOL EOL);
+ }
+}
+
static void _dump_level_info(FILE* file)
{
CrawlHashTable &props = env.properties;
@@ -6506,8 +6518,23 @@ void do_crash_dump()
fprintf(file, "Version: %s %s" EOL, CRAWL, Version::Long().c_str());
#if defined(UNIX)
- fprintf(file, "Platform: unix" EOL);
+ fprintf(file, "Platform: unix");
+# if defined(TARGET_OS_MACOSX)
+ fprintf(file, " (OS X)");
+# endif
+ fprintf(file, EOL);
+#elif defined(TARGET_OS_WINDOWS)
+ fprintf(file, "Platform: Windows" EOL);
+#elif defined(TARGET_OS_DOS)
+ fprintf(file, "Platform: DOS" EOL);
+#endif // UNIX
+
+#if TARGET_CPU_BITS == 64
+ fprintf(file, "Bits: 64" EOL);
+#else
+ fprintf(file, "Bits: 32" EOL);
#endif
+
#ifdef USE_TILE
fprintf(file, "Tiles: yes" EOL EOL);
#else
@@ -6522,6 +6549,9 @@ void do_crash_dump()
fprintf(file, EOL);
+ // Next information on how the binary was compiled
+ _dump_compilation_info(file);
+
// Next information about the level the player is on, plus level
// generation info if the crash happened during level generation.
_dump_level_info(file);
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 162b97fd2f..6c9072505a 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -3514,6 +3514,7 @@ enum commandline_option_type {
CLO_ARENA,
CLO_TEST,
CLO_HELP,
+ CLO_VERSION,
CLO_NOPS
};
@@ -3521,7 +3522,7 @@ enum commandline_option_type {
static const char *cmd_ops[] = {
"scores", "name", "species", "job", "plain", "dir", "rc",
"rcdir", "tscores", "vscores", "scorefile", "morgue", "macro",
- "mapstat", "arena", "test", "help"
+ "mapstat", "arena", "test", "help", "version"
};
const int num_cmd_ops = CLO_NOPS;
@@ -3554,6 +3555,13 @@ std::string find_executable_path()
return std::string(tempPath);
}
+static void _print_version()
+{
+ printf("Crawl version %s" EOL, Version::Long().c_str());
+
+ printf("%s", compilation_info().c_str());
+}
+
bool parse_args( int argc, char **argv, bool rc_only )
{
COMPILE_CHECK(ARRAYSZ(cmd_ops) == CLO_NOPS, c1);
@@ -3798,6 +3806,10 @@ bool parse_args( int argc, char **argv, bool rc_only )
case CLO_HELP:
// Shouldn't happen.
return (false);
+
+ case CLO_VERSION:
+ _print_version();
+ end(0);
}
// Update position.
diff --git a/crawl-ref/source/makefile b/crawl-ref/source/makefile
index e9d5421bc0..0d30dddc9d 100644
--- a/crawl-ref/source/makefile
+++ b/crawl-ref/source/makefile
@@ -34,7 +34,6 @@ CFOTHERS_L := -fsigned-char
CFWARN := -Wall
MAKEFLAGS := --no-print-directory
-
#
# The GCC and GXX variables are set later.
#
@@ -591,12 +590,12 @@ ifneq ($(MAKECMDGOALS),distclean)
endif
endif
-.INTERMEDIATE: build.h
+.INTERMEDIATE: build.h compflag.h
build.h:
$(QUIET_GEN)util/gen_ver.pl $@
-version.cc: build.h
+version.cc: build.h compflag.h
##########################################################################
# The level compiler
@@ -682,7 +681,35 @@ distclean: clean clean-contrib clean-rltiles
done
@touch .contrib-ok
-$(GAME): $(GAME_DEPENDS)
+# This information is included in crash reports, and is printed with
+# "crawl -version"
+compile-flags:
+ @echo "// Automatically generated by makefile" > .compflag.h
+ @echo "#ifndef __included_crawl_compiler_flags_h" >> .compflag.h
+ @echo "#define __included_crawl_compiler_flags_h" >> .compflag.h
+
+ @echo -n "#define CRAWL_CFLAGS \"" >> .compflag.h
+ @echo -n $(CFLAGS) | sed s/\"/\\\"/g >> .compflag.h
+ @echo "\"" >> .compflag.h
+
+ @echo -n "#define CRAWL_CFLAGS_L \"" >> .compflag.h
+ @echo -n $(CFLAGS_L) | sed s/\"/\\\"/g >> .compflag.h
+ @echo "\"" >> .compflag.h
+
+ @echo -n "#define CRAWL_LDFLAGS \"" >> .compflag.h
+ @echo -n $(LDFLAGS) | sed s/\"/\\\"/g >> .compflag.h
+ @echo "\"" >> .compflag.h
+
+ @echo "#endif" >> .compflag.h
+
+ @if [ "`diff -N -q .compflag.h compflag.h`" ]; then \
+ echo Updating compflag.h; \
+ mv .compflag.h compflag.h; \
+ fi
+
+compflag.h: compile-flags
+
+$(GAME): $(GAME_DEPENDS) compile-flags
$(QUIET_LINK)$(CXX) $(LDFLAGS) $(EXTRA_OBJECTS) $(OBJECTS) -o $(GAME) $(LIB)
debug: $(GAME)
diff --git a/crawl-ref/source/util/gen_ver.pl b/crawl-ref/source/util/gen_ver.pl
index b6ace87a15..bccb73f5b2 100755
--- a/crawl-ref/source/util/gen_ver.pl
+++ b/crawl-ref/source/util/gen_ver.pl
@@ -106,6 +106,14 @@ if ( $verstring ne $tag || !$pretyp ) {
}
}
+my $OS = `uname -o`;
+my $machine = `uname -m`;
+my $processor = `uname -p`;
+
+chomp($OS);
+chomp($machine);
+chomp($processor);
+
unlink("$outfile.tmp");
my $prefix = "CRAWL";
@@ -128,6 +136,10 @@ print OUT <<__eof__;
#define ${prefix}_RESOURCE_VERSION ${major},${minor},${revis},${build}
#define ${prefix}_RESOURCE_VERSION_STRING "${major}, ${minor}, ${revis}, ${build}"
+#define ${prefix}_BUILD_OS "${OS}"
+#define ${prefix}_BUILD_MACHINE "${machine}"
+#define ${prefix}_BUILD_PROCESSOR "${processor}"
+
#endif
__eof__
diff --git a/crawl-ref/source/version.cc b/crawl-ref/source/version.cc
index 0805bb5c8e..6d9ee55797 100644
--- a/crawl-ref/source/version.cc
+++ b/crawl-ref/source/version.cc
@@ -7,6 +7,7 @@
#include "AppHdr.h"
#include "build.h"
+#include "compflag.h"
namespace Version
{
@@ -49,5 +50,73 @@ namespace Version
{
return CRAWL_VERSION_PREREL_NUM;
}
+
+ std::string Compiler()
+ {
+#if defined(__GNUC__) && defined(__VERSION__)
+ return make_stringf("GCC %s", __VERSION__);
+#elif defined(__GNUC__)
+ return ("GCC (unknown version)");
+#elif defined(TARGET_COMPILER_MINGW)
+ return ("MINGW");
+#elif defined(TARGET_COMPILER_CYGWIN)
+ return ("CYGWIN");
+#elif defined(TARGET_COMPILER_VC)
+ return ("Visual C++");
+#elif defined(TARGET_COMPILER_ICC)
+ return ("Intel C++");
+#else
+ return ("Unknown compiler");
+#endif
+ }
+
+ std::string BuildOS()
+ {
+ return CRAWL_BUILD_OS;
+ }
+
+ std::string BuildMachine()
+ {
+ return CRAWL_BUILD_MACHINE;
+ }
+
+ std::string BuildProcessor()
+ {
+ return CRAWL_BUILD_PROCESSOR;
+ }
+
+ std::string CFLAGS()
+ {
+ return CRAWL_CFLAGS;
+ }
+
+ std::string CFLAGS_L()
+ {
+ return CRAWL_CFLAGS_L;
+ }
+
+ std::string LDFLAGS()
+ {
+ return CRAWL_LDFLAGS;
+ }
}
+std::string compilation_info()
+{
+ std::string out = "";
+
+ out += make_stringf("Compiled with %s on %s at %s" EOL,
+ Version::Compiler().c_str(), __DATE__, __TIME__);
+ out += make_stringf("Compiled on OS: %s" EOL,
+ Version::BuildOS().c_str());
+ out += make_stringf("Compiled on machine type: %s" EOL,
+ Version::BuildMachine().c_str());
+ out += make_stringf("Compiled on processor type: %s" EOL,
+ Version::BuildProcessor().c_str());
+
+ out += make_stringf("CLFAGS: %s" EOL, Version::CFLAGS().c_str());
+ out += make_stringf("CFLAGS_L: %s" EOL, Version::CFLAGS_L().c_str());
+ out += make_stringf("LDFLAGS: %s" EOL, Version::LDFLAGS().c_str());
+
+ return (out);
+}
diff --git a/crawl-ref/source/version.h b/crawl-ref/source/version.h
index 8b8341b2a3..660b38ff92 100644
--- a/crawl-ref/source/version.h
+++ b/crawl-ref/source/version.h
@@ -85,6 +85,53 @@ namespace Version
* will return the alpha/beta/rc number. Otherwise, this returns 0.
*/
int ReleaseID();
+
+ //! The compiler used.
+ /*!
+ * Names the compiler used to genrate the executable.
+ */
+ std::string Compiler();
+
+ //! The operating system.
+ /*!
+ * Names the operating system that the executable was compiled on.
+ */
+ std::string BuildOS();
+
+ //! The machine type.
+ /*!
+ * Names the machine type (e.g., "i686") the executable was compiled on.
+ */
+ std::string BuildMachine();
+
+ //! The processor type.
+ /*!
+ * Names the processor type the executable was compiled on.
+ */
+ std::string BuildProcessor();
+
+ //! The CFLAGS.
+ /*!
+ * Returns the CFLAGS the executable was compiled with.
+ */
+ std::string CFLAGS();
+
+ //! The CFLAGS_L.
+ /*!
+ * Returns the CFLAGS_L the executable was compiled with.
+ */
+ std::string CFLAGS_L();
+
+ //! The LDFLAGS.
+ /*!
+ * Returns the flags the executable was linked with.
+ */
+ std::string LDFLAGS();
}
+/* ***********************************************************************
+ * called from: initfile debug
+ * *********************************************************************** */
+std::string compilation_info();
+
#endif