forked from uwcms/vivado-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.pl
executable file
·127 lines (118 loc) · 4.54 KB
/
checkout.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/perl
use warnings;
use strict;
use Cwd qw(getcwd);
use POSIX qw(WEXITSTATUS);
open(RVV, '<', 'RepoVivadoVersion');
my $VIVADO_VERSION = <RVV>; chomp $VIVADO_VERSION;
close(RVV);
unless ($VIVADO_VERSION) {
printf "Unable to detect the Vivado version in use in this repository.\n";
exit(1);
}
if ($ENV{PATH} !~ m!/Vivado/\Q$VIVADO_VERSION\E(/\.)?/bin!) {
printf "You are not running Vivado $VIVADO_VERSION or have not sourced the environment initialization scripts. Aborting.\n";
exit(1);
}
my %MESSAGES;
printf "~~~ Destroying backup workspace! ~~~\n";
system('rm', '-rf', 'workspace.bak');
printf "\n";
printf "~~~ Backing up and replacing current workspace\n";
if (-e 'workspace' && !rename('workspace', 'workspace.bak')) {
printf "~~~ Failed to rename workspace to workspace.bak. Aborting.\n";
exit(2);
}
if (!mkdir('workspace')) {
printf "~~~ Failed to create workspace. Aborting.\n";
exit(2);
}
if (-e 'ip_repo_sources') {
printf "\n";
printf "~"x80 ."\n";
printf "~~~ COPYING IP_REPO\n";
printf "~~~\n";
system('rsync',
'-rhtci', '--del',
'ip_repo_sources/',
'workspace/ip_repo/');
printf "~~~\n";
printf "\n";
}
open(PROJECTLIST, '<', 'projects.list');
while (my $ProjectCanonicalName = <PROJECTLIST>) {
chomp $ProjectCanonicalName;
my $SourcesDir = sprintf("sources/%s", $ProjectCanonicalName);
my $ProjectDir = sprintf("%s/workspace/%s", getcwd(), $ProjectCanonicalName);
$MESSAGES{$ProjectCanonicalName} = [];
printf "~"x80 ."\n";
printf "~~~ Processing Project: %s\n", $ProjectCanonicalName;
printf "~~~\n";
printf "~~~ Sourcing Project TCL in Vivado\n";
system('vivado', '-mode', 'batch', '-nojournal', '-nolog', '-source', sprintf("sources/%s.tcl", $ProjectCanonicalName));
if (WEXITSTATUS($?)) {
push @{$MESSAGES{$ProjectCanonicalName}}, { Severity => 'CRITICAL ERROR', Message => sprintf("Vivado exited with an unexpected status code after project regeneration: %s. Aborting. The project has NOT necessarily been safely or fully created!", WEXITSTATUS($?)) };
}
else {
printf "~~~ Running any project-specific initialization scripts\n";
my @InitScripts;
push @InitScripts, sprintf("initscripts/%s.pl", $ProjectCanonicalName);
push @InitScripts, sprintf("initscripts/%s.sh", $ProjectCanonicalName);
push @InitScripts, sprintf("initscripts/%s.py", $ProjectCanonicalName);
for my $InitScript (@InitScripts) {
if (-x $InitScript) {
printf "~~~ Running %s\n", $InitScript;
system($InitScript, sprintf("%s/%s.xpr", $ProjectDir, $ProjectCanonicalName));
if (WEXITSTATUS($?)) {
push @{$MESSAGES{$ProjectCanonicalName}}, { Severity => 'WARNING', Message => sprintf("Project initialization script %s exited with nonzero status: %s!", $InitScript, WEXITSTATUS($?)) };
}
}
}
my $InitScript = sprintf("initscripts/%s.tcl", $ProjectCanonicalName);
if (-f $InitScript) {
printf "~~~ Running %s\n", $InitScript;
system('vivado', '-mode', 'batch', '-nojournal', '-nolog', '-source', $InitScript, sprintf("%s/%s.xpr", $ProjectDir, $ProjectCanonicalName));
if (WEXITSTATUS($?)) {
push @{$MESSAGES{$ProjectCanonicalName}}, { Severity => 'WARNING', Message => sprintf("Project initialization script %s exited with nonzero status: %s!", $InitScript, WEXITSTATUS($?)) };
}
}
}
printf "~~~\n";
printf "~~~ Finished processing project %s\n", $ProjectCanonicalName;
printf "\n";
printf "\n";
if (@{$MESSAGES{$ProjectCanonicalName}}) {
printf "~"x80 ."\n";
printf "~~~ MESSAGES FOR PROJECT %s\n", $ProjectCanonicalName;
printf "~~~\n";
for my $Message (@{$MESSAGES{$ProjectCanonicalName}}) {
printf "~~~ %s: %s\n", $Message->{Severity}, $Message->{Message};
}
printf "~~~\n";
}
}
my %MessageTotals;
for my $ProjectCanonicalName (keys %MESSAGES) {
if (@{$MESSAGES{$ProjectCanonicalName}}) {
printf "\n\n\n" unless (%MessageTotals);
printf "~"x80 ."\n";
printf "~~~ MESSAGES FOR PROJECT %s\n", $ProjectCanonicalName;
printf "~~~\n";
for my $Message (@{$MESSAGES{$ProjectCanonicalName}}) {
printf "~~~ %s: %s\n", $Message->{Severity}, $Message->{Message};
$MessageTotals{$Message->{Severity}} = 0 unless exists($MessageTotals{$Message->{Severity}});
$MessageTotals{$Message->{Severity}}++;
}
printf "~~~\n";
}
}
if (grep { $_ } values %MessageTotals) {
printf "~"x80 ."\n";
for my $MessageType (sort keys %MessageTotals) {
printf "~~~ %u %s messages\n", $MessageTotals{$MessageType}, $MessageType;
}
printf "~~~ Please review them carefully and make sure none are dangerous before proceeding.\n";
}
else {
printf "~~~ No issues encountered. Projects generated and ready to use.\n";
}