1 package Object::Remote::FatNode;
3 #TODO If a file does not end in a new line by itself
12 $text =~ /^(\s+)/ && $text =~ s/^$1//mg;
16 my %maybe_libs = map +($_ => 1), grep defined, (values %Config, '.');
18 my @extra_libs = grep not(ref($_) or $maybe_libs{$_}), @INC;
20 my $extra_libs = join '', map " -I$_\n", @extra_libs;
26 -mObject::Remote::Connector::STDIO
32 -mObject::Remote::ModuleLoader
33 -mObject::Remote::Node
34 -mMethod::Generate::BuildAll
35 -mMethod::Generate::DemolishAll
37 -e 'print join "\\n", \%INC'
42 chomp(my @inc = qx($command));
44 my %mods = reverse @inc;
46 #TODO oi this isn't right yet
47 my @non_core_non_arch = grep +(
49 /^\Q$Config{privlibexp}/ or /^\Q$Config{archlibexp}/
50 #or /^\Q$Config{vendorarchexp}/ or /^\Q$Config{sitearchexp}/
54 my @core_non_arch = grep +(
55 /^\Q$Config{privlibexp}/
56 and not(/^\Q$Config{archlibexp}/ or /\Q$Config{archname}/ or /\Q$Config{myarchname}/)
60 if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) {
61 my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
62 return unless $level =~ /^\w+$/;
63 $env_pass = '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
66 my $start = stripspace <<'END_START';
67 # This chunk of stuff was generated by Object::Remote::FatNode. To find
68 # the original file's code, look for the end of this BEGIN block or the
71 my (%fatpacked,%fatpacked_extra);
73 my $end = stripspace <<'END_END';
74 s/^ //mg for values %fatpacked, values %fatpacked_extra;
77 if (my $fat = $_[0]->{$_[1]}) {
78 open my $fh, '<', \$fat;
81 #Uncomment this to find brokenness
82 #warn "Missing $_[1]";
86 unshift @INC, sub { load_from_hash(\%fatpacked, $_[1]) };
87 push @INC, sub { load_from_hash(\%fatpacked_extra, $_[1]) };
89 } # END OF FATPACK CODE
92 use Object::Remote::Node;
93 Object::Remote::Node->run(watchdog_timeout => $WATCHDOG_TIMEOUT);
96 my %files = map +($mods{$_} => scalar do { local (@ARGV, $/) = ($_); <> }),
97 @non_core_non_arch, @core_non_arch;
99 sub generate_fatpack_hash {
100 my ($hash_name, $orig) = @_;
101 (my $stub = $orig) =~ s/\.pm$//;
102 my $name = uc join '_', split '/', $stub;
103 my $data = $files{$orig} or die $orig; $data =~ s/^/ /mg;
104 return '$'.$hash_name.'{'.perlstring($orig).qq!} = <<'${name}';\n!
105 .qq!${data}${name}\n!;
109 map(generate_fatpack_hash('fatpacked', $_), sort map $mods{$_}, @non_core_non_arch),
110 map(generate_fatpack_hash('fatpacked_extra', $_), sort map $mods{$_}, @core_non_arch),
113 our $DATA = join "\n", $start, $env_pass, @segments, $end;