Add Elrood's patch to output LDC and LLVM source revs.

This commit is contained in:
Christian Kamm
2008-12-14 16:51:36 +01:00
parent 44c606c409
commit dff06d0f15
7 changed files with 58 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ syntax: glob
*.a
*.s
*.so
*.rej
Makefile
CMakeFiles
CMakeCache.txt
@@ -25,6 +26,8 @@ syntax: regexp
^impcnvgen
^impcnvgen.make
^ldc.make
^revisions.pl
^dmd2?/revisions.h
^dmd2?/impcnvtab.c
^dmd2?/id.c
^dmd2?/id.h

View File

@@ -160,6 +160,17 @@ endif(CMAKE_MINOR_VERSION LESS 6)
add_executable(${LDC_EXE} ${LDC_SOURCE_FILES})
# generate revision info
configure_file(revisions.pl.in revisions.pl)
add_custom_command(
OUTPUT revisions.h
COMMAND ${PERL_EXECUTABLE} ${PROJECT_BINARY_DIR}/revisions.pl
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${DMDFE_PATH}
)
add_custom_target(gen_revs_h ALL DEPENDS revisions.h)
add_dependencies(${LDC_EXE} gen_revs_h)
#
set(LDC_EXE_NAME ${PROGRAM_PREFIX}${LDC_EXE}${PROGRAM_SUFFIX})
set_target_properties(

View File

@@ -38,8 +38,7 @@
#include "gen/logger.h"
#include "gen/linker.h"
#include "llvm/Config/config.h"
#include "revisions.h"
void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
@@ -65,7 +64,8 @@ Global::Global()
copyright = "Copyright (c) 1999-2008 by Digital Mars and Tomas Lindquist Olsen";
written = "written by Walter Bright and Tomas Lindquist Olsen";
version = "v1.037";
ldc_version = "0.1";
ldc_version = LDC_REV;
llvm_version = LLVM_REV;
global.structalign = 8;
memset(&params, 0, sizeof(Param));
@@ -152,8 +152,8 @@ extern void backend_term();
void usage()
{
printf("LLVM D Compiler %s (based on DMD %s and %s)\n%s\n%s\n",
global.ldc_version, global.version, PACKAGE_STRING, global.copyright, global.written);
printf("LLVM D Compiler %s\nbased on DMD %s and %s\n%s\n%s\n",
global.ldc_version, global.version, global.llvm_version, global.copyright, global.written);
printf("\
D Language Documentation: http://www.digitalmars.com/d/1.0/index.html\n\
LDC Homepage: http://www.dsource.org/projects/ldc\n\

View File

@@ -186,6 +186,7 @@ struct Global
int structalign;
char *version;
char *ldc_version;
char *llvm_version;
Param params;
unsigned errors; // number of errors reported so far

View File

@@ -39,7 +39,7 @@
#include "gen/logger.h"
#include "gen/linker.h"
#include "llvm/Config/config.h"
#include "revisions.h"
void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
@@ -152,8 +152,8 @@ extern void backend_term();
void usage()
{
printf("LLVM D Compiler %s (based on DMD %s and %s)\n%s\n%s\n",
global.ldc_version, global.version, PACKAGE_STRING, global.copyright, global.written);
printf("LLVM D Compiler %s\nbased on DMD %s and %s\n%s\n%s\n",
global.ldc_version, global.version, global.llvm_version, global.copyright, global.written);
printf("\
D Language Documentation: http://www.digitalmars.com/d/2.0/index.html\n\
LDC Homepage: http://www.dsource.org/projects/ldc\n\

View File

@@ -193,6 +193,7 @@ struct Global
int structalign;
const char *version;
const char *ldc_version;
const char *llvm_version;
Param params;
unsigned errors; // number of errors reported so far

34
revisions.pl.in Normal file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/perl
use strict;
use warnings;
use File::stat;
use Time::localtime;
my $llvm_src = `perl @LLVM_CONFIG@ --src-root`;
#my $llvm_src = "k:/sources/llvm";
my $llvm_rev = `svnversion $llvm_src`;
if ($llvm_rev =~ s/(\d+)\s+$/$1/) {
$llvm_rev = qq!#define LLVM_REV "LLVM rev.$llvm_rev"!
} else {
my $llvm_lib = `perl @LLVM_CONFIG@ --libdir`;
$llvm_lib =~ s/\s+$//;
$llvm_rev = ctime(stat($llvm_lib)->mtime) if (-d $llvm_lib);
$llvm_rev = qq!#include "llvm/Config/config.h"\n#define LLVM_REV PACKAGE_STRING" ($llvm_rev)"!;
}
my $ldc_rev = `hg -R@PROJECT_SOURCE_DIR@ tip --template {rev}`;
open my $revh, ">", "revisions.h" or die "cannot create revisions.h";
print $revh qq!#ifndef LDC_VERSIONS_H
#define LDC_VERSIONS_H
$llvm_rev
#define LDC_REV "rev.$ldc_rev"
#endif // LDC_VERSIONS_H\n!;
close $revh;