« Prev 4.5.4 Using Subsidiary Build Scripts: The rscons Method | Table of Contents | Next » 4.6 Extending Rscons |
The
sh
build script method can be used to directly execute commands.
The sh
method accepts either a single String argument or an Array of Strings.
When an Array is given, if the array length is greater than 1, then the command
will not be executed and interpreted by the system shell.
Otherwise, it will be executed and interpreted by the system shell.
For example:
default do # Run "make" in imported "subcomponent" directory. sh "cd subcomponent; make" # Move a file around. sh "mv", "subcomponent/file with spaces.txt", "new_name.txt" end
If the command fails, rscons will normally print the error and terminate
execution.
If the :continue
option is set, then rscons will not terminate execution.
For example:
default do # This command will fail and a message will be printed. sh "false", continue: true # However, due to the :continue option being set, execution will continue. sh "echo hi" end
Options that Ruby's spawn
method accepts can also be passed in to the sh
method.
For example, to execute the given command with a different working directory,
the :chdir
option can be specified:
default do # Execute 'ls' from within the 'src' directory: sh "ls", chdir: "src" end
« Prev 4.5.4 Using Subsidiary Build Scripts: The rscons Method | Table of Contents | Next » 4.6 Extending Rscons |