Commit a3bdc2c2 authored by Barry Warsaw's avatar Barry Warsaw

Handle a couple of use cases discussed in python-dev w.r.t. calculating the

Subversion revision number.

First, in an svn export, there will be no .svn directory, so use an in-file
$Revision$ keyword string with the keyword chrome stripped off.

Also, use $(srcdir) in the Makefile.pre.in to handle the case where Python is
build outside the source tree.
parent d24499dc
...@@ -349,12 +349,9 @@ buildno: $(PARSER_OBJS) \ ...@@ -349,12 +349,9 @@ buildno: $(PARSER_OBJS) \
$(SIGNAL_OBJS) \ $(SIGNAL_OBJS) \
$(MODOBJS) \ $(MODOBJS) \
$(srcdir)/Modules/getbuildinfo.c $(srcdir)/Modules/getbuildinfo.c
if test -d .svn; then \ if test -d $(srcdir)/.svn; then \
svnversion . >buildno; \ svnversion $(srcdir) >buildno; \
elif test -f buildno; then \ fi
expr `cat buildno` + 1 >buildno1; \
mv -f buildno1 buildno; \
else echo 1 >buildno; fi
# Build static library # Build static library
# avoid long command lines, same as LIBRARY_OBJS # avoid long command lines, same as LIBRARY_OBJS
...@@ -446,7 +443,11 @@ Modules/Setup: $(srcdir)/Modules/Setup.dist ...@@ -446,7 +443,11 @@ Modules/Setup: $(srcdir)/Modules/Setup.dist
# Special rules for object files # Special rules for object files
Modules/getbuildinfo.o: $(srcdir)/Modules/getbuildinfo.c buildno Modules/getbuildinfo.o: $(srcdir)/Modules/getbuildinfo.c buildno
$(CC) -c $(PY_CFLAGS) -DBUILD=\"`cat buildno`\" -o $@ $(srcdir)/Modules/getbuildinfo.c if test -f buildno; then \
$(CC) -c $(PY_CFLAGS) -DBUILD=\"`cat buildno`\" -o $@ $(srcdir)/Modules/getbuildinfo.c ;\
else \
$(CC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/getbuildinfo.c ;\
fi
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
......
...@@ -21,20 +21,38 @@ ...@@ -21,20 +21,38 @@
#endif #endif
#ifndef BUILD #ifndef BUILD
#define BUILD "0" #define BUILD "$Revision$"
#endif #endif
const char * const char *
Py_GetBuildInfo(void) Py_GetBuildNumber(void)
{ {
static char buildinfo[50]; static char buildno[20];
PyOS_snprintf(buildinfo, sizeof(buildinfo), static int buildno_okay;
"%s, %.20s, %.9s", BUILD, DATE, TIME);
return buildinfo; if (!buildno_okay) {
char *build = BUILD;
int len = strlen(build);
if (len > 13 &&
!strncmp(build, "$Revision: ", 11) &&
!strcmp(build + len - 2, " $"))
{
memcpy(buildno, build + 11, len - 13);
}
else {
memcpy(buildno, build, 19);
}
buildno_okay = 1;
}
return buildno;
} }
const char * const char *
Py_GetBuildNumber(void) Py_GetBuildInfo(void)
{ {
return BUILD; static char buildinfo[50];
PyOS_snprintf(buildinfo, sizeof(buildinfo),
"#%s, %.20s, %.9s", Py_GetBuildNumber(), DATE, TIME);
return buildinfo;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment