run_add()
def run_add(name, deps, apply_trailing_args_to, help, type, platforms, visibility)Adds a rule to the workspace with no associated command.
This rule can be used to consolidate dependencies into a single rule.
Args
name: string: The name of the rule.deps: list: List of dependencies for the target.apply_trailing_args_to: The name of the rule that will get command line trailing args when this rule is run directly.help: The help message for the rule.type: See run_add_exec()platforms: List of platforms to build the target for (default is all).visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.
run_add_archive()
def run_add_archive(name, archive_name, deps, version, source_directory, suffix, includes, excludes, platform, visibility)Adds an archive target to the workspace.
This rule can be used to consolidate dependencies into a single target.
Args
name: string: The name of the rule.archive_name: string: The base name of the archive that will be createddeps: list: List of dependencies to run withspaces runversion: string: The version of the archive.source_directory: string: The directory containing the source files to archive.suffix: string: The archive suffix (tar.gz or zip for examples)includes: List of globs to include in the archive.excludes: List of globs to exclude from the archive.platform: The platform to build the target for (default is all).visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.
Returns
A tuple containing (
run_add_exec()
def run_add_exec(name, command, help, args, env, deps, inputs, apply_trailing_args_to, target_files, target_dirs, type, working_directory, platforms, log_level, redirect_stdout, timeout, visibility, expect)Adds a command to the run dependency graph
Args
name: string: The name of the rule.command: string: The command to execute.help: The help message for the rule.args: list: The arguments to pass to the command.env: dict: key value pairs of environment variablesdeps: list: The rule dependencies that must be run before this commandinputs: List of globs to specify the inputs. If the inputs are unchanged, the command will not run.apply_trailing_args_to: The name of the rule that will receive command line trailing args when this rule is run directly.target_files: A list of files created by this ruletarget_dirs: A list of directories populated by this ruletype: The exec type (Run|Setup|Optional (default)|PreCommit|Clean|Test)working_directory: The directory to run the command (default is workspace root).platforms: Platforms to run on (default is all).log_level: The log level to use None|App|Passthroughredirect_stdout: The file to redirect stdout to (prefer to parse the log file).timeout: Number of seconds to run before sending a kill signal.visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.expect: string: The expected result of the command Success|Failure|Any. (default is Success)
run_add_exec_clean()
def run_add_exec_clean(name, command, help, args, env, deps, inputs, apply_trailing_args_to, working_directory, platforms, log_level, redirect_stdout, timeout, visibility, expect)Adds a command as a clean rule.
All test rules can be executed with:
spaces run //:cleanArgs
name: string: The name of the rule.command: string: The command to execute.help: The help message for the rule.args: list: The arguments to pass to the commandenv: dict: key value pairs of environment variablesdeps: list: The rule dependenciesinputs: List of globs to specify the inputs. If the inputs are unchanged, the command will not run.apply_trailing_args_to: The name of the rule that will receive command line trailing args when this rule is run directly.working_directory: The directory to run the command (default is workspace root).platforms: Platforms to run on (default is all).log_level: The log level to use None|Appredirect_stdout: The file to redirect stdout to (prefer to parse the log file).timeout: Number of seconds to run before sending a kill signal.visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.expect: string: The expected result of the command Success|Failure|Any. (default is Success)
run_add_exec_precommit()
def run_add_exec_precommit(name, command, help, args, env, deps, inputs, apply_trailing_args_to, working_directory, platforms, log_level, redirect_stdout, timeout, visibility, expect)Adds a command as a pre-commit rule.
All pre-commit rules can be executed with:
spaces run //:pre-commitArgs
name: string: The name of the rule.command: string: The command to execute.help: The help message for the rule.args: list: The arguments to pass to the commandenv: dict: key value pairs of environment variablesdeps: list: The rule dependenciesinputs: List of globs to specify the inputs. If the inputs are unchanged, the command will not run.apply_trailing_args_to: The name of the rule that will receive command line trailing args when this rule is run directly.working_directory: The directory to run the command (default is workspace root).platforms: Platforms to run on (default is all).log_level: The log level to use None|Appredirect_stdout: The file to redirect stdout to (prefer to parse the log file).timeout: Number of seconds to run before sending a kill signal.visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.expect: string: The expected result of the command Success|Failure|Any. (default is Success)
run_add_exec_setup()
def run_add_exec_setup(name, command, help, args, env, deps, apply_trailing_args_to, working_directory, platforms, log_level, redirect_stdout, timeout, visibility, expect)Adds a command as a setup rule. It will run only once and all run rules will depend on it.
All setup rules can be executed with:
spaces run //:setupArgs
name: string: The name of the rule.command: string: The command to execute.help: The help message for the rule.args: list: The arguments to pass to the commandenv: dict: key value pairs of environment variablesdeps: list: The rule dependenciesapply_trailing_args_to: The name of the rule that will receive command line trailing args when this rule is run directly.working_directory: The directory to run the command (default is workspace root).platforms: Platforms to run on (default is all).log_level: The log level to use None|Appredirect_stdout: The file to redirect stdout to (prefer to parse the log file).timeout: Number of seconds to run before sending a kill signal.visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.expect: string: The expected result of the command Success|Failure|Any. (default is Success)
run_add_exec_test()
def run_add_exec_test(name, command, help, args, env, deps, inputs, apply_trailing_args_to, working_directory, platforms, log_level, redirect_stdout, timeout, visibility, expect)Adds a command as a test rule.
All test rules can be executed with:
spaces run //:testArgs
name: string: The name of the rule.command: string: The command to execute.help: The help message for the rule.args: list: The arguments to pass to the commandenv: dict: key value pairs of environment variablesdeps: list: The rule dependenciesinputs: List of globs to specify the inputs. If the inputs are unchanged, the command will not run.apply_trailing_args_to: The name of the rule that will receive command line trailing args when this rule is run directly.working_directory: The directory to run the command (default is workspace root).platforms: Platforms to run on (default is all).log_level: The log level to use None|Appredirect_stdout: The file to redirect stdout to (prefer to parse the log file).timeout: Number of seconds to run before sending a kill signal.visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.expect: string: The expected result of the command Success|Failure|Any. (default is Success)
run_add_kill_exec()
def run_add_kill_exec(name, target, signal, help, expect, deps, type, platforms, visibility)Adds a target that will send a signal to another target.
Args
name: string: The name of the rule.target: string: The name of the rule to kill.signal: string: The signal to send to the target.help: The help message for the rule.expect: string: The expected result of the kill. (default is Success)deps: list: Run rule dependencies.type: See run_add_exec()platforms: Platforms to run on (default is all).visibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.
run_add_to_all()
def run_add_to_all(name, deps, visibility)Creates a target rule called name with deps and part of :all.
Targets will run with spaces run or spaces run //:all.
Args
name: string: The name of the rule.deps: list: List of dependencies to run withspaces runvisibility: Rule visibility:Public|Private|Rules[]. See visibility.star for more info.
run_expect_any()
def run_expect_any()Expect the command to succeed or fail.
spaces exits successfully if the command succeeds or fails.
Returns
str: “Any”
run_expect_failure()
def run_expect_failure()Expect the command to fail.
If the command fails and is expected to fail, spaces exits successfully.
Returns
str: “Failure”
run_expect_success()
def run_expect_success()Expect the command to succeed
Returns
str: “Success”
run_inputs_always()
def run_inputs_always()Assign inputs to None to run the command every time.
Returns
None
run_inputs_once()
def run_inputs_once()Assign inputs to [] to run the command once.
Returns
list: []
run_load_env()
def run_load_env(key) -> stringLoad the value of an environment variable when the rule is executed.
Args
key: string:
Returns
str: A token that will be replaced with the value of the environment variable at execution time.
run_load_exit_code()
def run_load_exit_code(rule) -> stringLoad the exit code of a previous run rule and return it as a string.
The file will be automatically added to the rule dependencies.
Args
rule: string:
Returns
str: The contents of the file.
run_load_file_contents()
def run_load_file_contents(path) -> stringLoad the contents of a file and return it as a string.
The file will be automatically added to the rule dependencies.
Args
path: string:
Returns
str: The contents of the file.
run_log_level_app()
def run_log_level_app()Print the output of the run rule while running spaces
Returns
str: “App”
run_log_level_passthrough()
def run_log_level_passthrough()Print the output of the run rule while running spaces with no additional markings
Returns
str: “Passthrough”
run_signal_abort()
def run_signal_abort()Gets the Abort signal
run_signal_alarm()
def run_signal_alarm()Gets the Alarm signal
run_signal_hup()
def run_signal_hup()Gets the Hangup signal
run_signal_int()
def run_signal_int()Gets the Interrupt signal
run_signal_kill()
def run_signal_kill()Gets the Kill signal
run_signal_quit()
def run_signal_quit()Gets the Quit signal
run_signal_terminate()
def run_signal_terminate()Gets the Terminate signal
run_signal_user1()
def run_signal_user1()Gets the User1 signal
run_signal_user2()
def run_signal_user2()Gets the User2 signal
run_type_all()
def run_type_all()Assign type to Run to run the command with spaces run.
The rules marked as Run are part of the //:all target.
spaces run //:allReturns
str: “Run”
run_type_precommit()
def run_type_precommit()The rules added as PreCommit are part of the //:pre-commit target.
spaces run //:pre-commitReturns
str: “PreCommit”
run_type_setup()
def run_type_setup()The rules added as Setup are part of the //:setup target.
spaces run //:setupReturns
str: “Setup”
run_type_test()
def run_type_test()The rules added as Test are part of the //:test target.
spaces run //:testReturns
str: “Test”