1 package Object::Remote::FatNode;
7 my @exclude_mods = qw(XSLoader.pm DynaLoader.pm);
11 $text =~ /^(\s+)/ && $text =~ s/^$1//mg;
15 my %maybe_libs = map +($_ => 1), grep defined, (values %Config, '.');
17 my @extra_libs = grep not(ref($_) or $maybe_libs{$_}), @INC;
19 my $extra_libs = join '', map " -I$_\n", @extra_libs;
25 -mObject::Remote::Connector::STDIO
31 -mObject::Remote::ModuleLoader
32 -mObject::Remote::Node
33 -mMethod::Generate::BuildAll
34 -mMethod::Generate::DemolishAll
36 -e 'print join "\\n", \%INC'
41 chomp(my @inc = qx($command));
43 my %exclude = map { $_ => 1 } @exclude_mods;
44 my %mods = reverse @inc;
46 foreach(keys(%mods)) {
47 if ($exclude{ $mods{$_} }) {
54 /^\Q$Config{privlibexp}/ or /^\Q$Config{archlibexp}/
58 my @file_names = keys %mods;
59 my @before_inc = grep { filter_not_core() } @file_names;
62 my $start = stripspace <<'END_START';
63 # This chunk of stuff was generated by Object::Remote::FatNode. To find
64 # the original file's code, look for the end of this BEGIN block or the
67 my (%fatpacked,%fatpacked_extra);
70 $start .= 'my %exclude = map { $_ => 1 } (\'' . join("','", @exclude_mods) . "');\n";
72 my $end = stripspace <<'END_END';
73 s/^ //mg for values %fatpacked, values %fatpacked_extra;
76 if (my $fat = $_[0]->{$_[1]}) {
77 if ($exclude{$_[1]}) {
78 warn "Will not pre-load '$_[1]'";
82 #warn "Handling $_[1]";
83 open my $fh, '<', \$fat;
87 #Uncomment this to find brokenness
88 #warn "Missing $_[1]";
92 unshift @INC, sub { load_from_hash(\%fatpacked, $_[1]) };
93 push @INC, sub { load_from_hash(\%fatpacked_extra, $_[1]) };
95 } # END OF FATPACK CODE
98 use Object::Remote::Node;
99 Object::Remote::Node->run;
102 my %files = map +($mods{$_} => scalar do { local (@ARGV, $/) = ($_); <> }),
103 @before_inc, @after_inc;
105 sub generate_fatpack_hash {
106 my ($hash_name, $orig) = @_;
107 (my $stub = $orig) =~ s/\.pm$//;
108 my $name = uc join '_', split '/', $stub;
109 my $data = $files{$orig} or die $orig; $data =~ s/^/ /mg;
110 return '$'.$hash_name.'{'.perlstring($orig).qq!} = <<'${name}';\n!
111 .qq!${data}${name}\n!;
115 map(generate_fatpack_hash('fatpacked', $_), sort map $mods{$_}, @before_inc),
116 map(generate_fatpack_hash('fatpacked_extra', $_), sort map $mods{$_}, @after_inc),
119 our $DATA = join "\n", $start, @segments, $end;