view @ 1065:dc576c7e4b1e

Fix to make sure to create gen/ in build dir and unbreak build with older perl
author Frits van Bommel <fvbommel>
date Sun, 08 Mar 2009 16:37:55 +0100
parents f0b6549055ab
children 829ac3f30103
line wrap: on
line source

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

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

my $llvm_rev = `svnversion --committed $llvm_src`;
my $llvm_rev_str;
my $llvm_rev_nr;

if ($llvm_rev =~ /^\s*(\d+:)?((\d+)[MSP]*)\s*$/) {
	$llvm_rev_str = qq!#define LLVM_REV_STR "LLVM rev. $2"!;
	$llvm_rev_nr = "$3";
} 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_str = qq!#include "llvm/Config/config.h"\n#define LLVM_REV_STR PACKAGE_STRING" ($llvm_rev)"!;
	# Assume latest release, so < any version we should be testing for.
	$llvm_rev_nr = 0;

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

// LLVM version string, for use in -version output
// LLVM svn revision number, used to adapt to changes in LLVM
// (Is 0 if LLVM is not an SVN version)
#define LLVM_REV $llvm_rev_nr
// LDC version string, for use in -version output
#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;