Name

SPVM::Builder::Config::Exe - Excutable File Config

Description

The SPVM::Builder::Config::Exe class has methods to manipulate the config for the excutable file generated by spvmcc command.

Usage

use SPVM::Builder::Config::Exe;

my $config_exe = SPVM::Builder::Config::Exe->new_gnu99;

Details

Warning: Should Not Change Compiler Flags

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.

Config Mode

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

Super Class

Fields

mode

my $mode = $config->mode;
$config->mode($mode);

Gets and sets mode field.

before_compile_cbs_global

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.

ccflags_global

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.

ccflags_spvm

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.

ccflags_native

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>.

ccflags_native_class

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.

ccflags_precompile

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.

defines_global

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.

defines_spvm

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.

defines_native

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>.

defines_native_class

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.

defines_precompile

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.

optimize_global

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.

optimize_spvm

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.

optimize_native

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>.

optimize_native_class

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.

optimize_precompile

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.

include_dirs_global

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.

include_dirs_spvm

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.

include_dirs_native

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>.

include_dirs_native_class

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.

include_dirs_precompile

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.

external_object_files

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.

spvm_archive

An SPVM archive.

See "load_spvm_archive" and "get_spvm_archive".

spvm_archive_skip_classes

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".

Methods

new

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:

load_base_config

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__);

load_mode_config

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.

add_before_compile_cb_global

$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
});

add_ccflag_global

$config->add_ccflag_global(@ccflags_global);

Adds @ccflags_global to the end of "ccflags_global" field.

add_ccflag_spvm

$config->add_ccflag_spvm(@ccflags_spvm);

Adds @ccflags_spvm to the end of "ccflags_spvm" field.

add_ccflag_native

$config->add_ccflag_native(@ccflags_native);

Adds @ccflags_native to the end of "ccflags_native" field.

add_ccflag_native_class

$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.

add_ccflag_precompile

$config->add_ccflag_precompile(@ccflags_precompile);

Adds @ccflags_precompile to the end of "ccflags_precompile" field.

add_define_global

$config->add_define_global(@defines_global);

Adds @defines_global to the end of "defines_global" field.

add_define_spvm

$config->add_define_spvm(@defines_spvm);

Adds @defines_spvm to the end of "defines_spvm" field.

add_define_native

$config->add_define_native(@defines_native);

Adds @defines_native to the end of "defines_native" field.

add_define_native_class

$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.

add_define_precompile

$config->add_define_precompile(@defines_precompile);

Adds @defines_precompile to the end of "defines_precompile" field.

add_include_dir_global

$config->add_include_dir_global(@include_dirs_global);

Adds @include_dirs_global to the end of "include_dirs_global" field.

add_include_dir_spvm

$config->add_include_dir_spvm(@include_dirs_spvm);

Adds @include_dirs_spvm to the end of "include_dirs_spvm" field.

add_include_dir_native

$config->add_include_dir_native(@include_dirs_native);

Adds @include_dirs_native to the end of "include_dirs_native" field.

add_include_dir_native_class

$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.

add_include_dir_precompile

$config->add_include_dir_precompile(@include_dirs_precompile);

Adds @include_dirs_precompile to the end of "include_dirs_precompile" field.

add_external_object_file

$config->add_external_object_file(@external_object_files);

Adds @external_object_files to the end of "external_object_files" field.

load_spvm_archive

$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]});

get_spvm_archive

my $spvm_archive = $config->get_spvm_archive;

Gets an SPVM archive.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License