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.

cc

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

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

Examples:

# gcc
$config->cc('gcc');

# g++ for C++
$config->cc('g++');

# nvcc for CUDA/GUP
$config->cc('nvcc');

# cc that compiled this Perl
use Config;
$config->cc($Config{cc});

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');

source_files

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

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

Examples:

$config->source_files(['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.

file

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

Get and set the config file path.

file_optional

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

Get and set the "file" field is optional in "new" method.

Default is 0.

Examples:

my $config = SPVM::Builder::Config->new(file_optional => 1);

class_name

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

Get and set the class name.

This is automatically decided by "file" field when "new" method is called.

For example "file" is /path/SPVM/Foo.config, class_name becomes SPVM::Foo.

Because This is parsed from /path/SPVM/Foo.spvm, the module file must be exist if file field is specified.

native_include_dir

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

Get and set the native include directory.

This is automatically decided by "file" field when "new" method is called.

For example "file" is /path/SPVM/Foo.config, native_include_dir becomes /path/SPVM/Foo.native/include

native_src_dir

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

Get and set the native src directory. This is automatically decided by "file" field when "new" method is called.

This is automatically decided by "file" field when "new" method is called.

For example "file" is /path/SPVM/Foo.config, native_include_dir becomes /path/SPVM/Foo.native/src

native_lib_dir

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

Get and set the native lib directory.

This is automatically decided by "file" field when "new" method is called.

For example "file" is /path/SPVM/Foo.config, native_lib_dir becomes /path/SPVM/Foo.native/lib

native_bin_dir

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

Get and set the native bin directory.

This is automatically decided by "file" field when "new" method is called.

For example "file" is /path/SPVM/Foo.config, native_bin_dir becomes /path/SPVM/Foo.native/bin

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(file => $config_file);

Create SPVM::Builder::Config object.

Examples:

# Foo/Bar.config
my $config = SPVM::Builder::Config->new(file => __FILE__);

new_c

my $config = SPVM::Builder::Config->new_c(file => $config_file);

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');

Examples:

# Foo/Bar.config
my $config = SPVM::Builder::Config->new_c(file => __FILE__);

new_c99

my $config = SPVM::Builder::Config->new_c99(file => $config_file);

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

Examples:

# Foo/Bar.config
my $config = SPVM::Builder::Config->new_c99(file => __FILE__);

new_cpp

my $config = SPVM::Builder::Config->new_cpp(file => $config_file);

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');

Examples:

# Foo/Bar.config
my $config = SPVM::Builder::Config->new_cpp(file => __FILE__);

new_cpp11

my $config = SPVM::Builder::Config->new_cpp11(file => __FILE__);

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

Examples:

# Foo/Bar.config
my $config = SPVM::Builder::Config->new_cpp11(file => __FILE__);

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_source_files

$config->add_source_files(@source_files);

Add the values after the last element of source_files 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');

use

$config->use(@resources);

This method is the alias for "add_resources" to improve user experiences.

Examples:

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

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.