Name
SPVM::Builder::API - Builder APIs
Description
SPVM::Builder::API class has the public methods to build SPVM native classes and SPVM precompilation classes.
Usage
my $builder = SPVM::Builder::API->new(
build_dir => '.spvm_build',
);
$builder->build_dynamic_lib_dist_precompile('MyClass');
$builder->build_dynamic_lib_dist_native('MyClass');
Class Methods
new
my $builder = SPVM::Builder::API->new(%options);
Creates a new SPVM::Builder::API object, and returns it.
Options:
build_dirA build directory.
optimizeThe optimization level for the compiler.
Instance Methods
build_dynamic_lib_dist_precompile
$builder->build_dynamic_lib_dist_precompile($class_name)
$builder->build_dynamic_lib_dist_precompile($class_name, $options)
Generates a dynamic library for a native class given by the class name $class_name, and copies it into the blib/lib directory.
A native class must have at least one method with native attribute.
Options:
$options is a hash reference. This is optional.
optimizeThe optimization level for the compiler (e.g.,
O2,O3,O0).
build_dynamic_lib_dist_native
$builder->build_dynamic_lib_dist_native($class_name)
$builder->build_dynamic_lib_dist_native($class_name, $options)
Generates a dynamic library for a precompilation class $class_name that has native methods, and copies it into the blib/lib directory.
A precompilation class must have at least one method with precompile attribute.
Options:
$options is a hash reference. This is optional.
optimizeThe optimization level for the compiler (e.g.,
O2,O3,O0).
build_parallel_dynamic_lib_dist
$builder->build_parallel_dynamic_lib_dist($options);
Generates dynamic libraries for multiple native classes and precompile classes in parallel, and copies them into the blib/lib directory.
Options:
$options is a hash reference.
native_classesAn array reference of native class names to be built.
native_classes_fileA path to a text file containing native class names to be built. The file must contain one class name per line. If both
native_classesand this option are specified, they are merged.precompile_classesAn array reference of precompile class names to be built.
precompile_classes_fileA path to a text file containing precompile class names to be built. The file must contain one class name per line. If both
precompile_classesand this option are specified, they are merged.optimizeThe optimization level for the compiler (e.g.,
O2,O3,O0).jobsThe number of parallel jobs. The default value is the number of CPU cores.
build_typeThe build type for the compiler and linker. This option follows the standard CMake build types.
Options:
DebugFor debugging. Optimization is disabled and debug symbols are enabled.
ReleaseFor production. High optimization and no debug symbols.
RelWithDebInfoFor production with debug symbols. High optimization with debug symbols.
MinSizeRelFor production, optimized for binary size.
If this option is specified, it overrides the
optimizeoption and sets appropriate flags for both the compiler and the linker to match CMake's behavior.