Name

spvmcc - Generating Excutable File

Description

The spvmcc command generates an executable file from SPVM classes.

Usage

Usage: spvmcc [OPTIONS] SCRIPT_NAME
  
  spvmcc -o myapp myapp.spvm
  
  spvmcc -I lib/SPVM -o myapp myapp.spvm

Options:
  -h, --help                      Shows this message
  -v, --version                   Shows the version
  -o, --output FILE               The output file name
  -I, --include-dir DIRECTORY     Adds a include directory
  -B, --build-dir DIRECTORY       Build diretory
  -q, --quiet                     Stops the output of messages
  -f, --force                     Forces the compile and link
  --no-config                     No configration file is ok
  -m, --mode MODE                 Config mode
  --config-argv ARG               A config argument
  --config-argv-option ARG_PAIR   Key-value config arguments such as KEY=VALUE
  --optimize LEVEL                Optimization level such as O3, "-O0 -g"

Details

spvmcc [OPTIONS] SCRIPT_NAME

The spvmcc command generates an executable file from SPVM classes.

OPTIONS are options.

SCRIPT_NAME is a script name that contains a bootstrap method in an anon class.

class {
  static method main : void () {
    
  }
}

See Class Search Directories about default class search directories.

See SPVM::Document::EnvironmentVariables about available environment variables.

Config File for Executable File

A config file that corresponding to the script name must exist for an executable file except for the case that "--no-config" is specified.

The config for an executable file is a SPVM::Builder::Config::Exe object.

myapp.config:

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

my $exe_config = SPVM::Builder::Config::Exe->new_gnu99(file => __FILE__);

$exe_config

Caching System

Compiled object files and an executable file are not rebuilt unless they need to be rebuilt.

"--force" option forces the rebuild.

Resources

There are important points to be aware of when generating executable files. That is, resources are not automatically compiled.

When you run an SPVM program with the spvm command, the resources are contained within the shared library of each class. Therefore, there are no conflicts between resources.

However, in the case of executable files, there are resource conflicts. For this, the resources must be resolved manually in the configuration file.

$config->use_resource('Resource::Zlib');

This is hard work, but given that the executable file must be compiled from source files and run on a variety of platforms, I think that solving it manually is a better way.

I have published a command that allows you to view the list of classes using resources and the resource settings.

See also --resource-info option in spvmdeps command to dump resource information.

Options

--help

Outputs how to use the spvmcc command to standard output.

-h

-h

Same as "--help".

--version

Outputs the version of the spvmcc command to standard output. This version is the same as the version of SPVM.

-v

-v

Same as "--version".

--include-dir

--include-dir DIRECTORY

Prepends DIRECTORY to class search directories

This option can be specified multiple times.

--include-dir dir1 --include-dir dir2

In this case, class search directories becomes the following.

[dir1, dir2, default_dirs]

-I

-I DIRECTORY

Same as "--include-dir".

--build-dir

--build-dir DIRECTORY

Sets SPVM_BUILD_DIR environment variable to DIRECTORY.

-B

-B DIRECTORY

Same as "--build-dir".

--output

--output FILE

Specifies the output file path FILE. This output file is an executable file.

-o

-o FILE

Same as "--output".

--quiet

--quiet

Suppresses messages from the spvmcc command.

-q

-q

Same as "--quiet".

--force

--force

Forces the rebuild of object files and an executable file.

-f

-f

Same as "--force".

--no-config

If this option is specified and a config file does not exist, the spvmcc command runs without finising the program.

--mode

--mode MODE

Specifies the config mode MODE.

See Config Mode about config modes.

-m

-m MODE

Same as "--mode".

--config-argv

--config-argv ARG

Specifies a config argument ARG.

This option can be specified multiple times.

See Config Arguments about config arguments.

Examples:

--config-argv FOO

--config-argv-option

--config-argv-option ARG_PAIR

Specifies two config arguments ARG_PAIR as the format KEY=VALUE.

This is expaned to the following options.

--config-argv KEY --config-argv VALUE

If only KEY exists or VALUE dose not exist, VALUE is set to an empty string "".

This option can be specified multiple times.

See Config Arguments about config arguments.

Examples:

--config-argv-option FOO=1

--optimize

--optimize LEVEL

Sepcifies optimization level LEVEL.

This affects all source files that are compiled.

Examples:

--optimize "-O0 -g"

-w

-w

Enables warning flag.

Implementation:

Sets CommandInfo#WARNING class variable to 1.

lib Directive

If the source code specified by SCRIPT_NAME contains lib directives, The directories specified by lib directive is prepeneded to class search directories.

#lib "$FindBin::Bin/lib"

class {

}

This directories specified by lib directive is placed after the directories specified by "--include-dir" option.

Copyright & License

Copyright 2023 Yuki Kimoto. All Rights Reserved.

MIT License.