From ac288f000957d00c26e742df0756d63350046193 Mon Sep 17 00:00:00 2001 From: Tobias Leich Date: Tue, 5 Jan 2016 21:40:28 +0100 Subject: first working post 6.c star --- tools/build/Makefile.in | 11 ++-- tools/build/module-install.pl | 113 +++--------------------------------------- 2 files changed, 9 insertions(+), 115 deletions(-) (limited to 'tools/build') diff --git a/tools/build/Makefile.in b/tools/build/Makefile.in index b2cc03f..df6e19c 100644 --- a/tools/build/Makefile.in +++ b/tools/build/Makefile.in @@ -3,7 +3,7 @@ MOAR_DIR = moarvm NQP_DIR = nqp RAKUDO_DIR = rakudo -STAR_VERSION = 2015.11 +STAR_VERSION = 2015.12 # install location PREFIX_DIR = @prefix@ @@ -69,13 +69,8 @@ modules-install-j: modules-install-m: @echo "== Installing modules for MoarVM" - $(PERL) tools/build/module-install.pl $(DESTDIR)$(PERL6_M_INSTALL) $(DESTDIR)$(PERL6_M_LANG_DIR)/lib moarvm mbc $(MODULES) - @echo "== Installing binaries for MoarVM" - $(PERL) tools/build/bin-install.pl $(PERL6_M_INSTALL) $(DESTDIR)$(MOAR_BIN_DIR) m modules/ufo/bin/ufo modules/panda/bin/panda modules/doc/bin/p6doc - $(PERL) tools/build/bin-install.pl $(PERL6_M_INSTALL) $(DESTDIR)$(MOAR_BIN_DIR) m modules/ufo/bin/ufo modules/panda/bin/panda modules/doc/bin/p6doc-index - $(MKPATH) $(DESTDIR)$(PERL6_M_LANG_DIR)/site/panda/ - $(CP) install/share/perl6/site/panda/projects.json $(DESTDIR)$(PERL6_M_LANG_DIR)/site/panda/ - $(CP) install/share/perl6/site/panda/state $(DESTDIR)$(PERL6_M_LANG_DIR)/site/panda/ + cd modules/panda && $(DESTDIR)$(PERL6_M_INSTALL) bootstrap.pl --bin-prefix=$(DESTDIR)$(MOAR_BIN_DIR) + $(PERL) tools/build/module-install.pl $(PERL6_M_INSTALL) $(DESTDIR)$(MOAR_BIN_DIR)/panda-m$(BAT) $(DESTDIR)$(MOAR_BIN_DIR) $(MODULES) modules-test: @backend_modules_test@ verbose-modules-test: @backend_modules_test@ diff --git a/tools/build/module-install.pl b/tools/build/module-install.pl index 0766398..4caacb7 100644 --- a/tools/build/module-install.pl +++ b/tools/build/module-install.pl @@ -2,117 +2,16 @@ use warnings; use strict; -use File::Find; -use File::Copy; -use File::Path; -use File::Basename; +my $perl6bin = shift @ARGV; +my $pandabin = shift @ARGV; +my $bindir = shift @ARGV; -my $perl6bin = shift @ARGV; -my $perl6lib = shift @ARGV; -my $compext = shift @ARGV; -my $comptarget = shift @ARGV; +my $exit = 0; -my @pmfiles; -my @mod_pms; while (<>) { next if /^\s*(#|$)/; my ($module) = /(\S+)/; - print "== Installing modules/$module\n"; - our $mlib = "modules/$module/lib"; - - @mod_pms = (); - find({ no_chdir=>1, wanted => \&libcopy }, $mlib); - - sub libcopy { - return unless /\.pm6?$|\.pod$/; - my $source = $File::Find::name; - my $target = $source; - $target =~ s/\Q$mlib\E/$perl6lib/; - print "$source => $target\n"; - mkpath dirname($target); - copy($source, $target) or die "copy failed: $!\n"; - push @mod_pms, $target if $target =~ /\.pm6?$/; - } - - my %usages_of; - my @modules; - my %module_to_path; - for my $module_file (@mod_pms) { - open(my $fh, '<', $module_file) or die $!; - my $module = path_to_module_name($module_file); - push @modules, $module; - $module_to_path{$module} = $module_file; - $usages_of{$module} = []; - while (<$fh>) { - if (/^\s* (?:use|need|require) \s+ (\w+ (?: :: \w+)*)/x and my $used = $1) { - next if $used eq 'v6'; - next if $used eq 'MONKEY_TYPING'; - - push @{$usages_of{$module}}, $used; - } - } - } - - my @order = topo_sort(\@modules, \%usages_of); - my @sources = map { $module_to_path{$_} } @order; - push @pmfiles, @sources; + $exit ||= system $perl6bin, $pandabin, '--force', "--bin-prefix=$bindir", "install", "modules/$module"; } -# Internally, we treat the module names as module names, '::' and all. -# But since they're really files externally, they have to be converted -# from paths to module names, and back again. - -sub path_to_module_name { - $_ = shift; - s/^.+\blib\///; - s/^.+\blib6\///; - s/\.pm6?$//; - s/\//::/g; - $_; -} - -do { - local $ENV{'PERL6LIB'} = $perl6lib; - - print "== Precompiling modules\n"; - chdir 'rakudo'; - foreach my $pm (@pmfiles) { - my @cmd = ($perl6bin, "--target=$comptarget", "--output=$pm.$compext", $pm); - print join(' ', @cmd), "\n"; - system(@cmd); - } -}; - - -# According to "Introduction to Algorithms" by Cormen et al., topological -# sort is just a depth-first search of a graph where you pay attention to -# the order in which you get done with a dfs-visit() for each node. - -sub topo_sort { - my ($modules, $dependencies) = @_; - my @modules = @$modules; - my @order; - my %color_of = map { $_ => 'not yet visited' } @modules; - - for my $module (@modules) { - if ($color_of{$module} eq 'not yet visited') { - dfs_visit($module, \%color_of, $dependencies, \@order); - } - } - return @order; -} - -sub dfs_visit { - my $module = shift; - my $color_of = shift; - my $dependencies = shift; - my $order = shift; - $color_of->{$module} = 'visited'; - for my $used (@{$dependencies->{$module}}) { - $color_of->{$used} ||= ''; - if ($color_of->{$used} eq 'not yet visited') { - dfs_visit($used, $color_of, $dependencies, $order); - } - } - push @$order, $module; -} +exit $exit; -- cgit v1.1