Skip to content

Commit

Permalink
Got rid of path-to-module-name and name-to-module-path. They acted qu…
Browse files Browse the repository at this point in the history
…ite funny when we were compiling files in some distant directory
  • Loading branch information
Tadeusz Sośnierz committed Nov 13, 2010
1 parent e86fc40 commit 1f3c08f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/Module/Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ use File::Find;

module Module::Build;

sub path-to-module-name($path) {
$path.subst(/^'lib/'/, '').subst(/\.pm6?$/, '').subst('/', '::', :g)
}

sub module-name-to-path($module-name) {
my $pm = 'lib/' ~ $module-name.subst('::', '/', :g) ~ '.pm';
$pm.IO ~~ :e ?? $pm !! $pm ~ '6';
}

our sub build(Str $dir = '.', Str $binary = 'perl6', :$v) {
if "$dir/Configure.pl".IO ~~ :f {
my $cwd = cwd;
Expand All @@ -32,16 +23,21 @@ our sub build(Str $dir = '.', Str $binary = 'perl6', :$v) {
}

my @module-files = find(dir => "$dir/lib", name => /\.pm6?$/).list;
my %path-to-name;
for @module-files -> $m {
my $n = $m.subst(/^.*lib\//, '').subst(/\.pm6?$/, '').subst('/', '::', :g);
%path-to-name{$m} = $n;
}
my %name-to-path = %path-to-name.invert;


# To know the best order of compilation, we build a dependency
# graph of all the modules in lib/. %usages_of ends up containing
# a graph, with the keys (containing names modules) being nodes,
# and the values (containing arrays of names) denoting directed
# edges.

my @modules = map {
path-to-module-name($_.Str.subst(/\.\/lib\//, ''))
}, @module-files;
my @modules = @module-files.map: { %path-to-name{$_} };
my %usages_of;
for @module-files -> $module-file {
my $fh = open($module-file, :r);
Expand Down Expand Up @@ -81,10 +77,10 @@ our sub build(Str $dir = '.', Str $binary = 'perl6', :$v) {
push @order, $module;
}

for @order».&module-name-to-path -> $module {
for @order.map({ %name-to-path{$_} }) -> $module {
my $pir = $module.subst(/\.pm6?/, ".pir");
next if ($pir.IO ~~ :f &&
$pir.IO.stat.modifytime > $module.IO.stat.modifytime);
$pir.IO.changed > $module.IO.changed);
my $command = "PERL6LIB=$dir/lib $binary --target=PIR "
~ "--output=$pir $module";
say $command if $v.defined;
Expand Down

0 comments on commit 1f3c08f

Please sign in to comment.