SPVM::Builder::Config::Exe − Excutable File Config
The SPVM::Builder::Config::Exe class has methods to manipulate the config for the excutable file generated by spvmcc command.
use
SPVM::Builder::Config::Exe;
my $config_exe =
SPVM::Builder::Config::Exe−>new_gnu99;
The fields for compiler flags in SPVM::Builder::Config such as "cc" in SPVM::Builder::Config, "std" in SPVM::Builder::Config should not be changed.
This is because the compiler flags are used to compile SPVM core source files and a bootstrap source file generagted by "spvmcc" command.
A config can have its mode if the config is one for an executable file generated by spvmcc command.
The mode is written in the format ".MODE_NAME" just before ".config" extension of a config file.
"MODE_NAME" must consist of "a−zA−Z0−9_".
Examples:
# production
mode
MyClass.production.config
# devel mode
MyClass.devel.config
Use "mode" field to get the config mode.
my $mode = $config−>mode;
The spvmcc command has "−−mode" option for giving a config mode.
spvmcc −o myapp −−mode production myapp.spvm
|
• |
SPVM::Builder::Config |
my $mode =
$config−>mode;
$config−>mode($mode);
Gets and sets "mode" field.
my
$before_compile_cbs_global =
$config_exe−>before_compile_cbs_global;
$config_exe−>before_compile_cbs_global($before_compile_cbs_global);
Gets and sets the "before_compile_cbs_global" field, an array reference of callbacks that work globally called just before the compile command "cc" is executed.
This affects all compilations.
my
$ccflags_global = $config−>ccflags_global;
$config−>ccflags_global($ccflags_global);
Gets and sets "ccflags" field, an array reference containing arugments of the compiler "cc" in all compilation.
my $ccflags_spvm
= $config−>ccflags_spvm;
$config−>ccflags_spvm($ccflags_spvm);
Gets and sets "ccflags_spvm" field, an array reference containing arugments of the compiler "cc" in compilations of SPVM source code and a bootstrap source file.
my
$ccflags_native = $config−>ccflags_native;
$config−>ccflags_native($ccflags_native);
Gets and sets "ccflags_native" field, an array reference containing arugments of the compiler "cc" in compilation of all native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c>.
my
$ccflags_native_class =
$config−>ccflags_native_class($class_name);
$config−>ccflags_native_class($class_name,
$ccflags_native);
Gets and sets the value of "ccflags_native_class" field's class name key $class_name, an array reference containing arugments of the compiler "cc" in compilation of native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c> in $class_name.
my
$ccflags_precompile = $config−>ccflags_precompile;
$config−>ccflags_precompile($ccflags_precompile);
Gets and sets "ccflags_precompile" field, an array reference containing arugments of the compiler "cc" in compilation for precompilation.
my
$defines_global = $config−>defines_global;
$config−>defines_global($defines_global);
Gets and sets "defines" field, an array reference containing the value of "−D" arugments of the compiler "cc" in all compilation.
my $defines_spvm
= $config−>defines_spvm;
$config−>defines_spvm($defines_spvm);
Gets and sets "defines_spvm" field, an array reference containing the value of "−D" arugments of the compiler "cc" in compilations of SPVM source code and a bootstrap source file.
my
$defines_native = $config−>defines_native;
$config−>defines_native($defines_native);
Gets and sets "defines_native" field, an array reference containing the value of "−D" arugments of the compiler "cc" in compilation of all native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c>.
my
$defines_native_class =
$config−>defines_native_class($class_name);
$config−>defines_native_class($class_name,
$defines_native);
Gets and sets the value of "defines_native_class" field's class name key $class_name, an array reference containing the value of "−D" arugments of the compiler "cc" in compilation of native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c> in $class_name.
my
$defines_precompile = $config−>defines_precompile;
$config−>defines_precompile($defines_precompile);
Gets and sets "defines_precompile" field, an array reference containing the value of "−D" arugments of the compiler "cc" in compilation for precompilation.
my
$optimize_global = $config−>optimize_global;
$config−>optimize_global($optimize_global);
Gets and sets "optimize" field, an arugment of the compiler "cc" for optimization in all compilation.
my
$optimize_spvm = $config−>optimize_spvm;
$config−>optimize_spvm($optimize_spvm);
Gets and sets "optimize_spvm" field, an arugment of the compiler "cc" for optimization in compilations of SPVM source code and a bootstrap source file.
my
$optimize_native = $config−>optimize_native;
$config−>optimize_native($optimize_native);
Gets and sets "optimize_native" field, an arugment of of the compiler "cc" for optimization in compilation of all native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c>.
my
$optimize_native_class =
$config−>optimize_native_class($class_name);
$config−>optimize_native_class($class_name,
$optimize_native);
Gets and sets the value of "optimize_native_class" field's class name key $class_name, an arugments of the compiler "cc" for optimization in compilation of native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c> in $class_name.
my
$optimize_precompile =
$config−>optimize_precompile;
$config−>optimize_precompile($optimize_precompile);
Gets and sets "optimize_precompile" field, an arugment of of the compiler "cc" for optimization in compilation for precompilation.
my
$include_dirs_global =
$config−>include_dirs_global;
$config−>include_dirs_global($include_dirs_global);
Gets and sets "include_dirs" field, an array reference containing "−I" arugments of the compiler "cc" in all compilation.
my
$include_dirs_spvm = $config−>include_dirs_spvm;
$config−>include_dirs_spvm($include_dirs_spvm);
Gets and sets "include_dirs_spvm" field, an array reference containing "−I" arugments of the compiler "cc" in compilations of SPVM source code and a bootstrap source file.
my
$include_dirs_native =
$config−>include_dirs_native;
$config−>include_dirs_native($include_dirs_native);
Gets and sets "include_dirs_native" field, an array reference containing "−I" arugments of the compiler "cc" in compilation of all native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c>.
my
$include_dirs_native_class =
$config−>include_dirs_native_class($class_name);
$config−>include_dirs_native_class($class_name,
$include_dirs_native);
Gets and sets the value of "include_dirs_native_class" field's class name key $class_name, an array reference containing "−I" arugments of the compiler "cc" in compilation of native class source file(such as MyClass.c) and all native source files(such as MyClass.native/src/mysource.c> in $class_name.
my
$include_dirs_precompile =
$config−>include_dirs_precompile;
$config−>include_dirs_precompile($include_dirs_precompile);
Gets and sets "include_dirs_precompile" field, an array reference containing "−I" arugments of the compiler "cc" in compilation for precompilation.
my
$external_object_files =
$config−>external_object_files;
$config−>external_object_files($external_object_files);
Gets and sets "external_object_files" field, an array reference containing additinal external object files linked to an executable file.
An SPVM archive.
See "load_spvm_archive" and "get_spvm_archive".
my
$spvm_archive_skip_classes =
$config−>spvm_archive_skip_classes;
$config−>spvm_archive_skip_classes($spvm_archive_skip_classes);
Gets and sets "spvm_archive_skip_classes" field, an array reference containg the names of classes in an SPVM archive you do not want to load.
See also "load_spvm_archive".
my $config_exe = SPVM::Builder::Config::Exe−>new(%fields);
Create a new SPVM::Builder::Config::Exe object with "Fields" and fields of its super classes.
This method calls the "new" method of its super class given %fields with field default values applied.
Field Default Values:
|
• |
output_type |
"exe"
|
• |
"before_compile_cbs_global" |
[]
|
• |
Other Fields |
undef
my $config = $config−>load_base_config($config_file);
Creates the base config file path from the config file path $config_file, and calls load_config method given the base config file path and config arguments, and returns its return value.
A base config file is the config file that removes its mode.
# Config file
MyClass.mode.config
# Base config file
MyClass.config
Examples:
my $config = SPVM::Builder::Config::Exe−>load_base_config(__FILE__);
my $config = $config−>load_mode_config($config_file, $mode);
Creates a mode config file path from the config file path $config_file, and calls load_config method given the mode config file path and config arguments, and returns its return value.
my $config = SPVM::Builder::Config::Exe−>load_mode_config(__FILE__, "production");
""mode"" field is set to $mode.
$config_exe−>add_before_compile_cb_global(@before_compile_cbs_global);
Adds @before_compile_cbs_global to the end of "before_compile_cbs_global" field.
Examples:
$config_exe−>add_before_compile_cb_global(sub
{
my ($config, $compile_info) = @_;
my $cc_command = $compile_info−>to_command;
# Do something
});
$config−>add_ccflag_global(@ccflags_global);
Adds @ccflags_global to the end of "ccflags_global" field.
$config−>add_ccflag_spvm(@ccflags_spvm);
Adds @ccflags_spvm to the end of "ccflags_spvm" field.
$config−>add_ccflag_native(@ccflags_native);
Adds @ccflags_native to the end of "ccflags_native" field.
$config−>add_ccflag_native_class($class_name, @ccflags_native_class);
Adds @ccflags_native_class to the end of "ccflags_native_class" field's key $class_name.
$config−>add_ccflag_precompile(@ccflags_precompile);
Adds @ccflags_precompile to the end of "ccflags_precompile" field.
$config−>add_define_global(@defines_global);
Adds @defines_global to the end of "defines_global" field.
$config−>add_define_spvm(@defines_spvm);
Adds @defines_spvm to the end of "defines_spvm" field.
$config−>add_define_native(@defines_native);
Adds @defines_native to the end of "defines_native" field.
$config−>add_define_native_class($class_name, @defines_native_class);
Adds @defines_native_class to the end of "defines_native_class" field's key $class_name.
$config−>add_define_precompile(@defines_precompile);
Adds @defines_precompile to the end of "defines_precompile" field.
$config−>add_include_dir_global(@include_dirs_global);
Adds @include_dirs_global to the end of "include_dirs_global" field.
$config−>add_include_dir_spvm(@include_dirs_spvm);
Adds @include_dirs_spvm to the end of "include_dirs_spvm" field.
$config−>add_include_dir_native(@include_dirs_native);
Adds @include_dirs_native to the end of "include_dirs_native" field.
$config−>add_include_dir_native_class($class_name, @include_dirs_native_class);
Adds @include_dirs_native_class to the end of "include_dirs_native_class" field's key $class_name.
$config−>add_include_dir_precompile(@include_dirs_precompile);
Adds @include_dirs_precompile to the end of "include_dirs_precompile" field.
$config−>add_external_object_file(@external_object_files);
Adds @external_object_files to the end of "external_object_files" field.
$config−>load_spvm_archive($spvm_archive);
$config−>load_spvm_archive($spvm_archive,
$options);
Loads an SPVM archive.
Actually, "spvm_archive" field is just set to $spvm_archive, and "spvm_archive_skip_classes" field is set to the vlaue of "skip" option, and the loading happens later.
Options:
|
• |
skip |
An array reference containg the names of classes you do not want to load.
Examples:
my $config_dir =
File::Basename::dirname __FILE__;
$config−>load_spvm_archive("$config_dir/myapp.spvm−archive.tar.gz);
$config−>load_spvm_archive("$config_dir/myapp.spvm−archive.tar.gz,
{skip => ['SomeClass1', 'SomeClass2]});
my $spvm_archive = $config−>get_spvm_archive;
Gets an SPVM archive.
Copyright (c) 2023 Yuki Kimoto
MIT License