blib/lib/SPVM/Document/Resource.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 =head1 Name
2  
3 SPVM::Document::Resource - Resource
4  
5 =head1 Resource
6  
7 A resource in L<SPVM> is a L<native class|SPVM::Document::NativeClass> that contains L<header files|SPVM::Document::NativeClass/"Native Header Files"> and L<source files|SPVM::Document::NativeClass/"Native Source Files"> writen by native languages such as the C language or C++. A resource must have its L<config file|SPVM::Document::NativeClass/"Native Config File">. A resource does not need to have a L<native class file|SPVM::Document::NativeClass/"Native Class">.
8  
9 =head2 Resource Class
10  
11 The following is an example of a resource.
12  
13 C<SPVM/Resource/MyResource.build>
14  
15 my $config = SPVM::Builder::Config->new_c99;
16
17 $config->is_resource(1);
18
19 my @source_files = ("myresource.c");
20 $config->add_source_file(@source_files);
21
22 $config;
23  
24 Native header files:
25  
26 SPVM/Resource/MyResource.native/include/myresource.h
27  
28 Native source files:
29  
30 SPVM/Resource/MyResource.native/src/myresource.c
31  
32 =head2 Resource User Class
33  
34 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 L<SPVM::Builder::Config#use_resource|SPVM::Builder::Config/"use_resource">.
35  
36 C<SPVM/MyClass.build>
37  
38 my $config = SPVM::Builder::Config->new_c99;
39
40 $config->use_resource("Resource::MyResource");
41
42 $config;
43  
44 C<SPVM/MyClass.c>
45  
46 #include "myresource.h"
47  
48 =head1 Examples
49  
50 See L<Resource::Zlib|https://github.com/yuki-kimoto/SPVM-Resource-Zlib> as an example of resources.
51  
52 =head1 Distribution
53  
54 A distribution for a resource can be generated by L<spvmdist> command with C<--resource> option.
55  
56 # C
57 spvmdist --resource Resource::Foo
58  
59 # C++
60 spvmdist --resource --native c++ Resource::Foo
61  
62 =head1 See Also
63  
64 =over 2
65  
66 =item * L<Resource Modules|https://github.com/yuki-kimoto/SPVM/wiki/CPAN-Modules#resource-modules>
67  
68 =item * L<SPVM::Document>
69  
70 =back
71  
72 =head1 Copyright & License
73  
74 Copyright (c) 2023 Yuki Kimoto
75  
76 MIT License