[Scummvm-cvs-logs] SF.net SVN: scummvm:[48576] tools/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Apr 7 00:01:25 CEST 2010
Revision: 48576
http://scummvm.svn.sourceforge.net/scummvm/?rev=48576&view=rev
Author: fingolfin
Date: 2010-04-06 22:01:25 +0000 (Tue, 06 Apr 2010)
Log Message:
-----------
TOOLS: Add version information to tools
Modified Paths:
--------------
tools/trunk/Makefile.common
tools/trunk/configure
tools/trunk/gui/main.cpp
tools/trunk/scummvm-tools-cli.cpp
tools/trunk/scummvm-tools-cli.h
tools/trunk/tool.cpp
tools/trunk/tool.h
Added Paths:
-----------
tools/trunk/internal_version.h
tools/trunk/internal_version.h.in
tools/trunk/update-version.pl
tools/trunk/version.cpp
tools/trunk/version.h
Modified: tools/trunk/Makefile.common
===================================================================
--- tools/trunk/Makefile.common 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/Makefile.common 2010-04-06 22:01:25 UTC (rev 48576)
@@ -46,19 +46,6 @@
# to module.mk style files.
-# Replace regular output with quiet messages
-ifneq ($(findstring $(MAKEFLAGS),s),s)
-ifneq ($(VERBOSE_BUILD),1)
-ifneq ($(VERBOSE_BUILD),yes)
-QUIET_CXX = @echo ' ' C++ ' ' $@;
-QUIET_AR = @echo ' ' AR ' ' $@;
-QUIET_RANLIB = @echo ' ' RANLIB ' ' $@;
-QUIET_LINK = @echo ' ' LINK ' ' $(1);
-QUIET = @
-endif
-endif
-endif
-
#######################################################################
TARGETS := \
@@ -151,9 +138,15 @@
engines/scumm/descumm.o \
engines/scumm/descumm6.o \
engines/scumm/descumm-common.o \
- tool.o $(UTILS)
+ tool.o \
+ version.o \
+ $(UTILS)
-desword2_OBJS := engines/sword2/desword2.o tool.o $(UTILS)
+desword2_OBJS := \
+ engines/sword2/desword2.o \
+ tool.o \
+ version.o \
+ $(UTILS)
degob_OBJS := \
engines/gob/degob.o \
@@ -167,6 +160,7 @@
engines/gob/degob_script_bargon.o \
engines/gob/degob_script_fascin.o \
tool.o \
+ version.o \
$(UTILS)
extract_mohawk_OBJS := \
@@ -227,6 +221,7 @@
compress.o \
tool.o \
tools.o \
+ version.o \
$(UTILS)
ifdef USE_PNG
@@ -257,6 +252,16 @@
scummvm-tools-cli_LIBS := $(LIBS)
+# Make base/version.o depend on all other object files. This way if anything is
+# changed, it causes version.cpp to be recompiled. This in turn ensures that
+# the build date in gScummVMBuildDate is correct.
+version.o: $(filter-out version.o,$(descumm_OBJS))
+version.o: $(filter-out version.o,$(desword2_OBJS))
+version.o: $(filter-out version.o,$(degob_OBJS))
+version.o: $(filter-out version.o,$(scummvm-tools_OBJS))
+version.o: $(filter-out version.o,$(scummvm-tools-cli_OBJS))
+
+
######################################################################
@@ -296,6 +301,19 @@
DEPDIRS = $(addsuffix $(DEPDIR),$(MODULE_DIRS))
DEPFILES =
+# Replace regular output with quiet messages
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifneq ($(VERBOSE_BUILD),1)
+ifneq ($(VERBOSE_BUILD),yes)
+QUIET_CXX = @echo ' ' C++ ' ' $@;
+QUIET_AR = @echo ' ' AR ' ' $@;
+QUIET_RANLIB = @echo ' ' RANLIB ' ' $@;
+QUIET_LINK = @echo ' ' LINK ' ' $(1);
+QUIET = @
+endif
+endif
+endif
+
ifdef CXX_UPDATE_DEP_FLAG
# Build rule for C++ files. Makes use of CXX_UPDATE_DEP_FLAG for advanced
@@ -315,3 +333,42 @@
# Include the dependency tracking files.
-include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
+
+# Mark *.d files and most *.mk files as PHONY. This stops make from trying to
+# recreate them (which it can't), and in particular from looking for potential
+# source files. This can save quite a bit of disk access time.
+.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS))) $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES))) \
+ $(srcdir)/$(port_mk) $(srcdir)/rules.mk $(srcdir)/engines/engines.mk
+
+######################################################################
+# Get the current version information
+######################################################################
+
+# AmigaOS4's grep has a problem with "./" in pathnames, so use cat.
+VERSION = $(shell cat "${srcdir}/internal_version.h" | grep SCUMMVM_TOOLS_VERSION | cut -d\" -f2)
+VER_MAJOR = $(shell echo $(VERSION) | cut -d. -f 1)
+VER_MINOR = $(shell echo $(VERSION) | cut -d. -f 2)
+VER_PATCH = $(shell echo $(VERSION) | cut -d. -f 3 | cut -c1)
+VER_EXTRA = $(shell echo $(VERSION) | cut -d. -f 3 | cut -c2-)
+
+
+######################################################################
+# Get Subversion's working copy information
+######################################################################
+
+ifeq ($(shell LANG=C svn stat $(srcdir) 2>&1 | grep "is not a working copy"),)
+SVNROOT := $(srcdir)
+ifeq ($(origin SVNREV), undefined)
+# Get the working copy base revision
+VER_SVNREV := $(shell LANG=C svn info $(SVNROOT) | grep "^Revision" | cut -d ' ' -f 2)
+endif
+else
+SVNROOT := https://scummvm.svn.sourceforge.net/svnroot/scummvm/tools/trunk/
+endif
+
+# Define the Subversion revision if available, either autodetected or
+# specified by the user
+ifneq ($(origin VER_SVNREV), undefined)
+CXXFLAGS+= -DSCUMMVM_TOOLS_SVN_REVISION=\"$(VER_SVNREV)\"
+endif
+
Modified: tools/trunk/configure
===================================================================
--- tools/trunk/configure 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/configure 2010-04-06 22:01:25 UTC (rev 48576)
@@ -262,7 +262,7 @@
-h, --help display this help and exit
Installation directories:
- --prefix=DIR use this prefix for installing the Tools [/usr/local]
+ --prefix=DIR use this prefix for installing the ScummVM Tools [/usr/local]
--bindir=DIR directory to install the tool binaries in [PREFIX/bin]
--mandir=DIR directory to install the manpage in [PREFIX/share/man]
--libdir=DIR directory to install the plugins in [PREFIX/lib]
@@ -722,17 +722,11 @@
#
echo_n "Alignment required... "
case $_host_cpu in
- arm*)
- _need_memalign=yes
- ;;
alpha*)
# Hardcode alignment requirements for Alpha processsors
_need_memalign=yes
;;
- sh*)
- # Hardcode alignment requirements for SH processsors.
- # While these can emulate unaligned memory access, this
- # emulation is rather slow.
+ arm*)
_need_memalign=yes
;;
mips*)
@@ -741,6 +735,12 @@
# emulation is rather slow.
_need_memalign=yes
;;
+ sh*)
+ # Hardcode alignment requirements for SH processsors.
+ # While these can emulate unaligned memory access, this
+ # emulation is rather slow.
+ _need_memalign=yes
+ ;;
*)
# Try to auto-detect....
cat > $TMPC << EOF
@@ -1113,7 +1113,7 @@
# Some platforms use certain GNU extensions in header files
case $_host_os in
-wii | gamecube | psp)
+gamecube | psp | wii)
;;
*)
CXXFLAGS="$CXXFLAGS -pedantic"
Modified: tools/trunk/gui/main.cpp
===================================================================
--- tools/trunk/gui/main.cpp 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/gui/main.cpp 2010-04-06 22:01:25 UTC (rev 48576)
@@ -36,10 +36,11 @@
#include <wx/hyperlink.h>
#include <wx/notebook.h>
-#include "main.h"
+#include "gui/main.h"
+#include "gui/pages.h"
+#include "gui/gui_tools.h"
-#include "pages.h"
-#include "gui_tools.h"
+#include "version.h"
/**
@@ -109,7 +110,7 @@
titletext->SetFont(wxFont(22, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Arial")));
sizer->Add(titletext, wxSizerFlags());
- wxStaticText *versiontext = new wxStaticText(dialog, wxID_ANY, wxT("Development Version"));
+ wxStaticText *versiontext = new wxStaticText(dialog, wxID_ANY, wxString(gScummVMToolsVersionDate, wxConvISO8859_1));
versiontext->SetForegroundColour(wxColor(128, 128, 128));
versiontext->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Arial")));
sizer->Add(versiontext, wxSizerFlags());
Added: tools/trunk/internal_version.h
===================================================================
--- tools/trunk/internal_version.h (rev 0)
+++ tools/trunk/internal_version.h 2010-04-06 22:01:25 UTC (rev 48576)
@@ -0,0 +1,5 @@
+#ifndef SCUMMVM_TOOLS_SVN_REVISION
+#define SCUMMVM_TOOLS_SVN_REVISION
+#endif
+
+#define SCUMMVM_TOOLS_VERSION "1.1.0svn" SCUMMVM_TOOLS_SVN_REVISION
Property changes on: tools/trunk/internal_version.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/trunk/internal_version.h.in
===================================================================
--- tools/trunk/internal_version.h.in (rev 0)
+++ tools/trunk/internal_version.h.in 2010-04-06 22:01:25 UTC (rev 48576)
@@ -0,0 +1,5 @@
+#ifndef SCUMMVM_TOOLS_SVN_REVISION
+#define SCUMMVM_TOOLS_SVN_REVISION
+#endif
+
+#define SCUMMVM_TOOLS_VERSION "@VERSION@" SCUMMVM_TOOLS_SVN_REVISION
Property changes on: tools/trunk/internal_version.h.in
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: tools/trunk/scummvm-tools-cli.cpp
===================================================================
--- tools/trunk/scummvm-tools-cli.cpp 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/scummvm-tools-cli.cpp 2010-04-06 22:01:25 UTC (rev 48576)
@@ -25,6 +25,7 @@
#include <assert.h>
#include "scummvm-tools-cli.h"
+#include "version.h"
ToolsCLI::ToolsCLI() {
}
@@ -33,9 +34,6 @@
}
int ToolsCLI::run(int argc, char *argv[]) {
- // No matter what we ouput, we should begin with a newline
- std::cout << std::endl;
-
if (argc == 1) {
// Run without any arguments
printHelp(argv[0]);
@@ -85,6 +83,8 @@
return 2;
} else if (option == "--list" || option == "-l") {
printTools();
+ } else if (option == "--version") {
+ printVersion();
} else {
ToolList choices;
std::deque<std::string>::reverse_iterator reader = arguments.rbegin();
@@ -195,18 +195,24 @@
void ToolsCLI::printHelp(const char *exeName) {
std::cout <<
- "\tScummVM Tools master interface" << std::endl <<
+ gScummVMToolsFullVersion << std::endl <<
std::endl <<
- "\tCommon use:" << std::endl <<
- "\t" << exeName << " [--tool <tool name>] [tool-specific options] [-o <output directory>] <input files>" << std::endl <<
- "\t" << exeName << " [tool-specific option] [-o <output directory>] [extract|compress] <input files>" << std::endl <<
+ "Common use:" << std::endl <<
+ " " << exeName << " [--tool <tool name>] [tool-specific options] [-o <output directory>] <input files>" << std::endl <<
+ " " << exeName << " [tool-specific option] [-o <output directory>] [extract|compress] <input files>" << std::endl <<
std::endl <<
- "\tOther Options:" << std::endl <<
- "\t--help\tDisplay this text" << std::endl <<
- "\t--list\tList all tools that are available" << std::endl <<
+ "Other Options:" << std::endl <<
+ " --help\tDisplay this text" << std::endl <<
+ " --version\tDisplay version information" << std::endl <<
+ " --list\tList all tools that are available" << std::endl <<
"";
}
+void ToolsCLI::printVersion() {
+ std::cout <<
+ gScummVMToolsFullVersion << std::endl;
+}
+
void ToolsCLI::printTools() {
std::cout << std::endl << "All available tools:" << std::endl;
for (ToolList::iterator tool = _tools.begin(); tool != _tools.end(); ++tool)
Modified: tools/trunk/scummvm-tools-cli.h
===================================================================
--- tools/trunk/scummvm-tools-cli.h 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/scummvm-tools-cli.h 2010-04-06 22:01:25 UTC (rev 48576)
@@ -35,6 +35,7 @@
int run(int argc, char *argv[]);
void printHelp(const char *exeName);
+ void printVersion();
void printTools();
};
Modified: tools/trunk/tool.cpp
===================================================================
--- tools/trunk/tool.cpp 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/tool.cpp 2010-04-06 22:01:25 UTC (rev 48576)
@@ -28,6 +28,7 @@
#include "common/file.h"
#include "tool.h"
+#include "version.h"
Tool::Tool(const std::string &name, ToolType type) {
_name = name;
@@ -62,10 +63,16 @@
// Check for help
if (_arguments.empty() || _arguments.front() == "-h" || _arguments.front() == "--help") {
- print(getHelp().c_str());
+ print(getHelp());
return 2;
}
+ // Check for version
+ if (_arguments.front() == "--version") {
+ print(getVersion());
+ return 2;
+ }
+
// Read standard arguments
parseAudioArguments();
parseOutputArguments();
@@ -74,7 +81,7 @@
if (!_arguments.empty() && _arguments.front()[0] == '-') {
std::string s = "Possibly ignored option " + _arguments.front() + ".";
- print(s.c_str());
+ print(s);
}
// Make sure we have enough input files.
@@ -109,13 +116,13 @@
_arguments.pop_front();
}
os << ")\n";
- print(os.str().c_str());
+ print(os.str());
return -2;
}
if (_inputPaths.empty()) {
// Display help text if we got no input
- print(_helptext.c_str());
+ print(_helptext);
return 2;
}
@@ -245,6 +252,14 @@
notifyProgress(false);
}
+void Tool::print(const std::string &msg) {
+ _internalPrint(_print_udata, msg.c_str());
+
+ // We notify of progress here
+ // This way, almost all tools will be able to exit gracefully (as they print stuff)
+ notifyProgress(false);
+}
+
void Tool::notifyProgress(bool print_dot) {
if (_abort)
throw AbortException();
@@ -299,6 +314,10 @@
return _shorthelp;
}
+std::string Tool::getVersion() const {
+ return gScummVMToolsFullVersion;
+}
+
ToolType Tool::getType() const {
return _type;
}
Modified: tools/trunk/tool.h
===================================================================
--- tools/trunk/tool.h 2010-04-06 19:20:43 UTC (rev 48575)
+++ tools/trunk/tool.h 2010-04-06 22:01:25 UTC (rev 48576)
@@ -114,20 +114,28 @@
void warning(const char *format, ...);
/**
- * Prints a message, to either stdout or the GUI, always use this
+ * Prints a formatted message, to either stdout or the GUI. Always use this
* instead of printf.
*/
void print(const char *format, ...);
+ /**
+ * Prints a message, to either stdout or the GUI.
+ */
+ void print(const std::string &msg);
+
/** Returns name of the tool. */
std::string getName() const;
- /** Returns the helpstring of the tool. */
+ /** Returns the help string of the tool. */
virtual std::string getHelp() const;
- /** Returns the short helpstring of the tool. */
+ /** Returns the short help string of the tool. */
virtual std::string getShortHelp() const;
+ /** Returns the version string of the tool. */
+ virtual std::string getVersion() const;
+
/** Returns the type of the tool. */
ToolType getType() const;
Added: tools/trunk/update-version.pl
===================================================================
--- tools/trunk/update-version.pl (rev 0)
+++ tools/trunk/update-version.pl 2010-04-06 22:01:25 UTC (rev 48576)
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+#
+# This script is a hack to update the ScummVM tools version in all (?) files that
+# contain it. Obviously, it should be used before a release.
+
+use strict;
+
+if ($#ARGV+1 < 3 or $#ARGV+1 > 4) {
+ # TODO: Allow the user to specify the version as "1.2.3svn"
+ # and automatically split that into 1, 2, 3, svn
+ print STDERR "Usage: $0 MAJOR MINOR PATCH [EXTRA]\n";
+ print STDERR " TODO\n";
+ exit 1;
+}
+
+# TODO: Verify that major/minor/patch are actually numbers
+my $VER_MAJOR = $ARGV[0];
+my $VER_MINOR = $ARGV[1];
+my $VER_PATCH = $ARGV[2];
+my $VER_EXTRA = $ARGV[3];
+my $VERSION = "$VER_MAJOR.$VER_MINOR.$VER_PATCH$VER_EXTRA";
+
+die "MAJOR must be a natural number\n" unless ($VER_MAJOR =~ /^\d+$/);
+die "MINOR must be a natural number\n" unless ($VER_MINOR =~ /^\d+$/);
+die "PATCH must be a natural number\n" unless ($VER_PATCH =~ /^\d+$/);
+
+
+print "Setting version to '$VERSION'\n";
+
+
+# List of the files in which we need to perform substitution.
+my @subs_files = qw(
+ internal_version.h
+ );
+
+my %subs = (
+ VER_MAJOR => $VER_MAJOR,
+ VER_MINOR => $VER_MINOR,
+ VER_PATCH => $VER_PATCH,
+ VER_EXTRA => $VER_EXTRA,
+ VERSION => $VERSION
+ );
+
+foreach my $file (@subs_files) {
+ print "Processing $file...\n";
+ open(INPUT, "< $file.in") or die "Can't open '$file.in' for reading: $!\n";
+ open(OUTPUT, "> $file") or die "Can't open '$file' for writing: $!\n";
+
+ while (<INPUT>) {
+ while (my ($key, $value) = each(%subs)) {
+ s/\@$key\@/$value/;
+ }
+ print OUTPUT;
+ }
+
+ close(INPUT);
+ close(OUTPUT);
+}
Property changes on: tools/trunk/update-version.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: tools/trunk/version.cpp
===================================================================
--- tools/trunk/version.cpp (rev 0)
+++ tools/trunk/version.cpp 2010-04-06 22:01:25 UTC (rev 48576)
@@ -0,0 +1,59 @@
+/* ScummVM Tools
+ * Copyright (C) 2002-2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/scummsys.h"
+#include "internal_version.h"
+#include "version.h"
+
+/*
+ * Version string and build date string. These can be used by anything that
+ * wants to display this information to the user (e.g. about dialog).
+ *
+ * Note: it would be very nice if we could instead of (or in addition to) the
+ * build date present a date which corresponds to the date our source files
+ * were last changed. To understand the difference, imagine that a user
+ * makes a checkout on January 1, then after a week compiles it
+ * (e.g. after doing a 'make clean'). The build date then will say January 8
+ * even though the files were last changed on January 1.
+ *
+ * Another problem is that __DATE__/__TIME__ depend on the local time zone.
+ *
+ * It's clear that such a "last changed" date would be much more useful to us
+ * for feedback purposes. After all, when somebody files a bug report, we
+ * don't care about the build date, we want to know which date their checkout
+ * was made.
+ *
+ * So, how could we implement this? At least on unix systems, a special script
+ * could do it. Basically, that script could parse the output of "svn info" or
+ * "svnversion" to determine the revision of the checkout, and insert that
+ * information somehow into the build process (e.g. by generating a tiny
+ * header file, analog to internal_version.h, maybe called svn_rev.h or so.)
+ *
+ * Drawback: This only works on systems which can run suitable scripts as part
+ * of the build proces (so I guess Visual C++ would be out of the game here?
+ * I don't know VC enough to be sure). And of course it must be robust enough
+ * to properly work in exports (i.e. release tar balls etc.).
+ */
+const char *gScummVMToolsVersion = SCUMMVM_TOOLS_VERSION;
+const char *gScummVMToolsBuildDate = __DATE__ " " __TIME__;
+const char *gScummVMToolsVersionDate = SCUMMVM_TOOLS_VERSION " (" __DATE__ " " __TIME__ ")";
+const char *gScummVMToolsFullVersion = "ScummVM Tools " SCUMMVM_TOOLS_VERSION " (" __DATE__ " " __TIME__ ")";
Property changes on: tools/trunk/version.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/trunk/version.h
===================================================================
--- tools/trunk/version.h (rev 0)
+++ tools/trunk/version.h 2010-04-06 22:01:25 UTC (rev 48576)
@@ -0,0 +1,31 @@
+/* ScummVM Tools
+ * Copyright (C) 2002-2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef BASE_VERSION_H
+#define BASE_VERSION_H
+
+extern const char *gScummVMToolsVersion; // e.g. "0.4.1"
+extern const char *gScummVMToolsBuildDate; // e.g. "2003-06-24"
+extern const char *gScummVMToolsVersionDate; // e.g. "0.4.1 (2003-06-24)"
+extern const char *gScummVMToolsFullVersion; // e.g. "ScummVM Tools 0.4.1 (2003-06-24)"
+
+#endif
Property changes on: tools/trunk/version.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list