isolate

package
v0.0.0-...-1643519 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package isolate implements the code to process '.isolate' files to generate '.isolated' files.

Index

Constants

View Source
const IsolatedGenJSONVersion = 1

IsolatedGenJSONVersion is used in the batcharchive json format.

TODO(tandrii): Migrate to batch_archive.go.

View Source
const ValidVariable = "[A-Za-z_][A-Za-z_0-9]*"

ValidVariable is the regexp of valid isolate variable name.

Variables

This section is empty.

Functions

func Archive

func Archive(arch *archiver.Archiver, opts *ArchiveOptions) *archiver.PendingItem

Archive processes a .isolate, generates a .isolated and archive it. Returns a *PendingItem to the .isolated.

func IsValidVariable

func IsValidVariable(variable string) bool

IsValidVariable returns true if the variable is a valid symbol name.

func IsWindows

func IsWindows() bool

IsWindows returns True when running on the best OS there is.

func ProcessIsolate

func ProcessIsolate(opts *ArchiveOptions) ([]string, string, *isolated.Isolated, error)

ProcessIsolate parses an isolate file, returning the list of dependencies (both files and directories), the root directory and the initial Isolated struct.

func ReplaceVariables

func ReplaceVariables(str string, opts *ArchiveOptions) (string, error)

ReplaceVariables replaces any occurrences of '<(FOO)' in 'str' with the corresponding variable from 'opts'.

If any substitution refers to a variable that is missing, the returned error will refer to the first such variable. In the case of errors, the returned string will still contain a valid result for any non-missing substitutions.

Types

type ArchiveOptions

type ArchiveOptions struct {
	Isolate         string              `json:"isolate"`
	Isolated        string              `json:"isolated"`
	Blacklist       stringlistflag.Flag `json:"blacklist"`
	PathVariables   stringmapflag.Value `json:"path_variables"`
	ExtraVariables  stringmapflag.Value `json:"extra_variables"`
	ConfigVariables stringmapflag.Value `json:"config_variables"`
}

ArchiveOptions for achiving trees.

func (*ArchiveOptions) Init

func (a *ArchiveOptions) Init()

Init initializes with non-nil values.

func (*ArchiveOptions) PostProcess

func (a *ArchiveOptions) PostProcess(cwd string)

PostProcess post-processes the flags to fix any compatibility issue.

type ConfigSettings

type ConfigSettings struct {
	// Files is the list of dependencies. The items use '/' as a path separator.
	Files []string
	// Command is the actual command to run.
	Command []string
	// ReadOnly describes how to map the files.
	ReadOnly ReadOnlyValue
	// IsolateDir is the path where to start the command from.
	// It uses the OS' native path separator and it must be an absolute path.
	IsolateDir string
}

ConfigSettings represents the dependency variables for a single build configuration.

The structure is immutable.

type Configs

type Configs struct {
	// ConfigVariables contains names only, sorted by name; the order is same as in byConfig.
	ConfigVariables []string
	// contains filtered or unexported fields
}

Configs represents a processed .isolate file.

Stores the file in a processed way, split by configuration.

At this point, we don't know all the possibilities. So mount a partial view that we have.

This class doesn't hold isolateDir, since it is dependent on the final configuration selected. It is implicitly dependent on which .isolate defines the 'command' that will take effect.

func LoadIsolateAsConfig

func LoadIsolateAsConfig(isolateDir string, content []byte) (*Configs, error)

LoadIsolateAsConfig parses one .isolate file and returns a Configs instance.

Arguments:
  isolateDir: only used to load relative includes so it doesn't depend on
              cwd.
  value: is the loaded dictionary that was defined in the gyp file.

The expected format is strict, anything diverting from the format below will
result in error:
{
  'includes': [
    'foo.isolate',
  ],
  'conditions': [
    ['OS=="vms" and foo=42', {
      'variables': {
        'command': [
          ...
        ],
        'files': [
          ...
        ],
        'read_only': 0,
      },
    }],
    ...
  ],
  'variables': {
    ...
  },
}

func (*Configs) GetConfig

func (c *Configs) GetConfig(configName configName) (*ConfigSettings, error)

GetConfig returns all configs that matches this config as a single ConfigSettings.

Returns nil if none apply.

type ReadOnlyValue

type ReadOnlyValue int

ReadOnlyValue defines permissions on isolated files.

const (
	NotSet        ReadOnlyValue = -1
	Writeable     ReadOnlyValue = 0
	FilesReadOnly ReadOnlyValue = 1
	DirsReadOnly  ReadOnlyValue = 2
)

Possible kinds of read only values.

func LoadIsolateForConfig

func LoadIsolateForConfig(isolateDir string, content []byte, configVariables map[string]string) (
	[]string, []string, ReadOnlyValue, string, error)

LoadIsolateForConfig loads the .isolate file and returns the information unprocessed but filtered for the specific OS.

Returns:

command, dependencies, readOnly flag, relDir, error.

relDir and dependencies are fixed to use os.PathSeparator.

func (ReadOnlyValue) ToIsolated

func (r ReadOnlyValue) ToIsolated() (out *isolated.ReadOnlyValue)

ToIsolated can be used to convert ReadOnlyValue enum values to corresponding isolated.ReadOnlyValue enum values. It returns nil on errors.

type Tree

type Tree struct {
	Cwd  string
	Opts ArchiveOptions
}

Tree to be isolated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL