Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

root/revisions.pl.in

Revision 1471:230765fc82f4, 2.4 kB (checked in by Frits van Bommel <fvbommel wxs.nl>, 3 years ago)

Emit nicer error messages when the user didn't set LLVM_REV and autodetection
didn't find a suitable revision or when the LLVM revision in use is too old.

Line 
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use File::stat;
6 use Time::localtime;
7
8 my $llvm_src = `perl @LLVM_CONFIG@ --src-root`;
9
10 my $svn_info = `LC_ALL=C svn info $llvm_src 2>/dev/null`;
11
12 my $extra_includes = "";
13 my $llvm_rev_str;
14 my $llvm_rev_nr;
15 my $llvm_date = "";
16
17 if ($svn_info =~ /^URL:.*\/trunk\s*$/m && $svn_info =~ /^Last Changed Rev:\s*(\d+)\s*/m) {
18     $llvm_rev_str = qq!"LLVM trunk rev. $1"!;
19     $llvm_rev_nr = $1;
20 } else {
21     # Either non-trunk or 'svn info' didn't report "Last Changed Rev".
22     $extra_includes = qq!#include "llvm/Config/config.h"!;
23     $llvm_rev_str = "PACKAGE_STRING";
24     # Assume latest release, so < any version we should be testing for.
25     $llvm_rev_nr = 0;
26 }
27
28 # Use SVN date even if non-trunk:
29 if ($svn_info =~ /^Last Changed Date: ([^(]*?)\s*(\(|$)/m) {
30     $llvm_date = qq!" ($1)"!;
31 } else {
32     # Otherwise, try to get it from the libdir
33     my $llvm_lib = `perl @LLVM_CONFIG@ --libdir`;
34     $llvm_lib =~ s/\s+$//;
35     if (-d $llvm_lib) {
36         my $mod_time = ctime(stat($llvm_lib)->mtime);
37         $llvm_date = qq!" ($mod_time)"!;
38     }
39 }
40
41 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})'`;
42
43 my $out = qq!#ifndef LDC_VERSIONS_H
44 #define LDC_VERSIONS_H
45 $extra_includes
46
47 // LLVM version string, for use in -version output
48 #define LLVM_REV_STR $llvm_rev_str$llvm_date
49 // LDC version string, for use in -version output
50 #define LDC_REV "rev. $ldc_rev"
51
52 #endif // LDC_VERSIONS_H\n!;
53
54 my $revh;
55 my $old = "";
56 open $revh, "revisions.h" and $old = join "", <$revh>;
57
58 if ($old ne $out) {
59     open $revh, ">revisions.h" or die "cannot create revisions.h: $!";
60     print $revh $out;
61     close $revh;
62 }
63
64 # Allow the user to manually define it on the command line...
65 $out = qq@#ifndef LLVM_REV
66
67 // LLVM svn revision number, used to adapt to changes in LLVM
68 // (Is 0 if LLVM is not an SVN trunk version)
69 #define LLVM_REV $llvm_rev_nr
70
71 #endif // LLVM_REV
72
73 #if !LLVM_REV
74 #error "You need to add '-DLLVM_REV=<your-llvm-rev>' to CMAKE_CXX_FLAGS in the cmake configuration"
75 #elif LLVM_REV < 67588
76 #error "Please update to a more recent LLVM version"
77 #endif\n@;
78
79 $old = "";
80 open $revh, "llvm-version.h" and $old = join "", <$revh>;
81
82 if ($old ne $out) {
83     open $revh, ">llvm-version.h" or die "cannot create llvm-version.h: $!";
84     print $revh $out;
85     close $revh;
86 }
Note: See TracBrowser for help on using the browser.
Copyright © 2008, LDC Development Team.