Name

SPVM::Document::Resource - Resource

Resource

A resource in SPVM is a native class that contains header files and source files writen by native languages such as the C language or C++. A resource must have its config file. A resource does not need to have a native class file.

Resource Class

The following is an example of a resource.

SPVM/Resource/MyResource.config

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

my @source_files = ("myresource.c");
$config->add_source_file(@source_files);

$config;

Native header files:

SPVM/Resource/MyResource.native/include/myresource.h

Native source files:

SPVM/Resource/MyResource.native/src/myresource.c

Resource User Class

A native class can include native header files of a resource and add the object files generated by native source files of a resource to the object files for the linker using the use_resource method in the SPVM::Builder::Config class.

SPVM/MyClass.config

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

$config->use_resource("Resource::MyResource");

$config;

SPVM/MyClass.c

#include "myresource.h"

Examples

See Resource::Zlib as an example of resources.

Distribution

A distribution for a resource can be generated by the spvmdist command with the --resource option.

# C
spvmdist --resource Resource::Foo

# C++
spvmdist --resource --native c++ Resource::Foo

See Also

Resource Modules

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License