Add a couple of built-ins to the vectorisation monad
[ghc-hetmet.git] / push-all
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 my @top_dirs = ("nofib", "testsuite");
6
7 my $reporoot;
8
9 my $verbose = 1;
10 my $ignore_failure = 0;
11
12 # --checked-out says we are pushing to a checked out tree
13 my $checked_out = 0;
14 # --core-only says we only want to push corelibs, not extralibs
15 my $core_only = 0;
16
17 sub message {
18     if ($verbose) {
19         print "@_\n";
20     }
21 }
22
23 sub warning {
24     print "warning: @_\n";
25 }
26
27 sub darcs {
28     message "== running darcs @_";
29     system ("darcs", @_) == 0
30         or $ignore_failure
31         or die "darcs failed: $?";
32 }
33
34 sub darcs_push {
35     darcs ("push", "--no-set-default", @_);
36 }
37
38 sub pushall {
39     my $dir;
40     my $ghcrepo = $checked_out ? $reporoot : "$reporoot/ghc";
41     darcs_push ($ghcrepo, @_);
42     for $dir (@top_dirs) {
43         if (-d $dir && -d "$dir/_darcs") {
44             darcs_push ("$reporoot/$dir", @_, "--repodir", $dir);
45         }
46         else {
47             message "== $dir not present or not a repository; skipping";
48         }
49     }
50     my $library_lists = $core_only
51                       ? "libraries/core-packages"
52                       : "libraries/core-packages libraries/extra-packages";
53     for my $pkg (`cat $library_lists`) {
54         chomp $pkg;
55         $dir = "libraries/$pkg";
56         if (-d "$dir") {
57             darcs_push ("$reporoot/$dir", @_, "--repodir", "$dir");
58         }
59         else {
60             warning("$pkg doesn't exist, use 'darcs-all get' to get it");
61         }
62     }
63 }
64
65 sub main {
66     if (! -d "_darcs" || ! -d "compiler") {
67         die "error: darcs-all must be run from the top level of the ghc tree."
68     }
69
70     if ($#_ ne -1) {
71         while ($#_ ne -1) {
72             my $arg = shift;
73             # We handle -q here as well as lower down as we need to skip
74             # over it if it comes before the darcs command
75             if ($arg eq "-q") {
76                 $verbose = 0;
77             }
78             elsif ($arg eq "--ignore-failure") {
79                 $ignore_failure = 1;
80             }
81             elsif ($arg eq "--checked-out") {
82                 $checked_out = 1;
83             }
84             elsif ($arg eq "--core-only") {
85                 $core_only = 1;
86             }
87             else {
88                 $reporoot = $arg;
89                 if (grep /^-q$/, @_) {
90                     $verbose = 0;
91                 }
92                 last;
93             }
94         }
95     }
96     else {
97         die "Where do you want to push to?";
98     }
99
100     pushall (@_);
101 }
102
103 main(@ARGV);
104