2012-03-26 20:57:53 +00:00
|
|
|
use strict;
|
2013-06-29 20:52:01 +00:00
|
|
|
use Time::HiRes ();
|
2012-03-26 20:57:53 +00:00
|
|
|
use FindBin qw($Bin);
|
|
|
|
|
|
|
|
sub build_bin {
|
|
|
|
my $target = shift;
|
2013-06-29 20:52:01 +00:00
|
|
|
my $final_bin = find_bin($target);
|
2013-07-29 17:15:59 +00:00
|
|
|
if ($ENV{CAMLI_FAST_DEV}) {
|
|
|
|
return $final_bin;
|
|
|
|
}
|
|
|
|
|
2013-06-29 20:52:01 +00:00
|
|
|
my $full_target = $target;
|
|
|
|
$full_target =~ s!^\./((cmd|server)/(\w+))$!camlistore.org/$1! or die "Bogus target $target";
|
|
|
|
|
|
|
|
my $mtime = 0;
|
|
|
|
if (-f $final_bin) {
|
|
|
|
$mtime = (stat($final_bin))[9];
|
2012-04-23 00:50:13 +00:00
|
|
|
}
|
2013-06-29 20:52:01 +00:00
|
|
|
|
|
|
|
print STDERR "Building $full_target ...\n";
|
|
|
|
my $t0 = Time::HiRes::time();
|
|
|
|
system("go", "run", "make.go",
|
|
|
|
"--quiet",
|
|
|
|
"--embed_static=false",
|
|
|
|
"--sqlite=false",
|
|
|
|
"--if_mods_since=$mtime",
|
|
|
|
"--targets=$full_target")
|
|
|
|
and die "go install $target failed";
|
|
|
|
my $td = Time::HiRes::time() - $t0;
|
|
|
|
|
|
|
|
print STDERR "Build/init took " . sprintf("%0.03f", $td) . " seconds.\n";
|
|
|
|
|
|
|
|
return $final_bin;
|
2012-03-26 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub find_bin {
|
|
|
|
my $target = shift;
|
|
|
|
$target =~ s!.+/!!;
|
2012-03-27 17:37:21 +00:00
|
|
|
my $bin = find_gobin();
|
|
|
|
return "$bin/$target";
|
2012-03-26 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub find_gobin {
|
2013-06-29 20:52:01 +00:00
|
|
|
return "$Bin/bin";
|
2012-03-26 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|