[ros-diffs] [gvg] 57: Add "buildno" tool

gvg at svn.reactos.org gvg at svn.reactos.org
Mon Jan 30 22:46:20 CET 2006


Add "buildno" tool
Modified: trunk/reactos/Makefile
Added: trunk/reactos/include/reactos/version.h
Added: trunk/reactos/tools/buildno/
Added: trunk/reactos/tools/buildno/buildno.cpp
Added: trunk/reactos/tools/buildno/buildno.mak
Added: trunk/reactos/tools/buildno/pch.h
Modified: trunk/reactos/tools/tools.mak
  _____  

Modified: trunk/reactos/Makefile
--- trunk/reactos/Makefile	2006-01-30 21:37:09 UTC (rev 56)
+++ trunk/reactos/Makefile	2006-01-30 21:46:14 UTC (rev 57)
@@ -348,19 +348,20 @@

 #include boot/freeldr/bootsect/bootsect.mak
 -include $(ROS_AUTOMAKE)
 
+#PREAUTO := \
+#	$(BIN2C_TARGET) \
+#	$(BIN2RES_TARGET) \
+#	$(BUILDNO_H) \
+#	$(BUGCODES_H) \
+#	$(BUGCODES_RC) \
+#	$(ERRCODES_H) \
+#	$(ERRCODES_RC) \
+#	$(NCI_SERVICE_FILES) \
+#	$(GENDIB_DIB_FILES)
 PREAUTO := \
-	$(BIN2C_TARGET) \
-	$(BIN2RES_TARGET) \
-	$(BUILDNO_H) \
-	$(BUGCODES_H) \
-	$(BUGCODES_RC) \
-	$(ERRCODES_H) \
-	$(ERRCODES_RC) \
-	$(NCI_SERVICE_FILES) \
-	$(GENDIB_DIB_FILES)
+	$(BUILDNO_H)
 
-#$(ROS_AUTOMAKE): $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
-$(ROS_AUTOMAKE): $(RBUILD_TARGET) $(XMLBUILDFILES)
+$(ROS_AUTOMAKE): $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
 	$(ECHO_RBUILD)
 	$(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) mingw
 
  _____  

Added: trunk/reactos/include/reactos/version.h
--- trunk/reactos/include/reactos/version.h	2006-01-30 21:37:09 UTC
(rev 56)
+++ trunk/reactos/include/reactos/version.h	2006-01-30 21:46:14 UTC
(rev 57)
@@ -0,0 +1,23 @@

+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        include/reactos/version.h
+ * PURPOSE:     Defines the current version
+ * COPYRIGHT:   Copyright 1999 David Welch (welch at mcmail.com)
+ *              Copyright 1999-2002 Emanuelle Aliberti
+ */
+
+#ifndef __VERSION_H
+#define __VERSION_H
+
+#define KERNEL_VERSION_MAJOR		0
+#define KERNEL_VERSION_MINOR		3
+#define KERNEL_VERSION_PATCH_LEVEL	0
+
+/* KERNEL_VERSION_BUILD_TYPE is L"SVN", L"PR", L"RC" or L"RELEASE" */
+#define KERNEL_VERSION_BUILD_TYPE	L"SVN"
+
+
+#endif
+
+/* EOF */
Property changes on: trunk/reactos/include/reactos/version.h
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native
Property changes on: trunk/reactos/tools/buildno
___________________________________________________________________
Name: ros:history
   +
