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 -o myapp myapp.spvm

Options:
  -h, --help                     Shows this message
  -v, --version                  Shows the version
  -I DIR                         Adds a include directory
  -Mblib                         Same as "-Mblib" in perl
  
  -B, --build-dir DIR            Build directory
  -w                             Enables warning flag
  -f|--force                     Compilations and links are forced
  
  -q, --quiet                    Stops diagnostic messages.
  -o, --output FILE              The output file name
  --no-config                    No configration file is ok
  -m, --mode MODE                Config mode

Details

spvmcc Command

spvmcc [OPTIONS] SCRIPT_NAME

The spvmcc command generates an executable file from SPVM classes.

OPTIONS are options.

SCRIPT_NAME is a script path that contains an SPVM script.

# myapp.spvm
use Fn;
my $var = 1;
say $var;

Anon class that contains a bootstrap method is allowed as an SPVM script.

# myapp.spvm
class {
  
  version "1.001";
  
  our $FOO : int;
  
  use Fn;
  
  static method main : void () {
    my $var = 1;
    say $var;
  }
}

The base name of SCRIPT_NAME must be a Script Base Name. Otherwise an exception is thrown.

See Class Search Directories about default class search directories.

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

Exported Functions

The executable file or dynamic link file generated by spvmcc command contains the following exported functions.

int SPVMCC__main(int argc, char* argv[]);

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;

$exe_config

Build Caching

High-reliability build caching using Ninja-compatible logs, command-line hashes, and file content SHA-1 to detect all changes perfectly.

See SPVM::Builder::Ninja.

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.

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"

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

Options

--help

See "--help" in spvm.

-h

-h

See "-h" in spvm.

--version

See "--version" in spvm.

-v

-v

See "-v" in spvm.

-I

-I DIR

See "-I" in spvm.

-Mblib

-Mblib

See "-Mblib" in spvm.

See "-B" in spvm.

--build-dir

--build-dir DIR

See "--build-dir" in spvm.

-B

-B DIR

-w

-w

See "-w" in spvm.

-f

-f

See "-f" in spvm.

--force

See "--force" in spvm.

--quiet

--quiet

Stops diagnostic messages.

-q

-q

Same as "--quiet".

--output

--output FILE

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

-o

-o FILE

Same as "--output".

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

--object-file

--object-file OBJECT_FILE

An additional object file OBJECT_FILE passed to the linker.

This option can be repeated.

Copyright & License

Copyright 2023 Yuki Kimoto. All Rights Reserved.

MIT License.