1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00

Move the version numbers from the interface of the version module into a new

implementation. Allow for release candidates to be specified and disinguished.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4260 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-09-28 20:10:01 +00:00
parent 3c6e8087f1
commit 7b847321a8
20 changed files with 165 additions and 89 deletions

View File

@ -6,8 +6,8 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2009, Ullrich von Bassewitz */
/* Römerstraße 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@ -121,8 +121,8 @@ int main (int argc, char* argv [])
case 'V': case 'V':
fprintf (stderr, fprintf (stderr,
"ar65 V%u.%u.%u - (C) Copyright 1998-2003 Ullrich von Bassewitz\n", "ar65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH); GetVersionAsString ());
break; break;
default: default:

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2008 Ullrich von Bassewitz */ /* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -945,7 +945,7 @@ static ExprNode* Factor (void)
break; break;
case TOK_VERSION: case TOK_VERSION:
N = GenLiteralExpr (VERSION); N = GenLiteralExpr (GetVersionAsNumber ());
NextTok (); NextTok ();
break; break;

View File

@ -224,12 +224,11 @@ static void PrintPageHeader (FILE* F, const ListLine* L)
/* Print the header on the new page */ /* Print the header on the new page */
fprintf (F, fprintf (F,
"ca65 V%u.%u.%u - %s\n" "ca65 V%s - %s\n"
"Main file : %s\n" "Main file : %s\n"
"Current file: %.*s\n" "Current file: %.*s\n"
"\n", "\n",
VER_MAJOR, VER_MINOR, VER_PATCH, GetVersionAsString (), Copyright,
Copyright,
InFile, InFile,
(int) SB_GetLen (CurFile), SB_GetConstBuf (CurFile)); (int) SB_GetLen (CurFile), SB_GetConstBuf (CurFile));

View File

