forked from xmos/test_support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.pl
executable file
·117 lines (101 loc) · 2.15 KB
/
Build.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
#!/usr/bin/perl
# Copyright 2016-2021 XMOS LIMITED.
# This Software is subject to the terms of the XMOS Public Licence: Version 1.
use warnings;
use strict;
use Carp;
use SetupEnv;
use File::Copy;
use File::Path;
use XmosBuildLib;
use XmosArg;
my $xmosArg;
my $MAKE_FLAGS;
my $CONFIG;
my $DOMAIN;
my $BIN;
my %ALIASES =
(
'all' => [ 'install' ]
);
my %TARGETS =
(
'install' => [ \&DoInstall, "Install" ],
);
sub main
{
$xmosArg = XmosArg::new(\@ARGV);
SetupEnv::SetupPaths();
my @targets =
sort { XmosBuildLib::ByTarget($a, $b) }
(@{ $xmosArg->GetTargets() });
$MAKE_FLAGS = $xmosArg->GetMakeFlags();
$DOMAIN = $xmosArg->GetOption("DOMAIN");
$CONFIG = $xmosArg->GetOption("CONFIG");
$BIN = $xmosArg->GetBinDir();
foreach my $target (@targets) {
DoTarget($target);
}
return 0;
}
sub DoTarget
{
my $target = $_[0];
if ($target eq "list_targets") {
ListTargets();
} else {
my $targets = $ALIASES{$target};
if (defined($targets)) {
# Target is an alias
foreach my $target (@$targets) {
DoTarget($target);
}
} else {
my $function = $TARGETS{$target}[0];
if (defined($function)) {
print(" ++ $target\n");
&$function();
}
}
}
}
sub ListTargets
{
foreach my $target (keys(%TARGETS)) {
print("$target\n");
}
foreach my $alias (keys(%ALIASES)) {
print("$alias\n");
}
}
sub PrintUsage
{
my $target;
my $alias;
my $targets;
my $targetTable;
my $description;
print("Usage:\n");
print(" Build.pl targets\n");
print("\n");
print(" Available targets:\n");
while (($target, $targetTable) = each(%TARGETS)) {
$description = @$targetTable[1];
print(" $target - $description\n");
}
while (($alias, $targets) = each(%ALIASES)) {
$description = "does";
foreach $target (@$targets) {
$description = "$description \'$target\' ";
}
print(" $alias - $description\n");
}
print(" list_targets - List all targets\n");
exit(1);
}
sub DoInstall
{
XmosBuildLib::InstallDirectory($DOMAIN, "", "lib/python", "");
XmosBuildLib::InstallReleaseDirectory($DOMAIN, "", "lib/python", "");
}
main()