SPVM::Builder::Config - Configurations of Compile and Link of Native Sources
SPVM::Builder::Config is configuration of c/c++ compile and link.
Fields.
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.
undef
Examples:
$config->ext('c'); $config->ext('cpp');
my $cc = $config->cc; $config->cc($cc);
Get and set a compiler. The default is the value of cc of Config module.
cc
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.
-I
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.
include_dirs
my $ccflags = $config->ccflags; $config->ccflags($ccflags);
Get and set compiler flags. the default is a empty string.
my $optimize = $config->optimize; $config->optimize($optimize);
Get and set the option for optimization of the compiler.
The default is -O3.
-O3
$config->optimize('-O3'); $config->optimize('-O2'); $config->optimize('-g3 -O0');
my $sources = $config->sources; $config->sources($sources);
Get and get source files. These sourceraries are linked by the compiler.
$config->sources(['foo.c', 'bar.c']);
my $ld = $config->ld; $config->ld($ld);
Get and set a linker. Default is ld of Config module.
ld
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.
-L
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.
my $exported_funcs = $config->exported_funcs; $config->exported_funcs($exported_funcs);
Get and set the exported functions. This has means on Windows.
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.
$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'}
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.
lib_dirs
$config->resources(['SPVM::Resouce::Zlib::V1_15']);
my ldflags = $config->ldflags; $config->ldflags(ldflags);
Get and set linker flags.
"-mdll -s"
Non-Windows
"-shared"
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.
-O2
-g3 -O0
The default is -O2.
my $force = $config->force; $config->force($force);
Get and set the flag to force compiles and links without caching.
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.
1
my $config = SPVM::Builder::Config->new;
Create SPVM::Builder::Config object.
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.
set_std
$config->set_std('c99');
my $config = SPVM::Builder::Config->new_c99;
Create default build config with C99 settings. This is SPVM::Builder::Config object.
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');
my $config = SPVM::Builder::Config->new_cpp11;
Create default build config with C++11 settings. This is SPVM::Builder::Config object.
$config->set_std($std);
Add the value that is converted to -std=$std after the last element of ccflags field.
-std=$std
ccflags
Example:
$config->set_std('gnu99');
$config->add_ccflags(@ccflags);
Add values after the last element of ccflags field.
$config->add_ldflags(@ldflags);
Add values after the last element of ldflags field.
ldflags
$config->add_include_dirs(@include_dirs);
Add values after the last element of include_dirs field.
$config->add_lib_dirs(@lib_dirs);
Add values after the last element of lib_dirs field.
$config->add_sources(@sources);
Add the values after the last element of sources field.
sources
$config->add_exported_funcs(@exported_funcs);
Add values after the last element of exported_funcs field.
exported_funcs
$config->add_libs(@libs);
Add the values after the last element of libs field.
libs
$config->add_libs('gsl');
$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}
$config->add_static_libs('gsl');
$config->add_dynamic_libs(@libs);
{type => 'dynamic', name => $lib}
$config->add_dynamic_libs('gsl');
$config->add_resources(@resources);
Add the values after the last element of resources field.
resources
$config->add_resources('SPVM::Resouce::Zlib::V1_15');
my $config = $config->to_hash;
Convert SPVM::Builder::Config to a hash reference.
my $lib_dirs = $config->search_lib_dirs_from_cc_info;
Get the library searching directories parsing the infomation the compiler has.
my $lib_dirs = $config->search_lib_dirs_from_config_libpth;
Get the library searching directories parsing libpth of Config.
libpth
my $include_dirs = $config->search_include_dirs_from_config_incpth;
Get the header searching directories parsing incpth of Config.
incpth
my $include_dir = $config->get_include_dir(__FILE__);
Get the header include directory from the config file name.
my $src_dir = $config->get_src_dir(__FILE__);
Get the source directory from the config file name.
my $lib_dir = $config->get_lib_dir(__FILE__);
Get the library directory from the config file name.
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.