The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SPVM::Builder::Config - Configurations of Compile and Link of Native Sources

DESCRIPTION

SPVM::Builder::Config is configuration of c/c++ compile and link.

FIELDS

Fields.

ext

  my $ext = $config->ext;
  $config->ext($ext);

Get and set the extension of native sources. This is used by the compiler.

The default is undef.

Examples:

  $config->ext('c');
  $config->ext('cpp');
  

cc

  my $cc = $config->cc;
  $config->cc($cc);

Get and set a compiler. The default is the value of cc of Config module.

include_dirs

  my $include_dirs = $config->include_dirs;
  $config->include_dirs($include_dirs);

Get and set header including directories of the compiler. This is same as -I option of gcc.

The default value is "SPVM/Builder/include" of one up of directory that SPVM::Buidler::Config.pm is loaded.

At runtime, the "include" directory of the native module is added before include_dirs.

ccflags

  my $ccflags = $config->ccflags;
  $config->ccflags($ccflags);

Get and set compiler flags. the default is a empty string.

optimize

  my $optimize = $config->optimize;
  $config->optimize($optimize);

Get and set the option for optimization of the compiler.

The default is -O3.

Examples:

  $config->optimize('-O3');
  $config->optimize('-O2');
  $config->optimize('-g3 -O0');

sources

  my $sources = $config->sources;
  $config->sources($sources);

Get and get source files. These sourceraries are linked by the compiler.

Examples:

  $config->sources(['foo.c', 'bar.c']);

ld

  my $ld = $config->ld;
  $config->ld($ld);

Get and set a linker. Default is ld of Config module.

lib_dirs

  my $lib_dirs = $config->lib_dirs;
  $config->lib_dirs($lib_dirs);

Get and set the directories libraries are searched for by the linker. This is same as -L option of gcc.

Default:

Windows

  The directory that perlxxx.dll exists
  

Not Windows

  empty list

At runtime, the "lib" directory of the native module is added before include_dirs.

exported_funcs

  my $exported_funcs = $config->exported_funcs;
  $config->exported_funcs($exported_funcs);

Get and set the exported functions. This has means on Windows.

libs

  my $libs = $config->libs;
  $config->libs($libs);

Get and set libraries. These libraries are linked by the linker.

If a dynamic link library is found from "lib_dirs", this is linked. Otherwise if a static link library is found from "lib_dirs", this is linked.

Examples:

  $config->libs(['gsl', 'png']);

If you want to link only dynamic link library, you can use the following hash reference as the value of the element instead of the library name.

  {type => 'dynamic', name => 'gsl'}

If you want to link only static link library, you can use the following hash reference as the value of the element instead of the library name.

  {type => 'static', name => 'gsl'}

resources

  my $resources = $config->resources;
  $config->resources($resources);

Get and get resouce module names.

At runtime, each modules' native "include" directory is added before include_dirs, and "lib" directory is added before lib_dirs.

Examples:

  $config->resources(['SPVM::Resouce::Zlib::V1_15']);
  

ldflags

  my ldflags = $config->ldflags;
  $config->ldflags(ldflags);

Get and set linker flags.

Default:

Windows

  "-mdll -s"
  

Non-Windows

  "-shared"

ld_optimize

  my $ld_optimize = $config->ld_optimize;
  $config->ld_optimize($ld_optimize);

Get and set the option for optimization of the linker such as -O3, -O2, -g3 -O0.

The default is -O2.

force

  my $force = $config->force;
  $config->force($force);

Get and set the flag to force compiles and links without caching.

quiet

  my $quiet = $config->quiet;
  $config->quiet($quiet);

Get and set the flag if the compiler and the linker output the results.

The default is 1.

Methods

new

  my $config = SPVM::Builder::Config->new;
  

Create SPVM::Builder::Config object.

new_c

  my $config = SPVM::Builder::Config->new_c;

Create default build config with C settings. This is SPVM::Builder::Config object.

If you want to use the specific C version, use set_std method.

  $config->set_std('c99');

new_c99

  my $config = SPVM::Builder::Config->new_c99;

Create default build config with C99 settings. This is SPVM::Builder::Config object.

new_cpp

  my $config = SPVM::Builder::Config->new_cpp;

Create default build config with C++ settings. This is SPVM::Builder::Config object.

If you want to use the specific C++ version, use set_std method.

  $config->set_std('c++11');

new_cpp11

  my $config = SPVM::Builder::Config->new_cpp11;

Create default build config with C++11 settings. This is SPVM::Builder::Config object.

set_std

  $config->set_std($std);

Add the value that is converted to -std=$std after the last element of ccflags field.

Example:

  $config->set_std('gnu99');

add_ccflags

  $config->add_ccflags(@ccflags);

Add values after the last element of ccflags field.

add_ldflags

  $config->add_ldflags(@ldflags);

Add values after the last element of ldflags field.

add_include_dirs

  $config->add_include_dirs(@include_dirs);

Add values after the last element of include_dirs field.

add_lib_dirs

  $config->add_lib_dirs(@lib_dirs);

Add values after the last element of lib_dirs field.

add_sources

  $config->add_sources(@sources);

Add the values after the last element of sources field.

add_exported_funcs

  $config->add_exported_funcs(@exported_funcs);

Add values after the last element of exported_funcs field.

add_libs

  $config->add_libs(@libs);

Add the values after the last element of libs field.

Examples:

  $config->add_libs('gsl');

add_static_libs

  $config->add_static_libs(@libs);

Add the values that each element is converted to the following hash reference after the last element of libs field.

  {type => 'static', name => $lib}

Examples:

  $config->add_static_libs('gsl');

add_dynamic_libs

  $config->add_dynamic_libs(@libs);

Add the values that each element is converted to the following hash reference after the last element of libs field.

  {type => 'dynamic', name => $lib}

Examples:

  $config->add_dynamic_libs('gsl');

add_resources

  $config->add_resources(@resources);

Add the values after the last element of resources field.

Examples:

  $config->add_resources('SPVM::Resouce::Zlib::V1_15');

to_hash

  my $config = $config->to_hash;

Convert SPVM::Builder::Config to a hash reference.

search_lib_dirs_from_cc_info

  my $lib_dirs = $config->search_lib_dirs_from_cc_info;

Get the library searching directories parsing the infomation the compiler has.

search_lib_dirs_from_config_libpth

  my $lib_dirs = $config->search_lib_dirs_from_config_libpth;

Get the library searching directories parsing libpth of Config.

search_include_dirs_from_config_incpth

  my $include_dirs = $config->search_include_dirs_from_config_incpth;

Get the header searching directories parsing incpth of Config.

sub get_include_dir

  my $include_dir = $config->get_include_dir(__FILE__);

Get the header include directory from the config file name.

get_src_dir

  my $src_dir = $config->get_src_dir(__FILE__);

Get the source directory from the config file name.

get_lib_dir

  my $lib_dir = $config->get_lib_dir(__FILE__);

Get the library directory from the config file name.