Skip to content

Commit

Permalink
Start to deal with some of the excessive UNIX-isms. This gets rid of …
Browse files Browse the repository at this point in the history
…the reliance on the find command, which means we can actually generate a Makefile now for projects without one. It's broken, but it's a step forward. Also replace one call out to mkdir with the Perl 6 command.
  • Loading branch information
jnthn committed Jul 14, 2010
1 parent a711098 commit 5273a90
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions proof-of-concept
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class POC::Fetcher does App::Pls::Fetcher {
die "Not able to fetch non-github projects yet, sorry :/"
unless $project<home> eq 'github';
if "cache" !~~ :e {
run-logged "mkdir cache", :step('fetch'), :$project;
mkdir('cache');
}
if "cache" !~~ :d {
die "Cannot proceed, cache inexplicably isn't a directory";
Expand All @@ -117,6 +117,21 @@ class POC::Fetcher does App::Pls::Fetcher {
}

class POC::Builder does App::Pls::Builder {
sub find-files($in-dir, $pattern) {
my @files = dir($in-dir);
my @found;
for @files -> $f {
next if $f eq '.' | '..';
if "$in-dir/$f" ~~ :d {
@found.push(find-files("$in-dir/$f", $pattern));
}
elsif $f ~~ $pattern {
@found.push("$in-dir/$f");
}
}
return @found;
}

method build($project --> Result) {
my $target-dir = "cache/$project<name>";
if "$target-dir/Makefile" !~~ :e {
Expand All @@ -129,17 +144,13 @@ class POC::Builder does App::Pls::Builder {
return failure;
}

# The grep is needed because 'find' prints a final newline, so
# there'll be an empty-string element at the end of the list.

my @module-files
= grep { $_ },
split "\n",
qqx[cd $target-dir; find lib -name \*.pm -or -name \*.pm6];
# Locate Perl 6 module files.

if !@module-files || @module-files[0].lc ~~ /'no such file'/ {
my @module-files = find-files("$target-dir/lib", /\.pm6?$/);
if !@module-files {
return success;
}
@module-files>>.=subst("$target-dir/", "");

# To know the best order of compilation, we build a dependency
# graph of all the modules in lib/. %usages_of ends up containing
Expand Down

0 comments on commit 5273a90

Please sign in to comment.