-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.pl
executable file
·103 lines (89 loc) · 1.9 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
#!/usr/bin/perl
use warnings;
use strict;
use Carp;
use SetupEnv;
use File::Copy;
use File::Path;
use XmosBuildLib;
use XmosArg;
my $MAKE_FLAGS;
my $CONFIG;
my $HOST;
my $DOMAIN;
my $BIN;
my %ALIASES =
(
'all' => ['clean','build','install'],
);
my %TARGETS =
(
'clean' => [\&DoClean, "Clean"],
'build' => [\&DoBuild, "Build"],
'install' => [\&DoInstall, "Install packaged binaries"],
);
sub main
{
my $xmosArg = XmosArg::new(\@ARGV);
SetupEnv::SetupPaths();
my @targets =
sort { XmosBuildLib::ByTarget($a, $b) }
(@{ $xmosArg->GetTargets() });
$MAKE_FLAGS = $xmosArg->GetMakeFlags();
$CONFIG = $xmosArg->GetOption("CONFIG");
$DOMAIN = $xmosArg->GetOption("DOMAIN");
$HOST = $xmosArg->GetOption("HOST");
$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 DoBuild
{
chdir("${XMOS_ROOT}${SLASH}aisrv") or confess "oops";
system("(cd app_alpr && xmake)") == 0
or die "Failed to build ALPR application";
}
sub DoClean
{
chdir("${XMOS_ROOT}${SLASH}aisrv") or confess "oops";
system("(cd app_alpr && xmake clean)") == 0
or die "Failed to build ALPR application";
}
sub DoInstall
{
chdir("${XMOS_ROOT}${SLASH}aisrv") or confess "oops";
XmosBuildLib::InstallReleaseDirectory($DOMAIN, "app_alpr/bin/app_alpr.xe", "app_alpr.xe");
}
main()