------------------------------------------------------------------------
r19708 | royce | 2005-11-28 00:04:51 +0100 (Mon, 28 Nov 2005) | 1 line
move xml.h/cpp and ssprintf.h/cpp up a directory, make both rbuild and
buildno use these same files
------------------------------------------------------------------------
r19675 | sedwards | 2005-11-27 07:48:34 +0100 (Sun, 27 Nov 2005) | 1
line
XML.cpp -> xml.cpp, XML.h -> xml.h. Sorry Windows users, if you make
sure your stuff is in the correct case the first time then you wont have
problems when doing a svn update.
------------------------------------------------------------------------
r18952 | gvg | 2005-11-02 17:13:00 +0100 (Wed, 02 Nov 2005) | 3 lines
ScoTTie <scott at wizzer-it.com>/erie-- <seditaniedi at gmail.com>
Build fixes for FreeBSD
------------------------------------------------------------------------
r16941 | weiden | 2005-08-01 12:58:28 +0200 (Mon, 01 Aug 2005) | 1 line
define common build flags so they can easily be changed for all tools
------------------------------------------------------------------------
r16689 | sedwards | 2005-07-22 21:45:32 +0200 (Fri, 22 Jul 2005) | 1
line
some fixes for the host gcc4 on FC4
------------------------------------------------------------------------
r15809 | chorns | 2005-06-05 18:32:33 +0200 (Sun, 05 Jun 2005) | 1 line
Remove old makefiles
------------------------------------------------------------------------
r15583 | chorns | 2005-05-28 17:18:30 +0200 (Sat, 28 May 2005) | 1 line
Merge 12735:15568 from xmlbuildsystem branch
------------------------------------------------------------------------
r14910 | arty | 2005-05-01 13:24:07 +0200 (Sun, 01 May 2005) | 3 lines
Added HOST=mingw32-linux64 setting.
Fixed various small breakage for linux64 host.
------------------------------------------------------------------------
r13656 | gvg | 2005-02-20 00:05:09 +0100 (Sun, 20 Feb 2005) | 4 lines
Don't use svn command line tool to get revision number
XML code stolen from the xmlbuildsystem branch, we need
to merge this when merging the xmlbuildsystem back into trunk
------------------------------------------------------------------------
Name: ros:doc
   + ReactOS-specific build utility
  _____  

Added: trunk/reactos/tools/buildno/buildno.cpp
--- trunk/reactos/tools/buildno/buildno.cpp	2006-01-30 21:37:09 UTC
(rev 56)
+++ trunk/reactos/tools/buildno/buildno.cpp	2006-01-30 21:46:14 UTC
(rev 57)
@@ -0,0 +1,371 @@

