1 package Object::Remote::FatNode;
9 $text =~ /^(\s+)/ && $text =~ s/^$1//mg;
13 my %maybe_libs = map +($_ => 1), grep defined, (values %Config, '.');
15 my @extra_libs = grep not(ref($_) or $maybe_libs{$_}), @INC;
17 my $extra_libs = join '', map " -I$_\n", @extra_libs;
23 -mObject::Remote::Connector::STDIO
29 -mObject::Remote::ModuleLoader
30 -mObject::Remote::Node
31 -mMethod::Generate::BuildAll
32 -mMethod::Generate::DemolishAll
34 -e 'print join "\\n", \%INC'
39 chomp(my @inc = qx($command));
41 my %mods = reverse @inc;
43 my @non_core = grep +(
45 /^\Q$Config{privlibexp}/ or /^\Q$Config{archlibexp}/
50 /^\Q$Config{privlibexp}/
54 if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) {
55 my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
56 return unless $level =~ /^\w+$/;
57 $env_pass = '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
60 my $start = stripspace <<'END_START';
61 # This chunk of stuff was generated by Object::Remote::FatNode. To find
62 # the original file's code, look for the end of this BEGIN block or the
65 my (%fatpacked,%fatpacked_extra);
67 my $end = stripspace <<'END_END';
68 s/^ //mg for values %fatpacked, values %fatpacked_extra;
71 if (my $fat = $_[0]->{$_[1]}) {
72 open my $fh, '<', \$fat;
75 #Uncomment this to find brokenness
76 #warn "Missing $_[1]";
80 unshift @INC, sub { load_from_hash(\%fatpacked, $_[1]) };
81 push @INC, sub { load_from_hash(\%fatpacked_extra, $_[1]) };
83 } # END OF FATPACK CODE
86 use Object::Remote::Node;
87 Object::Remote::Node->run(watchdog_timeout => $WATCHDOG_TIMEOUT);
90 my %files = map +($mods{$_} => scalar do { local (@ARGV, $/) = ($_); <> }),
93 sub generate_fatpack_hash {
94 my ($hash_name, $orig) = @_;
95 (my $stub = $orig) =~ s/\.pm$//;
96 my $name = uc join '_', split '/', $stub;
97 my $data = $files{$orig} or die $orig; $data =~ s/^/ /mg;
98 return '$'.$hash_name.'{'.perlstring($orig).qq!} = <<'${name}';\n!
99 .qq!${data}${name}\n!;
103 map(generate_fatpack_hash('fatpacked', $_), sort map $mods{$_}, @non_core),
104 map(generate_fatpack_hash('fatpacked_extra', $_), sort map $mods{$_}, @core),
107 our $DATA = join "\n", $start, $env_pass, @segments, $end;