⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windows.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 2 页
字号:
package ExtUtils::CBuilder::Platform::Windows;use strict;use warnings;use File::Basename;use File::Spec;use ExtUtils::CBuilder::Base;use vars qw($VERSION @ISA);$VERSION = '0.21';@ISA = qw(ExtUtils::CBuilder::Base);sub new {  my $class = shift;  my $self = $class->SUPER::new(@_);  my $cf = $self->{config};  # Inherit from an appropriate compiler driver class  unshift @ISA, "ExtUtils::CBuilder::Platform::Windows::" . $self->_compiler_type;  return $self;}sub _compiler_type {  my $self = shift;  my $cc = $self->{config}{cc};  return (  $cc =~ /cl(\.exe)?$/ ? 'MSVC'	  : $cc =~ /bcc32(\.exe)?$/ ? 'BCC'	  : 'GCC');}sub split_like_shell {  # As it turns out, Windows command-parsing is very different from  # Unix command-parsing.  Double-quotes mean different things,  # backslashes don't necessarily mean escapes, and so on.  So we  # can't use Text::ParseWords::shellwords() to break a command string  # into words.  The algorithm below was bashed out by Randy and Ken  # (mostly Randy), and there are a lot of regression tests, so we  # should feel free to adjust if desired.    (my $self, local $_) = @_;    return @$_ if defined() && UNIVERSAL::isa($_, 'ARRAY');    my @argv;  return @argv unless defined() && length();    my $arg = '';  my( $i, $quote_mode ) = ( 0, 0 );    while ( $i < length() ) {        my $ch      = substr( $_, $i  , 1 );    my $next_ch = substr( $_, $i+1, 1 );        if ( $ch eq '\\' && $next_ch eq '"' ) {      $arg .= '"';      $i++;    } elsif ( $ch eq '\\' && $next_ch eq '\\' ) {      $arg .= '\\';      $i++;    } elsif ( $ch eq '"' && $next_ch eq '"' && $quote_mode ) {      $quote_mode = !$quote_mode;      $arg .= '"';      $i++;    } elsif ( $ch eq '"' && $next_ch eq '"' && !$quote_mode &&	      ( $i + 2 == length()  ||		substr( $_, $i + 2, 1 ) eq ' ' )	    ) { # for cases like: a"" => [ 'a' ]      push( @argv, $arg );      $arg = '';      $i += 2;    } elsif ( $ch eq '"' ) {      $quote_mode = !$quote_mode;    } elsif ( $ch eq ' ' && !$quote_mode ) {      push( @argv, $arg ) if $arg;      $arg = '';      ++$i while substr( $_, $i + 1, 1 ) eq ' ';    } else {      $arg .= $ch;    }        $i++;  }    push( @argv, $arg ) if defined( $arg ) && length( $arg );  return @argv;}sub arg_defines {  my ($self, %args) = @_;  s/"/\\"/g foreach values %args;  return map qq{"-D$_=$args{$_}"}, keys %args;}sub compile {  my ($self, %args) = @_;  my $cf = $self->{config};  die "Missing 'source' argument to compile()" unless defined $args{source};  my ($basename, $srcdir) =    ( File::Basename::fileparse($args{source}, '\.[^.]+$') )[0,1];  $srcdir ||= File::Spec->curdir();  my @defines = $self->arg_defines( %{ $args{defines} || {} } );  my %spec = (    srcdir      => $srcdir,    builddir    => $srcdir,    basename    => $basename,    source      => $args{source},    output      => File::Spec->catfile($srcdir, $basename) . $cf->{obj_ext},    cc          => $cf->{cc},    cflags      => [                     $self->split_like_shell($cf->{ccflags}),                     $self->split_like_shell($cf->{cccdlflags}),                     $self->split_like_shell($cf->{extra_compiler_flags}),                   ],    optimize    => [ $self->split_like_shell($cf->{optimize})    ],    defines     => \@defines,    includes    => [ @{$args{include_dirs} || []} ],    perlinc     => [                     $self->perl_inc(),                     $self->split_like_shell($cf->{incpath}),                   ],    use_scripts => 1, # XXX provide user option to change this???  );  $self->normalize_filespecs(    \$spec{source},    \$spec{output},     $spec{includes},     $spec{perlinc},  );  my @cmds = $self->format_compiler_cmd(%spec);  while ( my $cmd = shift @cmds ) {    $self->do_system( @$cmd )      or die "error building $cf->{dlext} file from '$args{source}'";  }  (my $out = $spec{output}) =~ tr/'"//d;  return $out;}sub need_prelink { 1 }sub link {  my ($self, %args) = @_;  my $cf = $self->{config};  my @objects = ( ref $args{objects} eq 'ARRAY' ? @{$args{objects}} : $args{objects} );  my $to = join '', (File::Spec->splitpath($objects[0]))[0,1];  $to ||= File::Spec->curdir();  (my $file_base = $args{module_name}) =~ s/.*:://;  my $output = $args{lib_file} ||    File::Spec->catfile($to, "$file_base.$cf->{dlext}");  # if running in perl source tree, look for libs there, not installed  my $lddlflags = $cf->{lddlflags};  my $perl_src = $self->perl_src();  $lddlflags =~ s/\Q$cf->{archlibexp}\E[\\\/]CORE/$perl_src/ if $perl_src;  my %spec = (    srcdir        => $to,    builddir      => $to,    startup       => [ ],    objects       => \@objects,    libs          => [ ],    output        => $output,    ld            => $cf->{ld},    libperl       => $cf->{libperl},    perllibs      => [ $self->split_like_shell($cf->{perllibs})  ],    libpath       => [ $self->split_like_shell($cf->{libpth})    ],    lddlflags     => [ $self->split_like_shell($lddlflags) ],    other_ldflags => [ $self->split_like_shell($args{extra_linker_flags} || '') ],    use_scripts   => 1, # XXX provide user option to change this???  );  unless ( $spec{basename} ) {    ($spec{basename} = $args{module_name}) =~ s/.*:://;  }  $spec{srcdir}   = File::Spec->canonpath( $spec{srcdir}   );  $spec{builddir} = File::Spec->canonpath( $spec{builddir} );  $spec{output}    ||= File::Spec->catfile( $spec{builddir},                                            $spec{basename}  . '.'.$cf->{dlext}   );  $spec{manifest}  ||= File::Spec->catfile( $spec{builddir},                                            $spec{basename}  . '.'.$cf->{dlext}.'.manifest');  $spec{implib}    ||= File::Spec->catfile( $spec{builddir},                                            $spec{basename}  . $cf->{lib_ext} );  $spec{explib}    ||= File::Spec->catfile( $spec{builddir},                                            $spec{basename}  . '.exp'  );  if ($cf->{cc} eq 'cl') {    $spec{dbg_file}  ||= File::Spec->catfile( $spec{builddir},                                            $spec{basename}  . '.pdb'  );  }  elsif ($cf->{cc} eq 'bcc32') {    $spec{dbg_file}  ||= File::Spec->catfile( $spec{builddir},                                            $spec{basename}  . '.tds'  );  }  $spec{def_file}  ||= File::Spec->catfile( $spec{srcdir}  ,                                            $spec{basename}  . '.def'  );  $spec{base_file} ||= File::Spec->catfile( $spec{srcdir}  ,                                            $spec{basename}  . '.base' );  $self->add_to_cleanup(    grep defined,    @{[ @spec{qw(manifest implib explib dbg_file def_file base_file map_file)} ]}  );  foreach my $opt ( qw(output manifest implib explib dbg_file def_file map_file base_file) ) {    $self->normalize_filespecs( \$spec{$opt} );  }  foreach my $opt ( qw(libpath startup objects) ) {    $self->normalize_filespecs( $spec{$opt} );  }  (my $def_base = $spec{def_file}) =~ tr/'"//d;  $def_base =~ s/\.def$//;  $self->prelink( dl_name => $args{module_name},                  dl_file => $def_base,                  dl_base => $spec{basename} );  my @cmds = $self->format_linker_cmd(%spec);  while ( my $cmd = shift @cmds ) {    $self->do_system( @$cmd );  }  $spec{output} =~ tr/'"//d;  return wantarray    ? grep defined, @spec{qw[output manifest implib explib dbg_file def_file map_file base_file]}    : $spec{output};}# canonize & quote pathssub normalize_filespecs {  my ($self, @specs) = @_;  foreach my $spec ( grep defined, @specs ) {    if ( ref $spec eq 'ARRAY') {      $self->normalize_filespecs( map {\$_} grep defined, @$spec )    } elsif ( ref $spec eq 'SCALAR' ) {      $$spec =~ tr/"//d if $$spec;      next unless $$spec;      $$spec = '"' . File::Spec->canonpath($$spec) . '"';    } elsif ( ref $spec eq '' ) {      $spec = '"' . File::Spec->canonpath($spec) . '"';    } else {      die "Don't know how to normalize " . (ref $spec || $spec) . "\n";    }  }}# directory of perl's include filessub perl_inc {  my $self = shift;  my $perl_src = $self->perl_src();  if ($perl_src) {    File::Spec->catdir($perl_src, "lib", "CORE");  } else {    File::Spec->catdir($self->{config}{archlibexp},"CORE");  }}1;########################################################################=begin commentThe packages below implement functions for generating properlyformatted commandlines for the compiler being used. Each packagedefines two primary functions 'format_linker_cmd()' &'format_compiler_cmd()' that accepts a list of named arguments (ahash) and returns a list of formatted options suitable for invoking thecompiler. By default, if the compiler supports scripting of itsoperation then a script file is built containing the options whilethose options are removed from the commandline, and a reference to thescript is pushed onto the commandline in their place. Scripting thecompiler in this way helps to avoid the problems associated with longcommandlines under some shells.=end comment=cut########################################################################package ExtUtils::CBuilder::Platform::Windows::MSVC;sub format_compiler_cmd {  my ($self, %spec) = @_;  foreach my $path ( @{ $spec{includes} || [] },                     @{ $spec{perlinc}  || [] } ) {    $path = '-I' . $path;  }  %spec = $self->write_compiler_script(%spec)    if $spec{use_scripts};  return [ grep {defined && length} (    $spec{cc},'-nologo','-c',    @{$spec{includes}}      ,    @{$spec{cflags}}        ,    @{$spec{optimize}}      ,    @{$spec{defines}}       ,    @{$spec{perlinc}}       ,    "-Fo$spec{output}"      ,    $spec{source}           ,  ) ];}sub write_compiler_script {  my ($self, %spec) = @_;  my $script = File::Spec->catfile( $spec{srcdir},                                    $spec{basename} . '.ccs' );  $self->add_to_cleanup($script);  print "Generating script '$script'\n" if !$self->{quiet};  open( SCRIPT, ">$script" )    or die( "Could not create script '$script': $!" );  print SCRIPT join( "\n",    map { ref $_ ? @{$_} : $_ }    grep defined,    delete(      @spec{ qw(includes cflags optimize defines perlinc) } )  );  close SCRIPT;  push @{$spec{includes}}, '@"' . $script . '"';  return %spec;}sub format_linker_cmd {  my ($self, %spec) = @_;  my $cf = $self->{config};  foreach my $path ( @{$spec{libpath}} ) {    $path = "-libpath:$path";  }  my $output = $spec{output};  $spec{def_file}  &&= '-def:'      . $spec{def_file};  $spec{output}    &&= '-out:'      . $spec{output};  $spec{manifest}  &&= '-manifest ' . $spec{manifest};  $spec{implib}    &&= '-implib:'   . $spec{implib};  $spec{map_file}  &&= '-map:'      . $spec{map_file};  %spec = $self->write_linker_script(%spec)    if $spec{use_scripts};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -