This is liable to change in the future.A
sh_binary()is used to execute a shell script.
The short name for this build target.
Either the path to the script (relative to the build file), or a build target. This file must be executable in order to be run.
A list of files or build rules that this rule requires in order to run. These could be things such as random data files.
When the script runs, the
$BUCK_DEFAULT_RUNTIME_RESOURCESenvironment variable specifies the directory that contains these resources. This directory's location is determined entirely by Buck; the script should not assume the directory's location.
$BUCK_EXTERNAL_RUNTIME_RESOURCESvariable is also defined. Resources that are targets from external cells are placed in this directory.
The resources are also made available in a tree structure that mirrors their locations in the source and
buck-outtrees. The environment variable
$BUCK_PROJECT_ROOTspecifies a directory that contains all the resources, laid out in their locations relative to the original buck project root.
List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
exported_depsattributes. For more information, see visibility.
This sh_binary() just cats a sample data file back at the user.
# $REPO/BUCK sh_binary( name = "script", main = "script.sh", resources = [ "data.dat", ], )
# Sample data file with data we need at runtime $ echo "I'm a datafile" > data.dat # Create a simple script that prints out the resource $ cat > script.sh #!/bin/sh cat $BUCK_DEFAULT_RUNTIME_RESOURCES/data.dat # Make sure the script is executable $ chmod u+x script.sh # Run the script, and see that it prints out the resource we provided $ buck run //:script Building: finished in 1.9 sec (100%) 1/1 jobs, 1 updated Total time: 2.1 sec I'm a datafile