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 DIR Adds a include directory
-B, --build-dir DIR Build directory
-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
-w Enables warning flag
-Mblib Same as "-Mblib" in perl
--build-spvm-archive Generate an SPVM archive
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.
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
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.
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.
--build-dir
--build-dir DIR
-B
-B DIR
See "-B" in spvm.
-w
-w
See "-w" in spvm.
-Mblib
-Mblib
See "-Mblib" in spvm.
--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".
--object-file
--object-file OBJECT_FILE
An additional object file OBJECT_FILE passed to the linker.
This option can be repeated.
--build-spvm-archive
--build-spvm-archive
Generate an SPVM archive as a directory into the path of -o option.
If the directory already exists, it is not newly created. The spvm-archive.json file and the classes described in it are overwritten.
SPVM Archive is a format used to bundle SPVM class files, compiled SPVM native classes, precompiled classes, third-party header files, and static libraries into a single directory or a .tar.gz file.
See SPVM::Document::Archive for details.
Copyright & License
Copyright 2023 Yuki Kimoto. All Rights Reserved.
MIT License.