Skip to content

Commit

Permalink
make CUR.bindir overridable
Browse files Browse the repository at this point in the history
This is useful when several CURs share a single bin directory on disk.
Also when we have repositories that keep the distribution data on a non-local
storage, we need to keep the wrapper scripts in a local bindir, so that these
can be in PATH.
Rakudo Star will be the first user of this funtionality.
  • Loading branch information
FROGGS committed Jan 25, 2016
1 parent d67cb03 commit cf7706f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/core/CompUnit/Repository/Installation.pm
Expand Up @@ -6,7 +6,7 @@ class CompUnit::Repository::Installation does CompUnit::Repository::Locally does

my $verbose := nqp::getenvhash<RAKUDO_LOG_PRECOMP>;

submethod BUILD(:$!prefix, :$!lock, :$!WHICH, :$!next-repo) { }
submethod BUILD(:$!prefix, :$!bindir, :$!lock, :$!WHICH, :$!next-repo) { }

method writeable-path {
$.prefix.w ?? $.prefix !! IO::Path;
Expand Down Expand Up @@ -68,7 +68,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
exit 1;
}
exit run($*EXECUTABLE-NAME, @binaries[0].hash.<files><bin/#name#>, @*ARGS).exitcode
exit run($*EXECUTABLE, @binaries[0].hash.<files><bin/#name#>, @*ARGS).exitcode
}';

method !sources-dir() {
Expand All @@ -90,7 +90,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
}

method !bin-dir() {
my $bin = $.prefix.child('bin');
my $bin = $!bindir || $.prefix.child('bin');
$bin.mkdir unless $bin.e;
$bin
}
Expand Down Expand Up @@ -154,14 +154,14 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
my $destination = $resources-dir.child($id);
my $withoutext = $basename.subst(/\.[exe|bat]$/, '');
for '', '-j', '-m' -> $be {
"$path/bin/$withoutext$be".IO.spurt:
"$bin-dir/$withoutext$be".IO.spurt:
$perl_wrapper.subst('#name#', $basename, :g).subst('#perl#', "perl6$be").subst('#dist-name#', $dist.name);
if $is-win {
"$path/bin/$withoutext$be.bat".IO.spurt:
"$bin-dir/$withoutext$be.bat".IO.spurt:
$windows_wrapper.subst('#perl#', "perl6$be", :g);
}
else {
"$path/bin/$withoutext$be".IO.chmod(0o755);
"$bin-dir/$withoutext$be".IO.chmod(0o755);
}
}
self!add-short-name($basename, $dist);
Expand Down
10 changes: 6 additions & 4 deletions src/core/CompUnit/Repository/Locally.pm
@@ -1,16 +1,18 @@
role CompUnit::Repository::Locally {
has Lock $!lock;
has IO::Path $.prefix is required;
has IO::Path $.bindir is rw;
has Str $.WHICH;

my %instances;

method new(CompUnit::Repository::Locally: Str:D :$prefix, CompUnit::Repository :$next-repo) {
my $abspath := $*SPEC.rel2abs($prefix);
my $IO := IO::Path.new-from-absolute-path($abspath);
method new(CompUnit::Repository::Locally: Str:D :$prefix, :$bindir, CompUnit::Repository :$next-repo) {
my $abspath := $*SPEC.rel2abs($prefix);
my $IO-prefix := IO::Path.new-from-absolute-path($abspath);
my $IO-bindir := $bindir ?? IO::Path.new-from-absolute-path($bindir) !! IO::Path;

%instances{$abspath} //=
self.bless(:prefix($IO), :lock(Lock.new), :WHICH(self.^name ~ '|' ~ $abspath), :$next-repo);
self.bless(:prefix($IO-prefix), :bindir($IO-bindir), :lock(Lock.new), :WHICH(self.^name ~ '|' ~ $abspath), :$next-repo);
}

multi method Str(CompUnit::Repository::Locally:D:) { $!prefix.abspath }
Expand Down

0 comments on commit cf7706f

Please sign in to comment.