view revisions.pl.in @ 1052:12ea38902e83

Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file. The switch allows the optimizer and inliner to run on all modules at once and opens the door for template instantiation improvements that should lower compile time and executable size.
author Christian Kamm <kamm incasoftware de>
date Sat, 07 Mar 2009 19:38:00 +0100
parents d66ab756c75b
children f0b6549055ab
line wrap: on
line source

#!/usr/bin/perl

use strict;
use warnings;
use File::stat;
use Time::localtime;

my $llvm_src = `perl @LLVM_CONFIG@ --src-root`;

my $llvm_rev = `svnversion $llvm_src`;

if ($llvm_rev =~ s/(\d+M?)\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@ log -r qparent --template '{rev}:{node|short} ({date|isodate})' 2>/dev/null || hg -R@PROJECT_SOURCE_DIR@ tip --template '{rev}:{node|short} ({date|isodate})'`;

my $out = qq!#ifndef LDC_VERSIONS_H
#define LDC_VERSIONS_H

$llvm_rev
#define LDC_REV "rev. $ldc_rev"

#endif // LDC_VERSIONS_H\n!;

my $revh;
my $old = "";
open $revh, "revisions.h" and $old = join "", <$revh>;

if ($old ne $out) {
	open $revh, ">revisions.h" or die "cannot create revisions.h: $!";
	print $revh $out;
	close $revh;
}