+/* $Id$
+ *
+ * buildno - Generate the build number for ReactOS
+ *
+ * Copyright (c) 1999,2000 Emanuele Aliberti
+ *
+ * The build number is the day on which the build took
+ * place, as YYYYMMDD
+ *
+ * The build number is stored in the file
+ * <reactos/buildno.h> as a set of macros:
+ *
+ * KERNEL_VERSION_BUILD		base 10 number
+ * KERNEL_VERSION_BUILD_STR	C string
+ * KERNEL_VERSION_BUILD_RC	RC string
+ *
+ * REVISIONS
+ * ---------
+ * 2000-01-22 (ea)
+ * 	Fixed bugs: tm_year is (current_year - 1900),
+ * 	tm_month is 0-11 not 1-12 and code ignored TZ.
+ * 2000-12-10 (ea)
+ * 	Added -p option to make it simply print the
+ * 	version number, but skip buildno.h generation.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include "version.h"
+#include "xml.h"
+
+#define FALSE 0
+#define TRUE  1
+
+static char * argv0 = "";
+static char * filename = "";
+
+#ifdef DBG
+void
+tm_dump (const char *tag, struct tm * t)
+{
+	printf ("%s->tm_sec   = %d\n", tag, t->tm_sec);
+	printf ("%s->tm_min   = %d\n", tag, t->tm_min);
+	printf ("%s->tm_hour  = %d\n", tag, t->tm_hour);
+	printf ("%s->tm_mday  = %d\n", tag, t->tm_mday);
+	printf ("%s->tm_mon   = %d\n", tag, t->tm_mon);
+	printf ("%s->tm_year  = %d\n", tag, t->tm_year);
+	printf ("%s->tm_wday  = %d\n", tag, t->tm_wday);
+	printf ("%s->tm_yday  = %d\n", tag, t->tm_yday);
+	printf ("%s->tm_isdst = %d\n\n", tag, t->tm_isdst);
+}
+#endif
+
+void
+write_h (int build, char *buildstr)
+{
+  FILE	*h = NULL;
+  char* s;
+  char* s1;
+  unsigned int length;
+  int dllversion = KERNEL_VERSION_MAJOR + 42;
+
+  s1 = s = (char *) malloc(256 * 1024);
+  
+  s = s + sprintf (s, "/* Do not edit - Machine generated */\n");
+	
+  s = s + sprintf (s, "#ifndef _INC_REACTOS_BUILDNO\n" );
+  s = s + sprintf (s, "#define _INC_REACTOS_BUILDNO\n" );
+  
+  s = s + sprintf (s, "#define KERNEL_VERSION_BUILD\t%d\n", build);
+  s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_STR\t\"%s\"\n",
buildstr);
+  s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_RC\t\"%s\\0\"\n",
buildstr);
+  s = s + sprintf (s, "#define KERNEL_RELEASE_RC\t\"%d.%d",
+		   KERNEL_VERSION_MAJOR, KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\\0\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define KERNEL_RELEASE_STR\t\"%d.%d",
+		   KERNEL_VERSION_MAJOR,
+		   KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define KERNEL_VERSION_RC\t\"%d.%d",
+		   KERNEL_VERSION_MAJOR,
+		   KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\\0\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define KERNEL_VERSION_STR\t\"%d.%d", 
+		   KERNEL_VERSION_MAJOR,
+		   KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define REACTOS_DLL_VERSION_MAJOR\t%d\n",
dllversion);
+  s = s + sprintf (s, "#define REACTOS_DLL_RELEASE_RC\t\"%d.%d",
+		   dllversion, KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\\0\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define REACTOS_DLL_RELEASE_STR\t\"%d.%d",
+		   dllversion,
+		   KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define REACTOS_DLL_VERSION_RC\t\"%d.%d",
+		   dllversion,
+		   KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\\0\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#define REACTOS_DLL_VERSION_STR\t\"%d.%d", 
+		   dllversion,
+		   KERNEL_VERSION_MINOR);
+  if (0 != KERNEL_VERSION_PATCH_LEVEL)
+    {
+      s = s + sprintf (s, ".%d", KERNEL_VERSION_PATCH_LEVEL);
+    }
+  s = s + sprintf (s, "-%S\"\n", KERNEL_VERSION_BUILD_TYPE);
+  s = s + sprintf (s, "#endif\n/* EOF */\n");
+
+  h = fopen (filename, "wb");
+  if (h != NULL)
+    {
+      fseek(h, 0, SEEK_END);
+      length = ftell(h);
+      if (length == strlen(s1))
+	{
+	  char* orig;
+	  
+	  orig = (char *) malloc(length);
+	  fseek(h, 0, SEEK_SET);
+	  fread(orig, 1, length, h);
+	  if (memcmp(s1, orig, length) == 0)
+	    {
+	      fclose(h);
+	      return;
+	    }
+	}
+      fclose(h);
+    }
+
+  h = fopen (filename, "wb");
+  if (!h) 
+    {
+      fprintf (stderr,
+	       "%s: can not create file \"%s\"!\n",
+	       argv0,
+	       filename);
+      return;
+    }
+  fwrite(s1, 1, strlen(s1), h);
+  fclose (h);
+}
+
+char *
+GetRev(void)
+{
+  static char Unknown[] = "UNKNOWN";
+  static char Revision[10]; /* 999999999 revisions should be enough for
everyone... */
+
+  try
+    {
+      XMLElement *head;
+
+      try
+        {
+          head = XMLLoadFile(".svn/entries");
+        }
+      catch(XMLFileNotFoundException)
+        {
+          head = XMLLoadFile("_svn/entries");
+        }
+      XMLElement *entries = head->subElements[0];
+      for (size_t i = 0; i < entries->subElements.size(); i++)
+      {
+          XMLElement *entry = entries->subElements[i];
+          if ("entry" == entry->name)
+            {
+              bool GotName = false;
+              bool GotKind = false;
+              bool GotRevision = false;
+              for (size_t j = 0; j < entry->attributes.size(); j++)
+                {
+                  XMLAttribute *Attribute = entry->attributes[j];
+                  if ("name" == Attribute->name && "" ==
Attribute->value)
+                    {
+                      GotName = true;
+                    }
+                  if ("kind" == Attribute->name && "dir" ==
Attribute->value)
+                    {
+                      GotKind = true;
+                    }
+                  if ("revision" == Attribute->name)
+                    {
+                      if (sizeof(Revision) <= Attribute->value.length()
+ 1)
+                        {
+                          strcpy(Revision, "revtoobig");
+                        }
+                      else
+                        {
+                          strcpy(Revision, Attribute->value.c_str());
+                        }
+                      GotRevision = true;
+                    }
+                  if (GotName && GotKind && GotRevision)
+                    {
+                      delete head;
+                      return Revision;
+                    }
+                }
+            }
+        }
+
+      delete head;
+    }
+  catch(...)
+    {
+      ;
+    }
+
+  return Unknown;
+}
+
+
+void
+usage (void)
+{
+	fprintf (
+		stderr,
+		"Usage: %s [-{p|q}] path-to-header\n\n  -p  print
version number and exit\n  -q  run in quiet mode\n",
+		argv0
+		);
+	exit (EXIT_SUCCESS);
+}
+
+
+int
+main (int argc, char * argv [])
+{
+	int		print_only = FALSE;
+	int		quiet = FALSE;
+
+	int		build = 0;
+	char		buildstr[64];
+
+	time_t		t1 = 0;
+	struct tm	* t1_tm = NULL;
+
+	argv0 = argv[0];
+		
+	switch (argc)
+	{
+		case 1:
+			break;
+		case 2:
+		case 3:
+			if (argv[1][0] == '-')
+			{
+				if (argv[1][1] == 'q')
+				{
+					quiet = TRUE;
+				}
+				else  if (argv[1][1] == 'p')
+				{
+					print_only = TRUE;
+				}
+				else
+				{
+					usage ();
+				}
+				filename = argv[2];
+			}
+			else if (argc == 2)
+			{
+				filename = argv[1];
+			}
+			else
+			{
+				usage ();
+			}
+			break;
+		default:
+			usage ();
+	}
+	/*
+	 * Set TZ information.
+	 */
+	tzset ();
+	/*
+	 * We are building TODAY!
+	 */
+	if (! quiet)
+	{
+		printf ( "\nReactOS Build Number Generator\n\n");
+	}
+
+	time (& t1); /* current build time */
+	t1_tm = gmtime (& t1);
+
+#ifdef DBG
+	tm_dump ("t1", t1_tm);
+#endif
+	t1_tm->tm_year += 1900;
+#ifdef DBG
+	tm_dump ("t1", t1_tm);
+#endif
+	if (! quiet)
+	{
+		printf ( 
+			"Current date: %4d-%02d-%02d\n\n",
+			t1_tm->tm_year,
+			(t1_tm->tm_mon + 1),
+			t1_tm->tm_mday
+			);
+	}
+	/*
+	 * Compute build number.
+	 */
+	build =	t1_tm->tm_year * 10000 + (t1_tm->tm_mon + 1) * 100 +
t1_tm->tm_mday;
+
+	sprintf(buildstr, "%d-r%s", build, GetRev());
+
+	if (! quiet)
+	{
+		printf (
+			"ROS Version : %d.%d",
+			KERNEL_VERSION_MAJOR,
+			KERNEL_VERSION_MINOR
+			);
+		if (0 != KERNEL_VERSION_PATCH_LEVEL)
+		{
+			printf(".%d", KERNEL_VERSION_PATCH_LEVEL);
+		}
+		printf("-%S (Build %s)\n\n", KERNEL_VERSION_BUILD_TYPE,
buildstr);
+	}
+	/*
+	 * (Over)write the include file, unless
+	 * the user switched on -p.
+	 */
+	if (! print_only)
+	{
+		write_h (build, buildstr);
+	}
+	else
+	{
+		printf ("%s: no code generated", argv [0]);
+	}
+
+	return EXIT_SUCCESS;
+}
+
+
+/* EOF */
Property changes on: trunk/reactos/tools/buildno/buildno.cpp
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native
  _____  

