$Inline::VERSION
= '0.44';
use AutoLoader
'AUTOLOAD';
use Cwd
qw(abs_path cwd);
my $version_requested = 0;
$Inline::languages
= undef; #needs to be global for AutoLoaded error messages
NOCLEAN
=> [CLEAN_AFTER_BUILD
=> 0],
CLEAN
=> [CLEAN_BUILD_AREA
=> 1],
FORCE
=> [FORCE_BUILD
=> 1],
INFO
=> [PRINT_INFO
=> 1],
VERSION
=> [PRINT_VERSION
=> 1],
REPORTBUG
=> [REPORTBUG
=> 1],
UNTAINT
=> [UNTAINT
=> 1],
UNSAFE
=> [SAFEMODE
=> 0],
GLOBAL
=> [GLOBAL_LOAD
=> 1],
NOISY
=> [BUILD_NOISY
=> 1],
TIMERS
=> [BUILD_TIMERS
=> 1],
NOWARN
=> [WARNINGS
=> 0],
_INSTALL_
=> [_INSTALL_
=> 1],
SITE_INSTALL
=> undef, # No longer supported.
#==============================================================================
# This is where everything starts.
#==============================================================================
local ($/, $") = ("\n", ' '); local ($\, $,);
my ($pkg, $script) = caller;
# Not sure what this is for. Let's see what breaks.
if ($class ne 'Inline') {
croak M01_usage_use($class) if $class =~ /^Inline::/;
$CONFIG{$pkg}{template} ||= $default_config;
&create_config_file(), return 1 if $_[0] eq '_CONFIG_';
goto &maker_utils if $_[0] =~ /^(install|makedist|makeppd)$/i;
if ($control eq 'with') {
return handle_with($pkg, @_);
elsif ($control eq 'Config') {
return handle_global_config($pkg, @_);
elsif (exists $shortcuts{uc($control)}) {
handle_shortcuts($pkg, $control, @_);
$version_requested = $CONFIG{$pkg}{template}{PRINT_VERSION};
elsif ($control =~ /^\S+$/ and $control !~ /\n/) {
my $language_id = $control;
my $option = shift || '';
croak M02_usage() if /[\s\n]/;
$o->{INLINE}{version} = $Inline::VERSION;
$o->{API}{script} = $script;
$o->{API}{language_id} = $language_id;
if ($option =~ /^(FILE|BELOW)$/ or
defined $INC{File::Spec::Unix->catfile('Inline','Files.pm')} and
Inline::Files::get_filename($pkg)
$o->{CONFIG} = handle_language_config(@config);
elsif ($option eq 'DATA' or not $option) {
$o->{CONFIG} = handle_language_config(@config);
elsif ($option eq 'Config') {
$CONFIG{$pkg}{$language_id} = handle_language_config(@config);
$o->receive_code($option);
$o->{CONFIG} = handle_language_config(@config);
#==============================================================================
# Run time version of import (public method)
#==============================================================================
local ($/, $") = ("\n", ' '); local ($\
, $,);
my ($pkg, $script) = caller;
croak M03_usage_bind
() unless $class eq 'Inline';
$CONFIG{$pkg}{template
} ||= $default_config;
my $language_id = shift or croak M03_usage_bind
();
unless ($language_id =~ /^\S+$/ and $language_id !~ /\n/);
$code = shift or croak M03_usage_bind
();
croak M03_usage_bind
() if /[\s\n]/;
$o->{INLINE
}{version
} = $Inline::VERSION
;
$o->{API
}{script
} = $script;
$o->{API
}{language_id
} = $language_id;
$o->{CONFIG
} = handle_language_config
(@config);
#==============================================================================
# Process delayed objects that don't have source code yet.
#==============================================================================
# This code is an ugly hack because of the fact that you can't use an
# INIT block at "run-time proper". So we kill the warning for 5.6+ users
# and tell them to use a Inline->init() call if they run into problems. (rare)
my $lexwarn = ($] >= 5.006) ?
'no warnings;' : '';
\$INIT = \$INIT; # Needed by Sarathy's patch.
local ($/, $") = ("\n", ' '); local ($\, $,);
while (my $o = shift(@DATA_OBJS)) {
warn M51_unused_DATA() if @DATA_OBJS;
print_version() if $version_requested && not $version_printed;
#==============================================================================
# Print a small report about the version of Inline
#==============================================================================
return if $version_printed++;
You are using Inline.pm version $Inline::VERSION
#==============================================================================
# Compile the source if needed and then dynaload the object
#==============================================================================
my ($pkg, $language_id) = @
{$o->{API
}}{qw(pkg language_id)};
my @config = (%{$CONFIG{$pkg}{template
}},
%{$CONFIG{$pkg}{$language_id} || {}},
@config = $o->check_config(@config);
$o->env_untaint if UNTAINT
;
if (not $o->{INLINE
}{object_ready
}) {
$o->check_config_file; # Final DIRECTORY set here.
push @config, $o->with_configs;
my $language = $o->{API
}{language
};
croak M04_error_nocode
($language_id) unless $o->{API
}{code
};
$o->env_untaint if UNTAINT
;
$o->obj_untaint if UNTAINT
;
print_version
() if $version_requested;
$o->reportbug() if $o->{CONFIG
}{REPORTBUG
};
if (not $o->{INLINE
}{object_ready
}
or $o->{CONFIG
}{PRINT_INFO
}
eval "require $o->{INLINE}{ILSM_module}";
croak M05_error_eval
('glue', $@
) if $@
;
bless $o, $o->{INLINE
}{ILSM_module
};
$o->{CONFIG
} = {(%{$o->{CONFIG
}}, @config)};
$o->print_info if $o->{CONFIG
}{PRINT_INFO
};
unless ($o->{INLINE
}{object_ready
} or
not length $o->{INLINE
}{ILSM_suffix
}) {
$o->write_inl_file() unless $o->{CONFIG
}{_INSTALL_
};
if ($o->{INLINE
}{ILSM_suffix
} ne 'so' and
$o->{INLINE
}{ILSM_suffix
} ne 'dll' and
$o->{INLINE
}{ILSM_suffix
} ne 'bundle' and
eval "require $o->{INLINE}{ILSM_module}";
croak M05_error_eval
('glue', $@
) if $@
;
bless $o, $o->{INLINE
}{ILSM_module
};
#==============================================================================
# Set up the USING overrides
#==============================================================================
my ($language_id) = $o->{API
}{language_id
};
my ($ilsm) = $o->{INLINE
}{ILSM_module
};
for (@
{$o->{CONFIG
}{USING
}}) {
?
"Inline::$language_id$_"
: "Inline::${language_id}::$_";
eval "require $using_module";
croak
"Invalid module '$using_module' in USING list:\n$@" if $@
;
eval "\$register = $using_module->register";
croak
"Invalid module '$using_module' in USING list:\n$@" if $@
;
for my $override (@
{$register->{overrides
}}) {
next if defined $o->{OVERRIDDEN
}{$ilsm . "::$override"};
$o->{OVERRIDDEN
}{$ilsm . "::$override"} =
\
&{$ilsm . "::$override"};
*{$ilsm . "::$override"} =
*{$using_module . "::$override"};
#==============================================================================
# Restore the modules original methods
#==============================================================================
for my $override (keys %{$o->{OVERRIDDEN
}}) {
*{$override} = $o->{OVERRIDDEN
}{$override};
#==============================================================================
# Get source from the DATA filehandle
#==============================================================================
my ($marker, $marker_tag);
my ($pkg, $language_id) = @
{$o->{API
}}{qw(pkg language_id)};
unless ($DATA_read{$pkg}++) {
*Inline
::DATA
= *{$pkg . '::DATA'};
my ($CR, $LF) = (&Socket
::CR
, &Socket
::LF
);
(my $data = <Inline
::DATA
>) =~ s/$CR?$LF/\n/g;
@
{$DATA{$pkg}} = split /(?m)(__\S+?__\n)/, $data;
shift @
{$DATA{$pkg}} unless ($ {$DATA{$pkg}}[0] || '') =~ /__\S+?__\n/;
($marker, $o->{API
}{code
}) = splice @
{$DATA{$pkg}}, 0, 2;
croak M08_no_DATA_source_code
($language_id)
($marker_tag = $marker) =~ s/__(\S+?)__\n/$1/;
croak M09_marker_mismatch
($marker, $language_id)
unless $marker_tag eq $language_id;
#==============================================================================
# Validate and store the non language-specific config options
#==============================================================================
my ($key, $value) = (shift, shift);
if (defined $default_config->{$key}) {
if ($key =~ /^(WITH|USING)$/) {
croak M10_usage_WITH_USING
()
if (ref $value and ref $value ne 'ARRAY');
$value = [$value] unless ref $value;
$o->{CONFIG
}{$key} = $value;
$o->{CONFIG
}{$key} = $value, next if not $value;
if ($key eq 'DIRECTORY') {
croak M11_usage_DIRECTORY
($value) unless (-d
$value);
$value = abs_path
($value);
croak M12_usage_NAME
($value)
unless $value =~ /^[a-zA-Z_](\w|::)*$/;
elsif ($key eq 'VERSION') {
croak M13_usage_VERSION
($value) unless $value =~ /^\d\.\d\d*$/;
$o->{CONFIG
}{$key} = $value;
push @others, $key, $value;
#==============================================================================
# Set option defaults based on current option settings.
#==============================================================================
$untaint = $o->{CONFIG
}{UNTAINT
} || 0;
$safemode = (($o->{CONFIG
}{SAFEMODE
} == -1) ?
not $o->{CONFIG
}{DIRECTORY
}) {
croak M49_usage_unsafe
(1) if ($< == 0 or $> == 0);
warn M49_usage_unsafe
(0) if $^W
;
if ($o->{CONFIG
}{AUTONAME
} == -1) {
$o->{CONFIG
}{AUTONAME
} = length($o->{CONFIG
}{NAME
}) ?
0 : 1;
($o->{CONFIG
}{CLEAN_AFTER_BUILD
} and not $o->{CONFIG
}{REPORTBUG
});
#==============================================================================
# Check if Inline extension is preinstalled
#==============================================================================
$o->{INLINE
}{object_ready
} = 0;
unless ($o->{API
}{code
} =~ /^[A-Fa-f0-9]{32}$/) {
$o->{INLINE
}{md5
} = Digest
::MD5
::md5_hex
($o->{API
}{code
});
$o->{INLINE
}{md5
} = $o->{API
}{code
};
return if $o->{CONFIG
}{_INSTALL_
};
return unless $o->{CONFIG
}{VERSION
};
croak M26_error_version_without_name
()
unless $o->{CONFIG
}{NAME
};
my @pkgparts = split(/::/, $o->{API
}{pkg
});
my $realname = File
::Spec
->catfile(@pkgparts) . '.pm';
my $realname_unix = File
::Spec
::Unix
->catfile(@pkgparts) . '.pm';
my $realpath = $INC{$realname_unix}
or croak M27_module_not_indexed
($realname_unix);
my ($volume,$dir,$file) = File
::Spec
->splitpath($realpath);
my @dirparts = File
::Spec
->splitdir($dir);
pop @dirparts unless $dirparts[-1];
my @endparts = splice(@dirparts, 0 - @pkgparts);
if $dirparts[-2] eq 'blib' && $dirparts[-1] eq 'lib';
File
::Spec
->catfile(@endparts) eq $realname
or croak M28_error_grokking_path
($realpath);
File
::Spec
->catpath($volume,File
::Spec
->catdir(@dirparts),"");
$o->{API
}{version
} = $o->{CONFIG
}{VERSION
};
$o->{API
}{module
} = $o->{CONFIG
}{NAME
};
my @modparts = split(/::/,$o->{API
}{module
});
$o->{API
}{modfname
} = $modparts[-1];
$o->{API
}{modpname
} = File
::Spec
->catdir(@modparts);
my $suffix = $Config{dlext
};
my $obj = File
::Spec
->catfile($realpath,'auto',$o->{API
}{modpname
},
"$o->{API}{modfname}.$suffix");
croak M30_error_no_obj
($o->{CONFIG
}{NAME
}, $o->{API
}{pkg
},
$realpath) unless -f
$obj;
@
{$o->{CONFIG
}}{qw( PRINT_INFO
$o->{install_lib
} = $realpath;
$o->{INLINE
}{ILSM_type
} = 'compiled';
$o->{INLINE
}{ILSM_module
} = 'Inline::C';
$o->{INLINE
}{ILSM_suffix
} = $suffix;
$o->{INLINE
}{object_ready
} = 1;
#==============================================================================
# Dynamically load the object module
#==============================================================================
if ($o->{CONFIG
}{_INSTALL_
}) {
my $inline = "$o->{API}{modfname}.inl";
or croak M24_open_for_output_failed
($inline);
print INLINE
"*** AUTOGENERATED by Inline.pm ***\n\n";
print INLINE
"This file satisfies the make dependency for ";
print INLINE
"$o->{API}{modfname}.pm\n";
my ($pkg, $module) = @
{$o->{API
}}{qw(pkg module)};
croak M42_usage_loader
() unless $o->{INLINE
}{ILSM_type
} eq 'compiled';
@Inline::ISA
= qw(DynaLoader);
my $global = $o->{CONFIG
}{GLOBAL_LOAD
} ?
'0x01' : '0x00';
my $version = $o->{API
}{version
} || '0.00';
push \@$ {pkg}::ISA, qw($module)
unless \$module eq "$pkg";
local \$$ {module}::VERSION = '$version';
push \@$ {module}::ISA, qw(Exporter DynaLoader);
sub dl_load_flags
{ $global }
croak M43_error_bootstrap
($module, $@
) if $@
;
#==============================================================================
# Process the config options that apply to all Inline sections
#==============================================================================
sub handle_global_config
{
my ($key, $value) = (shift, shift);
croak M02_usage
() if $key =~ /[\s\n]/;
$key = $value if $key =~ /^(ENABLE|DISABLE)$/;
croak M47_invalid_config_option
($key)
unless defined $default_config->{$key};
$CONFIG{$pkg}{template
}{$value} = 1;
elsif ($key eq 'DISABLE') {
$CONFIG{$pkg}{template
}{$value} = 0;
$CONFIG{$pkg}{template
}{$key} = $value;
#==============================================================================
# Process the config options that apply to a particular language
#==============================================================================
sub handle_language_config
{
my ($key, $value) = (shift, shift);
croak M02_usage
() if $key =~ /[\s\n]/;
elsif ($key eq 'DISABLE') {
push @values, $key, $value;
#==============================================================================
# Validate and store shortcut config options
#==============================================================================
my $OPTION = uc($option);
if ($OPTION eq 'SITE_INSTALL') {
croak M58_site_install
();
elsif ($shortcuts{$OPTION}) {
my ($method, $arg) = @
{$shortcuts{$OPTION}};
$CONFIG{$pkg}{template
}{$method} = $arg;
croak M48_usage_shortcuts
($option);
#==============================================================================
# Process the with command
#==============================================================================
croak M45_usage_with
() unless @_;
croak M02_usage
() unless /^[\w:]+$/;
croak M46_usage_with_bad
($_) . $@
if $@
;
push @
{$CONFIG{$pkg}{template
}{WITH
}}, $_;
#==============================================================================
#==============================================================================
$o->clean_build if $o->{CONFIG
}{CLEAN_BUILD_AREA
};
# Comment out the next 2 lines to stop autoloading of subroutines (testing)
#==============================================================================
#==============================================================================
croak M02_usage
() unless (defined $code and $code);
if (ref $code eq 'CODE') {
$o->{API
}{code
} = &$code;
elsif (ref $code eq 'ARRAY') {
$o->{API
}{code
} = join '', @
$code;
elsif ($code =~ m
|[/\\:]| and
$code =~ m
|^[/\\:\w
.\
-\ \
$\
[\
]<>]+$|) {
open CODE
, "< $code" or croak M06_code_file_failed_open
($code);
$o->{API
}{code
} = <CODE
>;
croak M07_code_file_does_not_exist
($code);
#==============================================================================
# Get the source code from an Inline::Files filehandle
#==============================================================================
my ($lang, $pkg) = @
{$o->{API
}}{qw(language_id pkg)};
my $langfile = uc($lang);
croak M59_bad_inline_file
($lang) unless $langfile =~ /^[A-Z]\w*$/;
croak M60_no_inline_files
()
unless (defined $INC{File
::Spec
::Unix
->catfile("Inline","Files.pm")} and
$Inline::Files
::VERSION
=~ /^\d\.\d\d$/ and
$Inline::Files
::VERSION
ge '0.51');
croak M61_not_parsed
() unless $lang = Inline
::Files
::get_filename
($pkg);
$Inline::FILE
= \
*{"${pkg}::$langfile"};
$o->{API
}{code
} = <$Inline::FILE
>;
#==============================================================================
# Read the cached config file from the Inline directory. This will indicate
# whether the Language code is valid or not.
#==============================================================================
my ($DIRECTORY, %config);
croak M14_usage_Config
() if defined %main::Inline
::Config
::;
croak M63_no_source
($o->{API
}{pkg
})
if $o->{INLINE
}{md5
} eq $o->{API
}{code
};
# First make sure we have the DIRECTORY
if ($o->{CONFIG
}{_INSTALL_
}) {
croak M15_usage_install_directory
()
if $o->{CONFIG
}{DIRECTORY
};
$o->{INLINE
}{DIRECTORY
} = File
::Spec
->catdir($cwd,"_Inline");
or croak M16_DIRECTORY_mkdir_failed
($DIRECTORY);
$DIRECTORY = $o->{INLINE
}{DIRECTORY
} =
$o->{CONFIG
}{DIRECTORY
} || $o->find_temp_dir;
$o->create_config_file($DIRECTORY)
if not -e File
::Spec
->catfile($DIRECTORY,"config");
open CONFIG
, "< ".File
::Spec
->catfile($DIRECTORY,"config")
or croak M17_config_open_failed
($DIRECTORY);
my $config = join '', <CONFIG
>;
croak M62_invalid_config_file
(File
::Spec
->catfile($DIRECTORY,"config"))
unless $config =~ /^version :/;
($config) = $config =~ /(.*)/s if UNTAINT
;
%config = Inline
::denter
->new()->undent($config);
$Inline::languages
= $config{languages
};
croak M18_error_old_version
($config{version
}, $DIRECTORY)
unless (defined $config{version
} and
$config{version
} =~ /TRIAL/ or
$config{version
} >= 0.40);
croak M19_usage_language
($o->{API
}{language_id
}, $DIRECTORY)
unless defined $config{languages
}->{$o->{API
}{language_id
}};
$o->{API
}{language
} = $config{languages
}->{$o->{API
}{language_id
}};
if ($o->{API
}{language
} ne $o->{API
}{language_id
}) {
if (defined $o->{$o->{API
}{language_id
}}) {
$o->{$o->{API
}{language
}} = $o->{$o->{API
}{language_id
}};
delete $o->{$o->{API
}{language_id
}};
$o->{INLINE
}{ILSM_type
} = $config{types
}->{$o->{API
}{language
}};
$o->{INLINE
}{ILSM_module
} = $config{modules
}->{$o->{API
}{language
}};
$o->{INLINE
}{ILSM_suffix
} = $config{suffixes
}->{$o->{API
}{language
}};
#==============================================================================
# Auto-detect installed Inline language support modules
#==============================================================================
# This subroutine actually fires off another instance of perl.
# with arguments that make this routine get called again.
# That way the queried modules don't stay loaded.
($dir) = $dir =~ /(.*)/s if UNTAINT
;
my $perl = $Config{perlpath
};
$perl = $^X
unless -f
$perl;
($perl) = $perl =~ /(.*)/s if UNTAINT
;
local $ENV{PERL5LIB
} if defined $ENV{PERL5LIB
};
local $ENV{PERL5OPT
} if defined $ENV{PERL5OPT
};
my $inline = $INC{'Inline.pm'};
$inline ||= File
::Spec
->curdir();
my($v,$d,$f) = File
::Spec
->splitpath($inline);
$f = "" if $f eq 'Inline.pm';
$inline = File
::Spec
->catpath($v,$d,$f);
my $INC = "-I$inline -I" .
join(" -I", grep {(-d File
::Spec
->catdir($_,"Inline") or
-d File
::Spec
->catdir($_,"auto","Inline")
system "$perl $INC -MInline=_CONFIG_ -e1 $dir"
and croak M20_config_creation_failed
($dir);
my ($lib, $mod, $register, %checked,
%languages, %types, %modules, %suffixes);
next unless -d File
::Spec
->catdir($lib,"Inline");
opendir LIB
, File
::Spec
->catdir($lib,"Inline")
or warn(M21_opendir_failed
(File
::Spec
->catdir($lib,"Inline"))), next;
while ($mod = readdir(LIB
)) {
next unless $mod =~ /\.pm$/;
next LIB
if ($checked{$mod}++);
if ($mod eq 'Config') { # Skip Inline::Config
next if $mod =~ /^(MakeMaker|denter|messages)$/;
eval "require Inline::$mod;";
eval "\$register=&Inline::${mod}::register";
my $language = ($register->{language
})
or warn(M22_usage_register
($mod)), next;
for (@
{$register->{aliases
}}) {
warn(M23_usage_alias_used
($mod, $_, $languages{$_})), next
if defined $languages{$_};
$languages{$_} = $language;
$languages{$language} = $language;
$types{$language} = $register->{type
};
$modules{$language} = "Inline::$mod";
$suffixes{$language} = $register->{suffix
};
my $file = File
::Spec
->catfile($ARGV[0],"config");
open CONFIG
, "> $file" or croak M24_open_for_output_failed
($file);
print CONFIG Inline
::denter
->new()
->indent(*version
=> $Inline::VERSION
,
*languages
=> \
%languages,
#==============================================================================
# Check to see if code has already been compiled
#==============================================================================
return $o->install if $o->{CONFIG
}{_INSTALL_
};
if ($o->{CONFIG
}{NAME
}) {
$module = $o->{CONFIG
}{NAME
};
elsif ($o->{API
}{pkg
} eq 'main') {
$module = $o->{API
}{script
};
my($v,$d,$file) = File
::Spec
->splitpath($module);
$module = 'FOO' if $module =~ /^_*$/;
$module = "_$module" if $module =~ /^\d/;
$module = $o->{API
}{pkg
};
$o->{API
}{suffix
} = $o->{INLINE
}{ILSM_suffix
};
$o->{API
}{directory
} = $o->{INLINE
}{DIRECTORY
};
while ($auto_level <= 5) {
if ($o->{CONFIG
}{AUTONAME
}) {
$module . '_' . substr($o->{INLINE
}{md5
}, 0, 2**$auto_level);
$auto_level = 6; # Don't loop on non-autoname objects
$o->{API
}{module
} = $module2;
my @modparts = split /::/, $module2;
$o->{API
}{modfname
} = $modparts[-1];
$o->{API
}{modpname
} = File
::Spec
->catdir(@modparts);
File
::Spec
->catdir($o->{INLINE
}{DIRECTORY
},
'build',$o->{API
}{modpname
});
File
::Spec
->catdir($o->{INLINE
}{DIRECTORY
}, 'lib');
my $inl = File
::Spec
->catfile($o->{API
}{install_lib
},"auto",
$o->{API
}{modpname
},"$o->{API}{modfname}.inl");
File
::Spec
->catfile($o->{API
}{install_lib
},"auto",$o->{API
}{modpname
},
"$o->{API}{modfname}.$o->{INLINE}{ILSM_suffix}");
open INL
, $inl or croak M31_inline_open_failed
($inl);
%inl = Inline
::denter
->new()->undent(<INL
>);
next unless ($o->{INLINE
}{md5
} eq $inl{md5
});
next unless ($inl{inline_version
} ge '0.40');
unless (-f
$o->{API
}{location
}) {
Missing object file: $o->{API}{location}
$o->{INLINE
}{object_ready
} = 1 unless $o->{CONFIG
}{FORCE_BUILD
};
unshift @
::INC
, $o->{API
}{install_lib
};
#==============================================================================
# Set things up so that the extension gets installed into the blib/arch.
# Then 'make install' will do the right thing.
#==============================================================================
my ($module, $DIRECTORY);
croak M64_install_not_c
($o->{API
}{language_id
})
unless uc($o->{API
}{language_id
}) =~ /^(C|CPP)$/ ;
croak M36_usage_install_main
()
if ($o->{API
}{pkg
} eq 'main');
croak M37_usage_install_auto
()
if $o->{CONFIG
}{AUTONAME
};
croak M38_usage_install_name
()
unless $o->{CONFIG
}{NAME
};
croak M39_usage_install_version
()
unless $o->{CONFIG
}{VERSION
};
croak M40_usage_install_badname
($o->{CONFIG
}{NAME
}, $o->{API
}{pkg
})
unless $o->{CONFIG
}{NAME
} eq $o->{API
}{pkg
};
# $o->{CONFIG}{NAME} =~ /^$o->{API}{pkg}::\w(\w|::)+$/
my ($mod_name, $mod_ver, $ext_name, $ext_ver) =
($o->{API
}{pkg
}, $ARGV[0], @
{$o->{CONFIG
}}{qw(NAME VERSION)});
croak M41_usage_install_version_mismatch
($mod_name, $mod_ver,
unless ($mod_ver eq $ext_ver);
$o->{INLINE
}{INST_ARCHLIB
} = $ARGV[1];
$o->{API
}{version
} = $o->{CONFIG
}{VERSION
};
$o->{API
}{module
} = $o->{CONFIG
}{NAME
};
my @modparts = split(/::/,$o->{API
}{module
});
$o->{API
}{modfname
} = $modparts[-1];
$o->{API
}{modpname
} = File
::Spec
->catdir(@modparts);
$o->{API
}{suffix
} = $o->{INLINE
}{ILSM_suffix
};
$o->{API
}{build_dir
} = File
::Spec
->catdir($o->{INLINE
}{DIRECTORY
},'build',
$o->{API
}{directory
} = $o->{INLINE
}{DIRECTORY
};
File
::Spec
->catdir($cwd,$o->{INLINE
}{INST_ARCHLIB
});
File
::Spec
->catfile($o->{API
}{install_lib
},"auto",$o->{API
}{modpname
},
"$o->{API}{modfname}.$o->{INLINE}{ILSM_suffix}");
unshift @
::INC
, $o->{API
}{install_lib
};
$o->{INLINE
}{object_ready
} = 0;
#==============================================================================
# Create the .inl file for an object
#==============================================================================
File
::Spec
->catfile($o->{API
}{install_lib
},"auto",$o->{API
}{modpname
},
"$o->{API}{modfname}.inl");
or croak
"Can't create Inline validation file $inl";
my $apiversion = $Config{apiversion
} || $Config{xs_apiversion
};
print INL Inline
::denter
->new()
->indent(*md5
, $o->{INLINE
}{md5
},
*name
, $o->{API
}{module
},
*version
, $o->{CONFIG
}{VERSION
},
*language
, $o->{API
}{language
},
*language_id
, $o->{API
}{language_id
},
*installed
, $o->{CONFIG
}{_INSTALL_
},
*date_compiled
, scalar localtime,
*inline_version
, $Inline::VERSION
,
*ILSM
, { map {($_, $o->{INLINE
}{"ILSM_$_"})}
(qw( module suffix type ))
*Config
, { (map {($_,$Config{$_})}
(qw( archname osname osvers
(apiversion
=> $apiversion),
#==============================================================================
#==============================================================================
for my $mod (@
{$o->{CONFIG
}{WITH
}}) {
&{$mod . "::Inline"}($o->{API
}{language
});
croak M25_no_WITH_support
($mod, $@
) if $@
;
#==============================================================================
# Blindly untaint tainted fields in Inline object.
#==============================================================================
($ENV{$_}) = $ENV{$_} =~ /(.*)/;
my $delim = $^O
eq 'MSWin32' ?
';' : ':';
$ENV{PATH
} = join $delim, grep {not /^\./ and
not ((stat($_))[2] & 0022)
} split $delim, $ENV{PATH
};
map {($_) = /(.*)/} @INC;
#==============================================================================
# Blindly untaint tainted fields in Inline object.
#==============================================================================
($o->{INLINE
}{ILSM_module
}) = $o->{INLINE
}{ILSM_module
} =~ /(.*)/;
($o->{API
}{build_dir
}) = $o->{API
}{build_dir
} =~ /(.*)/;
($o->{CONFIG
}{DIRECTORY
}) = $o->{CONFIG
}{DIRECTORY
} =~ /(.*)/;
($o->{API
}{install_lib
}) = $o->{API
}{install_lib
} =~ /(.*)/;
($o->{API
}{modpname
}) = $o->{API
}{modpname
} =~ /(.*)/;
($o->{API
}{modfname
}) = $o->{API
}{modfname
} =~ /(.*)/;
($o->{API
}{language
}) = $o->{API
}{language
} =~ /(.*)/;
($o->{API
}{pkg
}) = $o->{API
}{pkg
} =~ /(.*)/;
($o->{API
}{module
}) = $o->{API
}{module
} =~ /(.*)/;
#==============================================================================
# Clean the build directory from previous builds
#==============================================================================
$prefix = $o->{INLINE
}{DIRECTORY
};
or croak
"Can't open build directory: $prefix for cleanup $!\n";
while ($dir = readdir(BUILD
)) {
my $maybedir = File
::Spec
->catdir($prefix,$dir);
if (($maybedir and -d
$maybedir) and ($dir =~ /\w{36,}/)) {
$o->rmpath($prefix,$dir);
#==============================================================================
# Apply a list of filters to the source code
#==============================================================================
my $new_code = $o->{API
}{code
};
croak M52_invalid_filter
($_) unless ref;
$new_code = $_->($new_code);
$new_code = $_->filter($o, $new_code);
#==============================================================================
# User wants to report a bug
#==============================================================================
return if $o->{INLINE
}{reportbug_handled
}++;
<-----------------------REPORTBUG Section------------------------------------->
REPORTBUG mode in effect.
Your Inline $o->{API}{language_id} code will be processed in the build directory:
A perl-readable bug report including your perl configuration and run-time
diagnostics will also be generated in the build directory.
When the program finishes please bundle up the above build directory with:
tar czf Inline.REPORTBUG.tar.gz $o->{API}{build_dir}
and send "Inline.REPORTBUG.tar.gz" as an email attachment to the author
of the offending Inline::* module with the subject line:
Include in the email, a description of the problem and anything else that
you think might be helpful. Patches are welcome! :-\)
<-----------------------End of REPORTBUG Section------------------------------>
%versions = map {eval "use $_();"; ($_, $ {$_ . '::VERSION'})}
qw
(Digest
::MD5 Parse
::RecDescent
ExtUtils
::MakeMaker File
::Path FindBin
$o->mkpath($o->{API
}{build_dir
});
open REPORTBUG
, "> ".File
::Spec
->catfile($o->{API
}{build_dir
},"REPORTBUG")
or croak M24_open_for_output_failed
(File
::Spec
->catfile($o->{API
}{build_dir
},"REPORTBUG"));
%Inline::REPORTBUG_Inline_Object
= ();
%Inline::REPORTBUG_Perl_Config
= ();
%Inline::REPORTBUG_Module_Versions
= ();
print REPORTBUG Inline
::denter
->new()
->indent(*REPORTBUG_Inline_Object
, $o,
*REPORTBUG_Perl_Config
, \
%Config::Config
,
*REPORTBUG_Module_Versions
, \
%versions,
#==============================================================================
# Print a small report if PRINT_INFO option is set.
#==============================================================================
<-----------------------Information Section----------------------------------->
Information about the processing of your Inline $o->{API}{language_id} code:
print STDERR
<<END if ($o->{INLINE}{object_ready});
Your module is already compiled. It is located at:
print STDERR
<<END if ($o->{INLINE}{object_ready} and $o->{CONFIG}{FORCE_BUILD});
But the FORCE_BUILD option is set, so your code will be recompiled.
I\'ll use this build directory:
and I\'ll install the executable as:
print STDERR
<<END if (not $o->{INLINE}{object_ready});
Your source code needs to be compiled. I\'ll use this build directory:
and I\'ll install the executable as:
<-----------------------End of Information Section---------------------------->
#==============================================================================
# Hand off this invokation to Inline::MakeMaker
#==============================================================================
require Inline
::MakeMaker
;
goto &Inline
::MakeMaker
::utils
;
#==============================================================================
#==============================================================================
#==============================================================================
#==============================================================================
my($volume,$dirs,$nofile) = File
::Spec
->splitpath($mkpath,1);
my @parts = File
::Spec
->splitdir($dirs);
my $path = File
::Spec
->catpath($volume,File
::Spec
->catdir(@done),"");
-d
$path || _mkdir
($path, 0777);
croak M53_mkdir_failed
($mkpath)
#==============================================================================
#==============================================================================
my ($o, $prefix, $rmpath) = @_;
# Nuke the target directory
_rmtree
(File
::Spec
->catdir($prefix ?
($prefix,$rmpath) : ($rmpath)));
# Remove any empty directories underneath the requested one
my @parts = File
::Spec
->splitdir($rmpath);
$rmpath = File
::Spec
->catdir($prefix ?
($prefix,@parts) : @parts);
or last; # rmdir failed because dir was not empty
$roots = [$roots] unless ref $roots;
foreach $root (@
{$roots}) {
if (opendir MYDIR
, $root) {
croak M21_opendir_failed
($root);
my $dot = File
::Spec
->curdir();
my $dotdot = File
::Spec
->updir();
foreach my $name (@names) {
next if $name eq $dot or $name eq $dotdot;
my $maybefile = File
::Spec
->catfile($root,$name);
push(@paths,$maybefile),next if $maybefile and -f
$maybefile;
push(@paths,File
::Spec
->catdir($root,$name));
($root) = $root =~ /(.*)/ if UNTAINT
;
rmdir($root) or croak M54_rmdir_failed
($root);
($root) = $root =~ /(.*)/ if UNTAINT
;
unlink($root) or croak M55_unlink_failed
($root);
#==============================================================================
# Find the 'Inline' directory to use.
#==============================================================================
return $TEMP_DIR if $TEMP_DIR;
my ($temp_dir, $home, $bin, $cwd, $env);
$env = $ENV{PERL_INLINE_DIRECTORY
} || '';
$home = $ENV{HOME
} ? abs_path
($ENV{HOME
}) : '';
elsif ($cwd = abs_path
('.') and
-d File
::Spec
->catdir($cwd,".Inline") and
-w File
::Spec
->catdir($cwd,".Inline")) {
$temp_dir = File
::Spec
->catdir($cwd,".Inline");
elsif (require FindBin
and
-d File
::Spec
->catdir($bin,".Inline") and
-w File
::Spec
->catdir($bin,".Inline")) {
$temp_dir = File
::Spec
->catdir($bin,".Inline");
-d File
::Spec
->catdir($home,".Inline") and
-w File
::Spec
->catdir($home,".Inline")) {
$temp_dir = File
::Spec
->catdir($home,".Inline");
elsif (defined $cwd and $cwd and
-d File
::Spec
->catdir($cwd,"_Inline") and
-w File
::Spec
->catdir($cwd,"_Inline")) {
$temp_dir = File
::Spec
->catdir($cwd,"_Inline");
elsif (defined $bin and $bin and
-d File
::Spec
->catdir($bin,"_Inline") and
-w File
::Spec
->catdir($bin,"_Inline")) {
$temp_dir = File
::Spec
->catdir($bin,"_Inline");
elsif (defined $cwd and $cwd and
_mkdir
(File
::Spec
->catdir($cwd,"_Inline"), 0777)) {
$temp_dir = File
::Spec
->catdir($cwd,"_Inline");
elsif (defined $bin and $bin and
_mkdir
(File
::Spec
->catdir($bin,"_Inline"), 0777)) {
$temp_dir = File
::Spec
->catdir($bin,"_Inline");
croak M56_no_DIRECTORY_found
()
return $TEMP_DIR = abs_path
($temp_dir);
my $mode = shift || 0777;
($dir) = ($dir =~ /(.*)/) if UNTAINT
;
return mkdir($dir, $mode);
# Comment out the next 2 lines to stop autoloading of messages (for testing)
#==============================================================================
# Error messages are autoloaded
#==============================================================================
It is invalid to use '$module' directly. Please consult the Inline
documentation for more information.
Invalid usage of Inline module. Valid usages are:
use Inline language => "source-string", config-pair-list;
use Inline language => "source-file", config-pair-list;
use Inline language => [source-line-list], config-pair-list;
use Inline language => 'DATA', config-pair-list;
use Inline language => 'Config', config-pair-list;
use Inline Config => config-pair-list;
use Inline with => module-list;
use Inline shortcut-list;
# This is broken ????????????????????????????????????????????????????
$usage .= <<END if defined $Inline::languages;
${\ join(', ', sort keys %$Inline::languages)}
Invalid usage of the Inline->bind() function. Valid usages are:
Inline->bind(language => "source-string", config-pair-list);
Inline->bind(language => "source-file", config-pair-list);
Inline->bind(language => [source-line-list], config-pair-list);
$usage .= <<END if defined $Inline::languages;
${\ join(', ', sort keys %$Inline::languages)}
No $language source code found for Inline.
my ($subroutine, $msg) = @_;
An eval() failed in Inline::$subroutine:
sub M06_code_file_failed_open
{
Couldn't open Inline code file '$file':
sub M07_code_file_does_not_exist
{
Inline assumes '$file' is a filename,
and that file does not exist.
sub M08_no_DATA_source_code
{
No source code in DATA section for Inline '$lang' section.
sub M09_marker_mismatch
{
my ($marker, $lang) = @_;
Marker '$marker' does not match Inline '$lang' section.
sub M10_usage_WITH_USING
{
Config option WITH or USING must be a module name or an array ref
sub M11_usage_DIRECTORY
{
Invalid value '$value' for config option DIRECTORY
Invalid value for NAME config option: '$name'
Invalid value for VERSION config option: '$version'
Must be of the form '#.##'.
(Should also be specified as a string rather than a floating point number)
As of Inline v0.30, use of the Inline::Config module is no longer supported
or allowed. If Inline::Config exists on your system, it can be removed. See
the Inline documentation for information on how to configure Inline.
(You should find it much more straightforward than Inline::Config :-)
sub M15_usage_install_directory
{
Can't use the DIRECTORY option when installing an Inline extension module.
sub M16_DIRECTORY_mkdir_failed
{
Can't mkdir $dir to build Inline code.
sub M17_config_open_failed
{
my $file = File
::Spec
->catfile(${dir
},"config");
Can't open ${file} for input.
sub M18_error_old_version
{
my ($old_version, $directory) = @_;
You are using Inline version $Inline::VERSION with a directory that was
configured by Inline version $old_version. This version is no longer supported.
Please delete the following directory and try again:
my ($language, $directory) = @_;
Error. You have specified '$language' as an Inline programming language.
I currently only know about the following languages:
${ defined $Inline::languages ?
\ join(', ', sort keys %$Inline::languages) : \ ''
If you have installed a support module for this language, try deleting the
config file from the following Inline DIRECTORY, and run again:
sub M20_config_creation_failed
{
my $file = File
::Spec
->catfile(${dir
},"config");
Failed to autogenerate ${file}.
Can't open directory '$dir'.
my ($language, $error) = @_;
The module Inline::$language does not support the Inline API, because it does
properly support the register() method. This module will not work with Inline
and should be uninstalled from your system. Please advise your sysadmin.
The following error was generating from this module:
sub M23_usage_alias_used
{
my ($new_mod, $alias, $old_mod) = @_;
The module Inline::$new_mod is attempting to define $alias as an alias.
But $alias is also an alias for Inline::$old_mod.
One of these modules needs to be corrected or removed.
Please notify the system administrator.
sub M24_open_for_output_failed
{
Can't open $file for output.
sub M25_no_WITH_support
{
You have requested "use Inline with => '$mod'"
but '$mod' does not work with Inline.
sub M26_error_version_without_name
{
Specifying VERSION option without NAME option is not permitted.
sub M27_module_not_indexed
{
You are attempting to load an extension for '$mod',
but there is no entry for that module in %INC.
sub M28_error_grokking_path
{
Can't calculate a path from '$path' in %INC
sub M29_error_relative_path
{
Can't load installed extension '$name'
from relative path '$path'.
my ($name, $pkg, $path) = @_;
The extension '$name' is not properly installed in path:
If this is a CPAN/distributed module, you may need to reinstall it on your
To allow Inline to compile the module in a temporary cache, simply remove the
Inline config option 'VERSION=' from the $pkg module.
sub M31_inline_open_failed
{
Can't open Inline validate file:
sub M32_error_md5_validation
{
The source code fingerprint:
does not match the one in:
This module needs to be reinstalled.
sub M33_error_old_inline_version
{
The following extension is not compatible with this version of Inline.pm.
You need to reinstall this extension.
sub M34_error_incorrect_version
{
The version of your extension does not match the one indicated by your
Inline source code, according to:
This module should be reinstalled.
sub M35_error_no_object_file
{
For Inline validation file:
This module should be reinstalled.
sub M36_usage_install_main
{
Can't install an Inline extension module from package 'main'.
sub M37_usage_install_auto
{
Can't install an Inline extension module with AUTONAME enabled.
sub M38_usage_install_name
{
An Inline extension module requires an explicit NAME.
sub M39_usage_install_version
{
An Inline extension module requires an explicit VERSION.
sub M40_usage_install_badname
{
The NAME '$name' is illegal for this Inline extension.
The NAME must match the current package name:
sub M41_usage_install_version_mismatch
{
my ($mod_name, $mod_ver, $ext_name, $ext_ver) = @_;
The version '$mod_ver' for module '$mod_name' doe not match
the version '$ext_ver' for Inline section '$ext_name'.
ERROR. The loader that was invoked is for compiled languages only.
sub M43_error_bootstrap
{
Had problems bootstrapping Inline module '$mod'
Syntax error detected using 'use Inline with ...'.
use Inline with => 'module1', 'module2', ..., 'moduleN';
Syntax error detected using 'use Inline with => "$mod";'.
'$mod' could not be found.
sub M47_invalid_config_option
{
Invalid Config option '$option'
sub M48_usage_shortcuts
{
Invalid shortcut '$shortcut' specified.
VERSION, INFO, FORCE, NOCLEAN, CLEAN, UNTAINT, SAFE, UNSAFE,
GLOBAL, NOISY and REPORTBUG
You are using the Inline.pm module with the UNTAINT and SAFEMODE options,
but without specifying the DIRECTORY option. This is potentially unsafe.
Either use the DIRECTORY option or turn off SAFEMODE.
($terminate ?
<<END : "");
Since you are running as the a privledged user, Inline.pm is terminating.
One or more DATA sections were not processed by Inline.
Invalid filter '$filter' is not a reference.
Couldn't make directory path '$dir'.
Can't remove directory '$dir':
Can't unlink file '$file':
sub M56_no_DIRECTORY_found
{
Couldn't find an appropriate DIRECTORY for Inline to use.
sub M57_wrong_architecture
{
my ($ext, $arch, $thisarch) = @_;
is built for perl on the '$arch' platform.
This is the '$thisarch' platform.
You have specified the SITE_INSTALL command. Support for this option has
been removed from Inline since version 0.40. It has been replaced by the
use of Inline::MakeMaker in your Makefile.PL. Please see the Inline
documentation for more help on creating and installing Inline based modules.
sub M59_bad_inline_file
{
Could not find any Inline source code for the '$lang' language using
the Inline::Files module.
sub M60_no_inline_files
{
It appears that you have requested to use Inline with Inline::Files.
You need to explicitly 'use Inline::Files;' before your 'use Inline'.
It does not appear that your program has been properly parsed by Inline::Files.
sub M62_invalid_config_file
{
You are using a config file that was created by an older version of Inline:
This file and all the other components in its directory are no longer valid
for this version of Inline. The best thing to do is simply delete all the
contents of the directory and let Inline rebuild everything for you. Inline
will do this automatically when you run your programs.
This module $pkg can not be loaded and has no source code.
You may need to reinstall this module.
Invalid attempt to install an Inline module using the '$lang' language.
Only C and CPP (C++) based modules are currently supported.