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 #TODO oi this isn't right yet
44 my @non_core_non_arch = grep +(
46 /^\Q$Config{privlibexp}/ or /^\Q$Config{archlibexp}/
47 #or /^\Q$Config{vendorarchexp}/ or /^\Q$Config{sitearchexp}/
51 my @core_non_arch = grep +(
52 /^\Q$Config{privlibexp}/
53 and not(/^\Q$Config{archlibexp}/ or /\Q$Config{archname}/ or /\Q$Config{myarchname}/)
57 if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) {
58 my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
59 return unless $level =~ /^\w+$/;
60 $env_pass = '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
63 my $start = stripspace <<'END_START';
64 # This chunk of stuff was generated by Object::Remote::FatNode. To find
65 # the original file's code, look for the end of this BEGIN block or the
68 my (%fatpacked,%fatpacked_extra);
70 my $end = stripspace <<'END_END';
71 s/^ //mg for values %fatpacked, values %fatpacked_extra;
74 if (my $fat = $_[0]->{$_[1]}) {
75 open my $fh, '<', \$fat;
78 #Uncomment this to find brokenness
79 #warn "Missing $_[1]";
83 unshift @INC, sub { load_from_hash(\%fatpacked, $_[1]) };
84 push @INC, sub { load_from_hash(\%fatpacked_extra, $_[1]) };
86 } # END OF FATPACK CODE
89 use Object::Remote::Node;
90 Object::Remote::Node->run;
93 my %files = map +($mods{$_} => scalar do { local (@ARGV, $/) = ($_); <> }),
94 @non_core_non_arch, @core_non_arch;
96 sub generate_fatpack_hash {
97 my ($hash_name, $orig) = @_;
98 (my $stub = $orig) =~ s/\.pm$//;
99 my $name = uc join '_', split '/', $stub;
100 my $data = $files{$orig} or die $orig; $data =~ s/^/ /mg;
101 return '$'.$hash_name.'{'.perlstring($orig).qq!} = <<'${name}';\n!
102 .qq!${data}${name}\n!;
106 map(generate_fatpack_hash('fatpacked', $_), sort map $mods{$_}, @non_core_non_arch),
107 map(generate_fatpack_hash('fatpacked_extra', $_), sort map $mods{$_}, @core_non_arch),
110 our $DATA = join "\n", $start, $env_pass, @segments, $end;