Added: trunk/reactos/tools/buildno/buildno.mak
--- trunk/reactos/tools/buildno/buildno.mak	2006-01-30 21:37:09 UTC
(rev 56)
+++ trunk/reactos/tools/buildno/buildno.mak	2006-01-30 21:46:14 UTC
(rev 57)
@@ -0,0 +1,50 @@

+BUILDNO_BASE = $(TOOLS_BASE_)buildno
+BUILDNO_BASE_ = $(BUILDNO_BASE)$(SEP)
+BUILDNO_INT = $(INTERMEDIATE_)$(BUILDNO_BASE)
+BUILDNO_INT_ = $(BUILDNO_INT)$(SEP)
+BUILDNO_OUT = $(OUTPUT_)$(BUILDNO_BASE)
+BUILDNO_OUT_ = $(BUILDNO_OUT)$(SEP)
+
+$(BUILDNO_INT): | $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(BUILDNO_OUT): | $(TOOLS_OUT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+endif
+
+BUILDNO_TARGET = \
+	$(EXEPREFIX)$(BUILDNO_OUT_)buildno$(EXEPOSTFIX)
+
+BUILDNO_SOURCES = $(addprefix $(BUILDNO_BASE_), \
+	buildno.cpp \
+	)
+
+BUILDNO_OBJECTS = \
+	$(addprefix $(INTERMEDIATE_), $(BUILDNO_SOURCES:.cpp=.o))
+
+BUILDNO_HOST_CXXFLAGS = -I$(TOOLS_BASE) -Iinclude/reactos
$(TOOLS_CPPFLAGS)
+
+BUILDNO_HOST_LFLAGS = $(TOOLS_LFLAGS)
+
+.PHONY: buildno
+buildno: $(BUILDNO_TARGET)
+
+$(BUILDNO_TARGET): $(BUILDNO_OBJECTS) $(XML_SSPRINTF_OBJECTS) |
$(BUILDNO_OUT)
+	$(ECHO_LD)
+	${host_gpp} $^ $(BUILDNO_HOST_LFLAGS) -o $@
+
+$(BUILDNO_INT_)buildno.o: $(BUILDNO_BASE_)buildno.cpp | $(BUILDNO_INT)
+	$(ECHO_CC)
+	${host_gpp} $(BUILDNO_HOST_CXXFLAGS) -c $< -o $@
+
+.PHONY: buildno_clean
+buildno_clean:
+	-@$(rm) $(BUILDNO_TARGET) $(BUILDNO_OBJECTS) 2>$(NUL)
+clean: buildno_clean
+
+$(BUILDNO_H): $(BUILDNO_TARGET)
+	$(ECHO_BUILDNO)
+	$(Q)$(BUILDNO_TARGET) $(BUILDNO_QUIET) $(BUILDNO_H)
Property changes on: trunk/reactos/tools/buildno/buildno.mak
___________________________________________________________________
Name: svn:eol-style
   + native
  _____  

Added: trunk/reactos/tools/buildno/pch.h
--- trunk/reactos/tools/buildno/pch.h	2006-01-30 21:37:09 UTC (rev 56)
+++ trunk/reactos/tools/buildno/pch.h	2006-01-30 21:46:14 UTC (rev 57)
@@ -0,0 +1,47 @@

+// pre-compiled header stuff
+
+#ifndef PCH_H
+#define PCH_H
+
+#ifdef _MSC_VER
+#pragma warning ( disable : 4786 ) // identifier was truncated to '255'
characters in the debug information
+#endif//_MSC_VER
+
+#include <string>
+#include <vector>
+#include <map>
+#include <set>
+
+#include <stdarg.h>
+#ifndef RBUILD
+#include <ctype.h>
+#include <unistd.h>
+#endif
+
+#ifdef _MSC_VER
+#define MAX_PATH _MAX_PATH
+#endif
+
+#ifndef WIN32
+#include <wctype.h>
+#include <math.h>
+
+inline char * strlwr(char *x)
+{
+        char  *y=x;
+
+        while (*y) {
+                *y=tolower(*y);
+                y++;
+        }
+        return x;
+}
+
+#define _finite __finite
+#define _isnan __isnan
+#define stricmp strcasecmp
+#define MAX_PATH PATH_MAX 
+#define _MAX_PATH PATH_MAX
+#endif
+
+#endif//PCH_H
Property changes on: trunk/reactos/tools/buildno/pch.h
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native
  _____  

Modified: trunk/reactos/tools/tools.mak
--- trunk/reactos/tools/tools.mak	2006-01-30 21:37:09 UTC (rev 56)
+++ trunk/reactos/tools/tools.mak	2006-01-30 21:46:14 UTC (rev 57)
@@ -46,7 +46,7 @@

 #include tools/raddr2line.mak
 #include tools/pefixup.mak
 #include tools/bin2res/bin2res.mak
-#include tools/buildno/buildno.mak
+include tools/buildno/buildno.mak
 #include tools/cabman/cabman.mak
 include tools/cdmake/cdmake.mak
 #include tools/gendib/gendib.mak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20060130/3784b256/attachment-0002.html


More information about the Ros-diffs mailing list