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