1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 22:46:37 +02:00

Changed the versioning system to use git

This commit is contained in:
Adam
2010-06-25 20:00:21 -04:00
parent cbcead4e89
commit 03fbc7d281
167 changed files with 2981 additions and 542 deletions
+14 -27
View File
@@ -1,30 +1,17 @@
# If we are building for Visual Studio OR if the system we are on doesn't have sh (which would be odd on a *nix system...), we'll build a C++ program to create version.h
if(MSVC OR NOT SH)
# Set version.sh.c to use C++ as well as set it's compile flags
set_source_files_properties(version.sh.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
# Generate version_sh executable to create version.h from the contents of version.sh, setting it's linker flags as well
add_executable(version_sh version.sh.c)
set_target_properties(version_sh PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
# Generate version.h from the above executable and the version.log file from the main source directory, with dependencies to the given headers and all source files in the main Anope build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
COMMAND version_sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS version_sh ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${SRC_SRCS}
)
# Add version_sh to list of files for CPack to ignore
get_target_property(version_sh_BINARY version_sh LOCATION)
get_filename_component(version_sh_BINARY ${version_sh_BINARY} NAME)
add_to_cpack_ignored_files("${version_sh_BINARY}$" TRUE)
# For any non-Visual Studio platforms that do have sh, we will run version.h through the version.h shell script
else(MSVC OR NOT SH)
# Generate version.h from version.sh and the version.log file from the main source directory, with dependencies to the given headers and all source files in the main Anope build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
COMMAND ${SH} ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_BINARY_DIR}/version.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${SRC_SRCS}
)
endif(MSVC OR NOT SH)
# Add version.h to the list of files for CPack to ignore
add_to_cpack_ignored_files("version.h$" TRUE)
# Set version.cpp to use C++ as well as set its compile flags
set_source_files_properties(version.cpp PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
# Generate version executable to modify version.h, setting it's linker flags as well
add_executable(version version.cpp)
set_target_properties(version PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
# Modify version.h from the above executable, with dependencies to the given headers, version.cpp, and all source files in the main Anope build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
COMMAND version ${Anope_SOURCE_DIR}/src/version.sh ${CMAKE_CURRENT_SOURCE_DIR}/version.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp ${SRC_SRCS}
)
# Add version to list of files for CPack to ignore
get_target_property(version_BINARY version LOCATION)
get_filename_component(version_BINARY ${version_BINARY} NAME)
add_to_cpack_ignored_files("${version_BINARY}$" TRUE)
# Add a custom target to the above file
add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+4 -4
View File
@@ -1,8 +1,8 @@
all: services.h extern.h version.h
./version ../src/version.sh version.h
version.h: Makefile version.sh services.h $(SRCS)
sh version.sh ../version.log $@
version.h: Makefile services.h version.cpp $(SRCS)
$(CC) version.cpp -o version
services.h: sysconf.h config.h extern.h
touch $@
@@ -11,4 +11,4 @@ clean:
(rm -f language.h)
distclean: clean
(rm -f sysconf.h version.h)
(rm -f sysconf.h version.h version)
-3
View File
@@ -206,9 +206,6 @@ E void fatal_perror(const char *fmt, ...) FORMAT(printf,1,2);
/**** main.c ****/
E const char version_number[];
E const char version_number_dotted[];
E const char version_build[];
E char *version_protocol;
E std::string services_dir;
+27 -1
View File
@@ -16,6 +16,7 @@
/*************************************************************************/
#include "version.h"
#include "sysconf.h"
#define BUFSIZE 1024
@@ -202,6 +203,7 @@ extern "C" void __pfnBkCheck() {}
/* Pull in the various bits of STL */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <exception>
@@ -355,6 +357,19 @@ template<typename T> class Flags
/*************************************************************************/
template<typename T>
inline const std::string stringify(const T &x)
{
std::stringstream stream;
if (!(stream << x))
throw CoreException("Stringify fail");
return stream.str();
}
/*************************************************************************/
/* forward declarations, mostly used by older code */
class User;
class ChannelInfo;
@@ -1036,7 +1051,19 @@ struct Message; // XXX
class CoreExport Anope
{
private:
static const char * const compiled;
public:
static inline const std::string Version()
{
return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH) + VERSION_EXTRA " (" + stringify(VERSION_BUILD) + ")";
}
static inline const std::string Build()
{
return "build #" + stringify(BUILD) + ", compiled " + compiled;
}
/** Check whether two strings match.
* @param str The string to check against the pattern (e.g. foobar)
* @param mask The pattern to check (e.g. foo*bar)
@@ -1064,7 +1091,6 @@ class CoreExport Anope
* @return a vector with pointers to the messagehandlers (you can bind more than one handler to a message)
*/
static std::vector<Message *> FindMessage(const std::string &name);
};
/*************************************************************************/
+116
View File
@@ -0,0 +1,116 @@
/* Build bumper
*
* (C) 2003-2010 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for furhter details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
int main(int argc, char *argv[])
{
using namespace std;
if (argc < 3)
{
cout << "Syntax: " << argv[0] << " <src/version.sh> <version.h>" << endl;
return 1;
}
fstream fd;
fd.open(argv[1], ios::in);
if (!fd.is_open())
{
cout << "Error: Unable to open src/version.sh for reading: " << argv[1] << endl;
return 1;
}
string filebuf;
list<pair<string, string> > versions;
while (getline(fd, filebuf))
{
if (filebuf.find("VERSION_") == 0)
{
size_t eq = filebuf.find('=');
string type = filebuf.substr(8, 5);
string value = filebuf.substr(eq + 2, filebuf.length() - eq - 3);
versions.push_back(make_pair(type, value));
}
}
fd.close();
fd.open(argv[2], ios::in);
string version_build = "#define VERSION_BUILD 1";
string version_extra;
string build = "#define BUILD 1";
if (fd.is_open())
{
while (getline(fd, filebuf))
{
if (filebuf.find("#define VERSION_BUILD") == 0)
{
version_build = filebuf;
}
else if (filebuf.find("#define VERSION_EXTRA") == 0)
{
size_t q = filebuf.find('"');
version_extra = filebuf.substr(q + 1, filebuf.length() - q - 2);
}
else if (filebuf.find("#define BUILD") == 0)
{
size_t tab = filebuf.find(' ');
int ibuild = atoi(filebuf.substr(tab + 1).c_str());
++ibuild;
stringstream ss;
ss << "#define BUILD " << ibuild;
build = ss.str();
}
}
fd.close();
}
fd.open(argv[2], ios::out);
if (!fd.is_open())
{
cout << "Error: Unable to include/version.h for writing: " << argv[2];
return 1;
}
fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << endl;
for (list<pair<string, string> >::iterator it = versions.begin(), it_end = versions.end(); it != it_end; ++it)
{
if (it->first == "EXTRA")
{
if (!version_extra.empty())
fd << "#define VERSION_EXTRA \"" << version_extra << "\"" << endl;
else
fd << "#define VERSION_EXTRA \"" << it->second << "\"" << endl;
}
else
fd << "#define VERSION_" << it->first << " " << it->second << endl;
}
fd << version_build << endl;
fd << build << endl;
fd.close();
return 0;
}
-63
View File
@@ -1,63 +0,0 @@
#!/bin/sh
#
# Build version string and increment Services build number.
#
if [ $# -lt 2 ] ; then
echo "Syntax: $0 <version.log> <version.h>"
exit 1
fi
# Grab version information from the version control file.
CTRL="$1"
if [ -f $CTRL ] ; then
. $CTRL
else
echo "Error: Unable to find control file: $CTRL"
exit 0
fi
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA} (${VERSION_BUILD})"
VERSIONDOTTED="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA}.${VERSION_BUILD}"
VERSIONH="$2"
if [ -f $VERSIONH ] ; then
BUILD=`fgrep '#define BUILD' $VERSIONH | cut -f2 -d\"`
BUILD=`expr $BUILD + 1 2>/dev/null`
else
BUILD=1
fi
if [ ! "$BUILD" ] ; then
BUILD=1
fi
cat >$VERSIONH <<EOF
/* Version information for Services.
*
* (C) 2003-2010 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and CREDITS for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* This file is auto-generated by version.sh
*
*/
#ifndef VERSION_H
#define VERSION_H
#define VERSION_MAJOR $VERSION_MAJOR
#define VERSION_MINOR $VERSION_MINOR
#define VERSION_PATCH $VERSION_PATCH
#define VERSION_EXTRA "$VERSION_EXTRA"
#define VERSION_BUILD $VERSION_BUILD
#define BUILD "$BUILD"
#define VERSION_STRING "$VERSION"
#define VERSION_STRING_DOTTED "$VERSIONDOTTED"
#endif
EOF
-248
View File
@@ -1,248 +0,0 @@
/* version file handler for win32.
*
* (C) 2003-2010 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for furhter details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* Written by Dominick Meglio <codemastr@unrealircd.com>
*/
/* Needed due to Windows lack of a decent interpreter */
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <cctype>
long version_major, version_minor, version_patch, version_build, build;
char *version_extra = NULL;
char version[1024];
char version_dotted[1024];
void load_ctrl(FILE *);
long get_value(char *);
char *get_value_str(char *);
char *strip(char *);
void parse_version(FILE *);
void write_version(FILE *, const char *);
void parse_line(FILE *, char *);
int main(int argc, char *argv[])
{
if (argc < 4)
{
fprintf(stderr, "Syntax: %s <version.log> <version.sh> <version.h>\n", argv[0]);
exit(1);
}
FILE *fd = fopen(argv[1], "r");
if (!fd)
{
fprintf(stderr, "Error: Unable to find control file: %s\n", argv[1]);
exit(0);
}
load_ctrl(fd);
fclose(fd);
_snprintf(version, 1024, "%ld.%ld.%ld%s (%ld)", version_major, version_minor, version_patch, version_extra ? version_extra : "", version_build);
_snprintf(version_dotted, 1024, "%ld.%ld.%ld%s.%ld", version_major, version_minor, version_patch, version_extra ? version_extra : "", version_build);
fd = fopen(argv[3], "r");
if (fd)
{
parse_version(fd);
fclose(fd);
}
else
build = 1;
fd = fopen(argv[3], "w");
write_version(fd, argv[2]);
fclose(fd);
if (version_extra)
free(version_extra);
}
void load_ctrl(FILE * fd)
{
char buf[512];
while (fgets(buf, 511, fd))
{
char *var;
strip(buf);
var = strtok(buf, "=");
if (!var)
continue;
if (!strcmp(var, "VERSION_MAJOR"))
version_major = get_value(strtok(NULL, ""));
else if (!strcmp(var, "VERSION_MINOR"))
version_minor = get_value(strtok(NULL, ""));
else if (!strcmp(var, "VERSION_PATCH"))
version_patch = get_value(strtok(NULL, ""));
else if (!strcmp(var, "VERSION_BUILD"))
version_build = get_value(strtok(NULL, ""));
else if (!strcmp(var, "VERSION_EXTRA"))
version_extra = get_value_str(strtok(NULL, ""));
}
}
char *strip(char *str)
{
char *c;
if ((c = strchr(str, '\n')))
*c = 0;
if ((c = strchr(str, '\r')))
*c = 0;
return str;
}
long get_value(char *string)
{
// XXX : if the fields in version.log are empty strtok returns a double quote, dont try to atol it then
if (string[1] != '"')
return atol(get_value_str(string));
else
return 0;
}
char *get_value_str(char *string)
{
int len;
char *newstr;
if (*string == '"')
++string;
len = strlen(string);
if (string[len - 1] == '"')
string[len - 1] = 0;
if (!*string)
return NULL;
newstr = (char *)malloc(len + 1);
strcpy(newstr, string);
return newstr;
//return strdup(string);
}
void parse_version(FILE * fd)
{
char buf[1024];
while (fgets(buf, 1023, fd))
{
char *para1;
strip(buf);
para1 = strtok(buf, " \t");
if (!para1)
continue;
if (!strcmp(para1, "#define"))
{
char *para2 = strtok(NULL, " \t");
if (!para2)
continue;
if (!strcmp(para2, "BUILD"))
{
char *value = strtok(NULL, "");
build = get_value(value);
build++;
return;
}
}
}
build = 1;
}
void write_version(FILE *fd, const char *input)
{
FILE *fdin = fopen(input, "r");
char buf[1024];
short until_eof = 0;
while (fgets(buf, 1023, fdin))
{
strip(buf);
if (until_eof)
{
if (!strcmp(buf, "EOF"))
break;
else
parse_line(fd, buf);
}
if (!strcmp(buf, "cat >$VERSIONH <<EOF"))
until_eof = 1;
}
if (fdin)
fclose(fdin);
}
void parse_line(FILE *fd, char *line)
{
char *c;
for (c = line; *c; ++c)
{
/* It's a variable, find out which */
if (*c == '$')
{
char *var, *varbegin;
if (*(c + 1))
++c;
else
continue;
for (var = varbegin = c; var; ++var)
if (!isalnum(*var) && *var != '_')
break;
if (var != varbegin)
{
char tmp = *var;
*var = 0;
if (!strcmp(varbegin, "VERSION_MAJOR"))
fprintf(fd, "%ld", version_major);
else if (!strcmp(varbegin, "VERSION_MINOR"))
fprintf(fd, "%ld", version_minor);
else if (!strcmp(varbegin, "VERSION_PATCH"))
fprintf(fd, "%ld", version_patch);
else if (!strcmp(varbegin, "VERSION_EXTRA"))
{
if (version_extra)
fprintf(fd, "%s", version_extra);
}
else if (!strcmp(varbegin, "VERSION_BUILD"))
fprintf(fd, "%ld", version_build);
else if (!strcmp(varbegin, "BUILD"))
fprintf(fd, "%ld", build);
else if (!strcmp(varbegin, "VERSION"))
fprintf(fd, "%s", version);
else if (!strcmp(varbegin, "VERSIONDOTTED"))
fprintf(fd, "%s", version_dotted);
if (tmp)
fputc(tmp, fd);
}
c = var;
}
else
fputc(*c, fd);
}
/* We only need \n here - we didn't open the file as binary -GD */
fprintf(fd, "\n");
}