Name

SPVM::Builder::LibInfo - Library Information

Description

The SPVM::Builder::LibInfo class has methods to manipulate library information.

Fields

name

my $name = $lib_info->name;
$lib_info->name($name);

Gets and sets the library name.

Examples:

$lib_info->name('z');

$lib_info->name('png');

file

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

Gets and sets the absolute path of the library file like /path/libz.so, /path/libpng.a.

static

my $static = $lib_info->static;
$lib_info->static($static);

Gets and sets the flag whether a static library is linked.

Default:

A false value.

is_abs

my $is_abs = $lib_info->is_abs;
$lib_info->is_abs($is_abs);

If the is_abs is a true value, the library is linked by the library name like -lfoo.

If it is a false value, the library is linked by the absolute path of the library like /path/libfoo.so.

Default:

A false value.

static_option_cb

my $static_option_cb = $lib_info->static_option_cb;
$lib_info->static_option_cb($static_option_cb);

Gets and sets the callback to create a linker option to link a static library.

Default:

sub {
  my ($self, $name) = @_;
  
  $name = "-Wl,-Bstatic -l$name -Wl,-Bdynamic";
  
  return $name;
};

Class Methods

new

my $lib_info = SPVM::Builder::LibInfo->new;

Instance Methods

to_arg

my $link_command_arg = $lib_info->to_arg;

Creates an argument of the link command from the "is_abs" field and "static" field, and returns it.

The following ones are examples of the return value.

-lfoo
-Wl,-Bstatic -lfoo -Wl,-Bdynamic
/path/foo.so
/path/foo.a

to_string

my $lib_name = $lib_info->to_string;

Returns the "name" field.

Operators

Overloads the following operators.

bool

my $bool = !!$lib_info;

Always true.

stringify

my $lib_name = "$lib_info";

Alias for the "to_string" method.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License