Name

SPVM::Builder::CommandInfo - Command Information

Description

The SPVM::Builder::CommandInfo class has methods to manipulate Command information.

Fields

config

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

Gets and sets the config field, a SPVM::Builder::Config object.

output_file

my $output_file = $command_info->output_file;
$command_info->output_file($output_file);

Gets and sets the output_file field, an output file.

command_hash

my $command_hash = $command_info->command_hash;
$command_info->command_hash($command_hash);

Gets and sets the command_hash field, a SHA-1 hash string that uniquely identifies the compilation task.

This hash ensures the consistency of the compilation. It is generated from the following information:

  • The compilation command itself.

  • The Command version.

  • The SPVM version-specific headers.

  • The information of the dependent files.

If any of these change, the hash will change, triggering a re-compilation in the ninja build system.

start_time

my $start_time = $command_info->start_time;
$command_info->start_time($start_time);

Gets and sets the start_time field. It is a Unix timestamp in milliseconds when the command execution started.

end_time

my $end_time = $command_info->end_time;
$command_info->end_time($end_time);

Gets and sets the end_time field. It is a Unix timestamp in milliseconds when the command execution ended.

tmp_dir

my $tmp_dir = $command_info->tmp_dir;
$command_info->tmp_dir($tmp_dir);

Gets and sets the tmp_dir field. It is a directory where the stdout and stderr log files of the command are stored.

process_id

my $process_id = $command_info->process_id;
$command_info->process_id($process_id);

Gets and sets the process_id field. It is the process ID of the command.

Instance Methods

create_command

my $compile_command = $compile_info->create_command;

Creates an array reference of the command conponents, and returns it.

This method is meant to be implemented in child classes.

create_command_string

my $compile_command_string = $compile_info->create_command_string;

Converts the array reference of the compilation command returned by the "create_command" method into a single string that can be executed in a shell (such as sh or bash) or the Windows Command Prompt (cmd.exe).

Each argument is automatically and appropriately quoted only when necessary (e.g., containing spaces or special characters) according to the operating system (OS) to ensure it can be safely executed as a command line.

Return Value Examples:

  • On UNIX/Linux (Only strings with special characters like = or spaces are quoted):

    gcc -c -o foo.o -O2 '-std=c99' -Ipath/include foo.c
  • On Windows (Only strings with characters like spaces or " are quoted):

    gcc -c -o foo.o -O2 -std=c99 -Ipath/include foo.c

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License