Name

SPVM::Builder::Config - Config for Compiling and Linking Native Classes

Description

The SPVM::Builder::Config class has methods to get and set config for compiling and linking native classes.

Fields

class_name

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

Gets and sets class_name field, the name of the class configured by this config.

This field is automatically set and users nomally do not change it.

file

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

Gets and sets file field, the file path of this config.

This field is set by "load_config" method and users should not set it.

category

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

Gets and sets category field.

If this field is precompile, this config is for precompilation,

If this field is native, this config is for a native class.

This field is automatically set and users nomally do not change it.

is_resource

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

Gets and sets is_resource field.

If this field is true, this config is for a resource class.

force

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

Gets and sets force field.

If this field is a true value, the compilation and linking are forced.

If this field is a false value except for undef, the compilation and linking are performed following the rule of the dependency resolution.

If this field is undef, this config does not specify whether the compilation and linking are perfomed.

quiet

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

Gets and sets quiet field.

If this field is a true value, the messages from the compiler and the linker are output to stderr.

If this field is a false value except for undef, the messages from the compiler and the linker are not output.

If this field is undef, this config does specify whether the messages from the compiler and the linker are output.

mode

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

Gets and sets mode field.

config_global

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

Gets and sets the config_global field, which provides global compilation rules.

This field is an SPVM::Builder::Config::Global object (like SPVM::Builder::Config::Exe) that stores shared settings used across multiple compilation units.

For example, when the spvmcc command generates an executable file, it sets this field to an SPVM::Builder::Config::Exe object. This allows individual resource configurations to inherit or refer to global flags, such as optimization levels or common library paths, defined in the executable's main configuration.

loaded_config_files

Returns the config files loaded by "load_config" method.

Class Methods

new

my $config = SPVM::Builder::Config::Base->new(%fields);

Creates a new SPVM::Builder::Config::Base object with fields, and returns it.

Field Default Values:

Instance Methods

load_config

my $config = $config->load_config($config_file);

Loads a config file given a config file path and an array refernce containing config arguments, and returns an SPVM::Builder::Config object.

Examples:

my $config = $config->load_config(__FILE__);

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::Global->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::Global->load_mode_config(__FILE__, "production");

""mode"" field is set to $mode.

clone

my $clone = $self->clone;

Clones SPVM::Builder::Config object, and returns it.

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

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License