xref: /aosp_15_r20/build/soong/cmd/sbox/sbox_proto/sbox.proto (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1*333d2b36SAndroid Build Coastguard Worker// Copyright 2020 Google Inc. All Rights Reserved.
2*333d2b36SAndroid Build Coastguard Worker//
3*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*333d2b36SAndroid Build Coastguard Worker//
7*333d2b36SAndroid Build Coastguard Worker//   http://www.apache.org/licenses/LICENSE-2.0
8*333d2b36SAndroid Build Coastguard Worker//
9*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*333d2b36SAndroid Build Coastguard Worker// limitations under the License.
14*333d2b36SAndroid Build Coastguard Worker
15*333d2b36SAndroid Build Coastguard Workersyntax = "proto2";
16*333d2b36SAndroid Build Coastguard Worker
17*333d2b36SAndroid Build Coastguard Workerpackage sbox;
18*333d2b36SAndroid Build Coastguard Workeroption go_package = "android/soong/cmd/sbox/sbox_proto";
19*333d2b36SAndroid Build Coastguard Worker
20*333d2b36SAndroid Build Coastguard Worker// A set of commands to run in a sandbox.
21*333d2b36SAndroid Build Coastguard Workermessage Manifest {
22*333d2b36SAndroid Build Coastguard Worker  // A list of commands to run in the sandbox.
23*333d2b36SAndroid Build Coastguard Worker  repeated Command commands = 1;
24*333d2b36SAndroid Build Coastguard Worker
25*333d2b36SAndroid Build Coastguard Worker  // If set, GCC-style dependency files from any command that references __SBOX_DEPFILE__ will be
26*333d2b36SAndroid Build Coastguard Worker  // merged into the given output file relative to the $PWD when sbox was started.
27*333d2b36SAndroid Build Coastguard Worker  optional string output_depfile = 2;
28*333d2b36SAndroid Build Coastguard Worker}
29*333d2b36SAndroid Build Coastguard Worker
30*333d2b36SAndroid Build Coastguard Worker// SandboxManifest describes a command to run in the sandbox.
31*333d2b36SAndroid Build Coastguard Workermessage Command {
32*333d2b36SAndroid Build Coastguard Worker  // A list of copy rules to run before the sandboxed command.  The from field is relative to the
33*333d2b36SAndroid Build Coastguard Worker  // $PWD when sbox was run, the to field is relative to the top of the temporary sandbox directory.
34*333d2b36SAndroid Build Coastguard Worker  repeated Copy copy_before = 1;
35*333d2b36SAndroid Build Coastguard Worker
36*333d2b36SAndroid Build Coastguard Worker  // If true, change the working directory to the top of the temporary sandbox directory before
37*333d2b36SAndroid Build Coastguard Worker  // running the command.  If false, leave the working directory where it was when sbox was started.
38*333d2b36SAndroid Build Coastguard Worker  optional bool chdir = 2;
39*333d2b36SAndroid Build Coastguard Worker
40*333d2b36SAndroid Build Coastguard Worker  // The command to run.
41*333d2b36SAndroid Build Coastguard Worker  required string command = 3;
42*333d2b36SAndroid Build Coastguard Worker
43*333d2b36SAndroid Build Coastguard Worker  // A list of copy rules to run after the sandboxed command.  The from field is relative to the
44*333d2b36SAndroid Build Coastguard Worker  // top of the temporary sandbox directory, the to field is relative to the $PWD when sbox was run.
45*333d2b36SAndroid Build Coastguard Worker  repeated Copy copy_after = 4;
46*333d2b36SAndroid Build Coastguard Worker
47*333d2b36SAndroid Build Coastguard Worker  // An optional hash of the input files to ensure the textproto files and the sbox rule reruns
48*333d2b36SAndroid Build Coastguard Worker  // when the lists of inputs changes, even if the inputs are not on the command line.
49*333d2b36SAndroid Build Coastguard Worker  optional string input_hash = 5;
50*333d2b36SAndroid Build Coastguard Worker
51*333d2b36SAndroid Build Coastguard Worker  // A list of files that will be copied before the sandboxed command, and whose contents should be
52*333d2b36SAndroid Build Coastguard Worker  // copied as if they were listed in copy_before.
53*333d2b36SAndroid Build Coastguard Worker  repeated RspFile rsp_files = 6;
54*333d2b36SAndroid Build Coastguard Worker
55*333d2b36SAndroid Build Coastguard Worker  // The environment variables that will be set or unset while running the command.
56*333d2b36SAndroid Build Coastguard Worker  // Also see dont_inherit_env.
57*333d2b36SAndroid Build Coastguard Worker  repeated EnvironmentVariable env = 7;
58*333d2b36SAndroid Build Coastguard Worker
59*333d2b36SAndroid Build Coastguard Worker  // By default, all environment variables are inherited from the calling process, but may be
60*333d2b36SAndroid Build Coastguard Worker  // replaced or unset by env. If dont_inherit_env is set, no environment variables will be
61*333d2b36SAndroid Build Coastguard Worker  // inherited, and instead only the variables in env will be defined.
62*333d2b36SAndroid Build Coastguard Worker  optional bool dont_inherit_env = 8;
63*333d2b36SAndroid Build Coastguard Worker}
64*333d2b36SAndroid Build Coastguard Worker
65*333d2b36SAndroid Build Coastguard Workermessage EnvironmentVariable {
66*333d2b36SAndroid Build Coastguard Worker  // The name of the environment variable
67*333d2b36SAndroid Build Coastguard Worker  required string name = 1;
68*333d2b36SAndroid Build Coastguard Worker  oneof state {
69*333d2b36SAndroid Build Coastguard Worker    // The value to set the environment variable to.
70*333d2b36SAndroid Build Coastguard Worker    string value = 2;
71*333d2b36SAndroid Build Coastguard Worker    // This environment variable should be unset in the command.
72*333d2b36SAndroid Build Coastguard Worker    bool unset = 3;
73*333d2b36SAndroid Build Coastguard Worker    // This environment variable should be inherited from the parent process.
74*333d2b36SAndroid Build Coastguard Worker    // Can be combined with dont_inherit_env to only inherit certain environment
75*333d2b36SAndroid Build Coastguard Worker    // variables.
76*333d2b36SAndroid Build Coastguard Worker    bool inherit = 4;
77*333d2b36SAndroid Build Coastguard Worker  }
78*333d2b36SAndroid Build Coastguard Worker}
79*333d2b36SAndroid Build Coastguard Worker
80*333d2b36SAndroid Build Coastguard Worker// Copy describes a from-to pair of files to copy.  The paths may be relative, the root that they
81*333d2b36SAndroid Build Coastguard Worker// are relative to is specific to the context the Copy is used in and will be different for
82*333d2b36SAndroid Build Coastguard Worker// from and to.
83*333d2b36SAndroid Build Coastguard Workermessage Copy {
84*333d2b36SAndroid Build Coastguard Worker  required string from = 1;
85*333d2b36SAndroid Build Coastguard Worker  required string to = 2;
86*333d2b36SAndroid Build Coastguard Worker
87*333d2b36SAndroid Build Coastguard Worker  // If true, make the file executable after copying it.
88*333d2b36SAndroid Build Coastguard Worker  optional bool executable = 3;
89*333d2b36SAndroid Build Coastguard Worker}
90*333d2b36SAndroid Build Coastguard Worker
91*333d2b36SAndroid Build Coastguard Worker// RspFile describes an rspfile that should be copied into the sandbox directory.
92*333d2b36SAndroid Build Coastguard Workermessage RspFile {
93*333d2b36SAndroid Build Coastguard Worker  // The path to the rsp file.
94*333d2b36SAndroid Build Coastguard Worker  required string file = 1;
95*333d2b36SAndroid Build Coastguard Worker
96*333d2b36SAndroid Build Coastguard Worker  // A list of path mappings that should be applied to each file listed in the rsp file.
97*333d2b36SAndroid Build Coastguard Worker  repeated PathMapping path_mappings = 2;
98*333d2b36SAndroid Build Coastguard Worker}
99*333d2b36SAndroid Build Coastguard Worker
100*333d2b36SAndroid Build Coastguard Worker// PathMapping describes a mapping from a path outside the sandbox to the path inside the sandbox.
101*333d2b36SAndroid Build Coastguard Workermessage PathMapping {
102*333d2b36SAndroid Build Coastguard Worker  required string from = 1;
103*333d2b36SAndroid Build Coastguard Worker  required string to = 2;
104*333d2b36SAndroid Build Coastguard Worker}
105