-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpcma
More file actions
executable file
·79 lines (61 loc) · 1.05 KB
/
pcma
File metadata and controls
executable file
·79 lines (61 loc) · 1.05 KB
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
#!/usr/bin/perl -s
use 5.024 ;
use vars qw($x $n $i) ;
# -x rebuild all
# -n show commands
# -i incremental (ignore cmakefile changes)
##
sub load_file
{
my($filename, $data) = @_;
local($/, *IN);
if (open(IN, $filename))
{
$data = <IN>;
close IN;
}
$data;
}
##
sub locate_root
{
while ( 1 )
{
die "no cmake" unless -f "CMakeLists.txt" ;
my $cn= load_file( 'CMakeLists.txt' ) ;
return if ( $cn =~ /project\s*\(/ ) ;
chdir( '..' ) ;
}
}
sub construct
{
return if $i ; # no rebuild
return unless $x or ! -d 'build' ;
$x= 1 ;
system( "rm -fr build" ) ;
mkdir( "build" ) ;
}
sub cmake
{
chdir( 'build' ) ;
return if $i ;
system( "cmake -GNinja .." ) ;
}
sub build_target
{
my ( $t ) = @_ ;
my $param ;
$param .= " -j4" unless $i ;
$param .= " -n -v" if $n ;
system( "ninja $param $t" ) ;
exit $? if $? ;
}
{
& locate_root ;
& construct ;
& cmake ;
my ( $target )= @ARGV ;
$target //= 'all' ;
build_target( $target ) ;
build_target( 'test' ) ;
}