xref: /aosp_15_r20/build/make/tools/rbcrun/README.md (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1*9e94795aSAndroid Build Coastguard Worker# Roboleaf configuration files interpreter
2*9e94795aSAndroid Build Coastguard Worker
3*9e94795aSAndroid Build Coastguard WorkerReads and executes Roboleaf product configuration files.
4*9e94795aSAndroid Build Coastguard Worker
5*9e94795aSAndroid Build Coastguard Worker## Usage
6*9e94795aSAndroid Build Coastguard Worker
7*9e94795aSAndroid Build Coastguard Worker`rbcrun` *options* *VAR=value*... [ *file* ]
8*9e94795aSAndroid Build Coastguard Worker
9*9e94795aSAndroid Build Coastguard WorkerA Roboleaf configuration file is a Starlark script. Usually it is read from *file*. The option `-c` allows to provide a
10*9e94795aSAndroid Build Coastguard Workerscript directly on the command line. The option `-f` is there to allow the name of a file script to contain (`=`).
11*9e94795aSAndroid Build Coastguard Worker(i.e., `my=file.rbc` sets `my` to `file.rbc`, `-f my=file.rbc` runs the script from `my=file.rbc`).
12*9e94795aSAndroid Build Coastguard Worker
13*9e94795aSAndroid Build Coastguard Worker### Options
14*9e94795aSAndroid Build Coastguard Worker
15*9e94795aSAndroid Build Coastguard Worker`-d` *dir*\
16*9e94795aSAndroid Build Coastguard WorkerRoot directory for load("//path",...)
17*9e94795aSAndroid Build Coastguard Worker
18*9e94795aSAndroid Build Coastguard Worker`-c` *text*\
19*9e94795aSAndroid Build Coastguard WorkerRead script from *text*
20*9e94795aSAndroid Build Coastguard Worker
21*9e94795aSAndroid Build Coastguard Worker`--perf` *file*\
22*9e94795aSAndroid Build Coastguard WorkerGather performance statistics and save it to *file*. Use \
23*9e94795aSAndroid Build Coastguard Worker`       go tool prof -top`*file*\
24*9e94795aSAndroid Build Coastguard Workerto show top CPU users
25*9e94795aSAndroid Build Coastguard Worker
26*9e94795aSAndroid Build Coastguard Worker`-f` *file*\
27*9e94795aSAndroid Build Coastguard WorkerFile to run.
28*9e94795aSAndroid Build Coastguard Worker
29*9e94795aSAndroid Build Coastguard Worker## Extensions
30*9e94795aSAndroid Build Coastguard Worker
31*9e94795aSAndroid Build Coastguard WorkerThe runner allows Starlark scripts to use the following features that Bazel's Starlark interpreter does not support:
32*9e94795aSAndroid Build Coastguard Worker
33*9e94795aSAndroid Build Coastguard Worker### Load statement URI
34*9e94795aSAndroid Build Coastguard Worker
35*9e94795aSAndroid Build Coastguard WorkerStarlark does not define the format of the load statement's first argument.
36*9e94795aSAndroid Build Coastguard WorkerThe Roboleaf configuration interpreter supports the format that Bazel uses
37*9e94795aSAndroid Build Coastguard Worker(`":file"` or `"//path:file"`). In addition, it allows the URI to end with
38*9e94795aSAndroid Build Coastguard Worker`"|symbol"` which defines a single variable `symbol` with `None` value if a
39*9e94795aSAndroid Build Coastguard Workermodule does not exist. Thus,
40*9e94795aSAndroid Build Coastguard Worker
41*9e94795aSAndroid Build Coastguard Worker```
42*9e94795aSAndroid Build Coastguard Workerload(":mymodule.rbc|init", mymodule_init="init")
43*9e94795aSAndroid Build Coastguard Worker```
44*9e94795aSAndroid Build Coastguard Worker
45*9e94795aSAndroid Build Coastguard Workerwill load the module `mymodule.rbc` and export a symbol `init` in it as
46*9e94795aSAndroid Build Coastguard Worker`mymodule_init` if `mymodule.rbc` exists. If `mymodule.rbc` is missing,
47*9e94795aSAndroid Build Coastguard Worker`mymodule_init` will be set to `None`
48*9e94795aSAndroid Build Coastguard Worker
49*9e94795aSAndroid Build Coastguard Worker### Predefined Symbols
50*9e94795aSAndroid Build Coastguard Worker
51*9e94795aSAndroid Build Coastguard Worker#### rblf_env
52*9e94795aSAndroid Build Coastguard Worker
53*9e94795aSAndroid Build Coastguard WorkerA `struct` containing environment variables. E.g., `rblf_env.USER` is the username when running on Unix.
54*9e94795aSAndroid Build Coastguard Worker
55*9e94795aSAndroid Build Coastguard Worker#### rblf_cli
56*9e94795aSAndroid Build Coastguard Worker
57*9e94795aSAndroid Build Coastguard WorkerA `struct` containing the variable set by the interpreter's command line. That is, running
58*9e94795aSAndroid Build Coastguard Worker
59*9e94795aSAndroid Build Coastguard Worker```
60*9e94795aSAndroid Build Coastguard Workerrbcrun FOO=bar myfile.rbc
61*9e94795aSAndroid Build Coastguard Worker```
62*9e94795aSAndroid Build Coastguard Worker
63*9e94795aSAndroid Build Coastguard Workerwill have the value of `rblf_cli.FOO` be `"bar"`
64*9e94795aSAndroid Build Coastguard Worker
65*9e94795aSAndroid Build Coastguard Worker### Predefined Functions
66*9e94795aSAndroid Build Coastguard Worker
67*9e94795aSAndroid Build Coastguard Worker#### rblf_file_exists(*file*)
68*9e94795aSAndroid Build Coastguard Worker
69*9e94795aSAndroid Build Coastguard WorkerReturns `True`  if *file* exists
70*9e94795aSAndroid Build Coastguard Worker
71*9e94795aSAndroid Build Coastguard Worker#### rblf_find_files(*top*, *file-pattern*, only_files = 0)
72*9e94795aSAndroid Build Coastguard Worker
73*9e94795aSAndroid Build Coastguard WorkerReturns all the paths under *top* whose basename matches *pattern* (which is a shell's glob pattern). If *only_files* is
74*9e94795aSAndroid Build Coastguard Workernot zero, only the paths to the regular files are returned. The returned paths are relative to *top*.
75*9e94795aSAndroid Build Coastguard Worker
76*9e94795aSAndroid Build Coastguard Worker#### rblf_wildcard(*glob*, *top* = None)
77*9e94795aSAndroid Build Coastguard Worker
78*9e94795aSAndroid Build Coastguard WorkerExpands *glob*. If *top* is supplied, expands "*top*/*glob*", then removes
79*9e94795aSAndroid Build Coastguard Worker"*top*/" prefix from the matching file names.
80*9e94795aSAndroid Build Coastguard Worker
81*9e94795aSAndroid Build Coastguard Worker#### rblf_regex(*pattern*, *text*)
82*9e94795aSAndroid Build Coastguard Worker
83*9e94795aSAndroid Build Coastguard WorkerReturns *True* if *text* matches *pattern*.
84*9e94795aSAndroid Build Coastguard Worker
85*9e94795aSAndroid Build Coastguard Worker#### rblf_shell(*command*)
86*9e94795aSAndroid Build Coastguard Worker
87*9e94795aSAndroid Build Coastguard WorkerRuns `sh -c "`*command*`"`, reads its output, converts all newlines into spaces, chops trailing newline returns this
88*9e94795aSAndroid Build Coastguard Workerstring. This is equivalent to Make's
89*9e94795aSAndroid Build Coastguard Worker`shell` builtin function. *This function will be eventually removed*.
90*9e94795aSAndroid Build Coastguard Worker
91*9e94795aSAndroid Build Coastguard Worker#### rblf_log(*arg*,..., sep=' ')
92*9e94795aSAndroid Build Coastguard Worker
93*9e94795aSAndroid Build Coastguard WorkerSame as `print` builtin but writes to stderr.