@ -132,7 +132,7 @@ static void SetOptions (void)
StrBuf Buf = STATIC_STRBUF_INITIALIZER; StrBuf Buf = STATIC_STRBUF_INITIALIZER;
/* Set the translator */ /* Set the translator */
SB_Printf (&Buf, "ca65 V%u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH); SB_Printf (&Buf, "ca65 V%s", GetVersionAsString ());
OptTranslator (&Buf); OptTranslator (&Buf);
/* Set date and time */ /* Set date and time */
@ -521,9 +521,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused))) const char* Arg attribute ((unused)))
/* Print the assembler version */ /* Print the assembler version */
{ {
fprintf (stderr, fprintf (stderr, "ca65 V%s - %s\n", GetVersionAsString (), Copyright);
"ca65 V%u.%u.%u - %s\n",
VER_MAJOR, VER_MINOR, VER_PATCH, Copyright);
} }

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2009 Ullrich von Bassewitz */ /* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -151,13 +151,12 @@ void g_preamble (void)
/* Identify the compiler version */ /* Identify the compiler version */
AddTextLine (";"); AddTextLine (";");
AddTextLine ("; File generated by cc65 v %u.%u.%u", AddTextLine ("; File generated by cc65 v %s", GetVersionAsString ());
VER_MAJOR, VER_MINOR, VER_PATCH);
AddTextLine (";"); AddTextLine (";");
/* Insert some object file options */ /* Insert some object file options */
AddTextLine ("\t.fopt\t\tcompiler,\"cc65 v %u.%u.%u\"", AddTextLine ("\t.fopt\t\tcompiler,\"cc65 v %s\"",
VER_MAJOR, VER_MINOR, VER_PATCH); GetVersionAsString ());
/* If we're producing code for some other CPU, switch the command set */ /* If we're producing code for some other CPU, switch the command set */
switch (CPU) { switch (CPU) {

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000-2009 Ullrich von Bassewitz */ /* (C) 2000-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -300,7 +300,7 @@ void Compile (const char* FileName)
}; };
/* Add macros that are always defined */ /* Add macros that are always defined */
DefineNumericMacro ("__CC65__", VERSION); DefineNumericMacro ("__CC65__", GetVersionAsNumber ());
/* Language standard that is supported */ /* Language standard that is supported */
DefineNumericMacro ("__CC65_STD_C89__", STD_C89); DefineNumericMacro ("__CC65_STD_C89__", STD_C89);

View File

@ -667,9 +667,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the compiler version */ /* Print the compiler version */
{ {
fprintf (stderr, fprintf (stderr,
"cc65 V%u.%u.%u\n" "cc65 V%s\nSVN version: %s\n",
"SVN version: %s\n", GetVersionAsString (), SVNVersion);
VER_MAJOR, VER_MINOR, VER_PATCH, SVNVersion);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }

View File

@ -1128,8 +1128,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print version number */ /* Print version number */
{ {
fprintf (stderr, fprintf (stderr,
"cl65 V%u.%u.%u - (C) Copyright 1998-2005 Ullrich von Bassewitz\n", "cl65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH); GetVersionAsString ());
} }

View File

@ -6,8 +6,8 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2003 Ullrich von Bassewitz */ /* (C) 2003-2009, Ullrich von Bassewitz */
/* Römerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@ -454,8 +454,8 @@ void Convert (const O65Data* D)
} }
/* Create a header */ /* Create a header */
fprintf (F, ";\n; File generated by co65 v %u.%u.%u using model `%s'\n;\n", fprintf (F, ";\n; File generated by co65 v %s using model `%s'\n;\n",
VER_MAJOR, VER_MINOR, VER_PATCH, GetModelName (Model)); GetVersionAsString (), GetModelName (Model));
/* Select the CPU */ /* Select the CPU */
if ((D->Header.mode & O65_CPU_MASK) == O65_CPU_65816) { if ((D->Header.mode & O65_CPU_MASK) == O65_CPU_65816) {
@ -463,8 +463,7 @@ void Convert (const O65Data* D)
} }
/* Object file options */ /* Object file options */
fprintf (F, ".fopt\t\tcompiler,\"co65 v %u.%u.%u\"\n", fprintf (F, ".fopt\t\tcompiler,\"co65 v %s\"\n", GetVersionAsString ());
VER_MAJOR, VER_MINOR, VER_PATCH);
if (Author) { if (Author) {
fprintf (F, ".fopt\t\tauthor, \"%s\"\n", Author); fprintf (F, ".fopt\t\tauthor, \"%s\"\n", Author);
xfree (Author); xfree (Author);

View File

@ -6,8 +6,8 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2003 Ullrich von Bassewitz */ /* (C) 2003-2009, Ullrich von Bassewitz */
/* Römerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@ -264,8 +264,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the assembler version */ /* Print the assembler version */
{ {
fprintf (stderr, fprintf (stderr,
"co65 V%u.%u.%u - (C) Copyright 1998-2003 Ullrich von Bassewitz\n", "co65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH); GetVersionAsString ());
} }

View File

@ -39,6 +39,7 @@ OBJS = abend.o \
strutil.o \ strutil.o \
target.o \ target.o \
tgttrans.o \ tgttrans.o \
version.o \
xmalloc.o \ xmalloc.o \
xsprintf.o xsprintf.o

View File

@ -85,6 +85,7 @@ OBJS = abend.obj \
strutil.obj \ strutil.obj \
target.obj \ target.obj \
tgttrans.obj \ tgttrans.obj \
version.obj \
wildargv.obj \ wildargv.obj \
xmalloc.obj \ xmalloc.obj \
xsprintf.obj xsprintf.obj

82
src/common/version.c Normal file
View File

@ -0,0 +1,82 @@
/*****************************************************************************/
/* */
/* version.c */
/* */
/* Version information for the cc65 compiler package */
/* */
/* */
/* */
/* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#include "version.h"
#include "xsprintf.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
#define VER_MAJOR 2U
#define VER_MINOR 13U
#define VER_PATCH 0U
#define VER_RC 0U
/*****************************************************************************/
/* Code */
/*****************************************************************************/
const char* GetVersionAsString (void)
/* Returns the version number as a string in a static buffer */
{
static char Buf[20];
#if defined(VER_RC) && (VER_RC > 0U)
xsnprintf (Buf, sizeof (Buf), "%u.%u.%u-rc%u", VER_MAJOR, VER_MINOR, VER_PATCH, VER_RC);
#else
xsnprintf (Buf, sizeof (Buf), "%u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH);
#endif
return Buf;
}
unsigned GetVersionAsNumber (void)
/* Returns the version number as a combined unsigned for use in a #define */
{
return ((VER_MAJOR * 0x100) + (VER_MINOR * 0x10) + VER_PATCH);
}

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2008, Ullrich von Bassewitz */ /* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -39,16 +39,16 @@
/*****************************************************************************/ /*****************************************************************************/
/* Data */ /* Code */
/*****************************************************************************/ /*****************************************************************************/
#define VER_MAJOR 2U const char* GetVersionAsString (void);
#define VER_MINOR 12U /* Returns the version number as a string in a static buffer */
#define VER_PATCH 9U
#define VERSION ((VER_MAJOR * 0x100) + (VER_MINOR * 0x10) + VER_PATCH) unsigned GetVersionAsNumber (void);
/* Returns the version number as a combined unsigned for use in a #define */

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2007 Ullrich von Bassewitz */ /* (C) 1998-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -340,8 +340,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the disassembler version */ /* Print the disassembler version */
{ {
fprintf (stderr, fprintf (stderr,
"da65 V%u.%u.%u - (C) Copyright 2000-2006, Ullrich von Bassewitz\n", "da65 V%s - (C) Copyright 2000-2009, Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH); GetVersionAsString ());
} }

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000-2007 Ullrich von Bassewitz */ /* (C) 2000-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -75,11 +75,11 @@ static void PageHeader (void)
/* Print a page header */ /* Print a page header */
{ {
fprintf (F, fprintf (F,
"; da65 V%u.%u.%u - (C) Copyright 2000-2005, Ullrich von Bassewitz\n" "; da65 V%s - (C) Copyright 2000-2009, Ullrich von Bassewitz\n"
"; Created: %s\n" "; Created: %s\n"
"; Input file: %s\n" "; Input file: %s\n"
"; Page: %u\n\n", "; Page: %u\n\n",
VER_MAJOR, VER_MINOR, VER_PATCH, GetVersionAsString (),
Now, Now,
InFile, InFile,
Page); Page);

View File

@ -490,8 +490,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the assembler version */ /* Print the assembler version */
{ {
fprintf (stderr, fprintf (stderr,
"ld65 V%u.%u.%u - (C) Copyright 1998-2005 Ullrich von Bassewitz\n", "ld65 V%s - (C) Copyright 1998-2009, Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH); GetVersionAsString ());
} }

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1999-2007 Ullrich von Bassewitz */ /* (C) 1999-2009, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -1385,7 +1385,7 @@ void O65WriteTarget (O65Desc* D, File* F)
} }
OptBuf[OptLen] = '\0'; OptBuf[OptLen] = '\0';
O65SetOption (D, O65OPT_TIMESTAMP, OptBuf, OptLen + 1); O65SetOption (D, O65OPT_TIMESTAMP, OptBuf, OptLen + 1);
sprintf (OptBuf, "ld65 V%u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH); sprintf (OptBuf, "ld65 V%s", GetVersionAsString ());
O65SetOption (D, O65OPT_ASM, OptBuf, strlen (OptBuf) + 1); O65SetOption (D, O65OPT_ASM, OptBuf, strlen (OptBuf) + 1);
/* Write the header */ /* Write the header */

View File

@ -6,9 +6,9 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000-2002 Ullrich von Bassewitz */ /* (C) 2000-2009, Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Roemerstrasse 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
@ -201,8 +201,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the assembler version */ /* Print the assembler version */
{ {
fprintf (stderr, fprintf (stderr,
"%s V%u.%u.%u - (C) Copyright 2000-2002 Ullrich von Bassewitz\n", "%s V%s - (C) Copyright 2000-2009, Ullrich von Bassewitz\n",
ProgName, VER_MAJOR, VER_MINOR, VER_PATCH); ProgName, GetVersionAsString ());
} }

View File

@ -6,8 +6,8 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2002-2005 Ullrich von Bassewitz */ /* (C) 2002-2009, Ullrich von Bassewitz */
/* Römerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@ -207,9 +207,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused))) const char* Arg attribute ((unused)))
/* Print the assembler version */ /* Print the assembler version */
{ {
fprintf (stderr, fprintf (stderr, "sim65 V%s\n", GetVersionAsString ());
"sim65 V%u.%u.%u\n",
VER_MAJOR, VER_MINOR, VER_PATCH);
} }