sbox.proto 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. syntax = "proto2";
  15. package sbox;
  16. option go_package = "sbox_proto";
  17. // A set of commands to run in a sandbox.
  18. message Manifest {
  19. // A list of commands to run in the sandbox.
  20. repeated Command commands = 1;
  21. // If set, GCC-style dependency files from any command that references __SBOX_DEPFILE__ will be
  22. // merged into the given output file relative to the $PWD when sbox was started.
  23. optional string output_depfile = 2;
  24. }
  25. // SandboxManifest describes a command to run in the sandbox.
  26. message Command {
  27. // A list of copy rules to run before the sandboxed command. The from field is relative to the
  28. // $PWD when sbox was run, the to field is relative to the top of the temporary sandbox directory.
  29. repeated Copy copy_before = 1;
  30. // If true, change the working directory to the top of the temporary sandbox directory before
  31. // running the command. If false, leave the working directory where it was when sbox was started.
  32. optional bool chdir = 2;
  33. // The command to run.
  34. required string command = 3;
  35. // A list of copy rules to run after the sandboxed command. The from field is relative to the
  36. // top of the temporary sandbox directory, the to field is relative to the $PWD when sbox was run.
  37. repeated Copy copy_after = 4;
  38. // An optional hash of the input files to ensure the textproto files and the sbox rule reruns
  39. // when the lists of inputs changes, even if the inputs are not on the command line.
  40. optional string input_hash = 5;
  41. // A list of files that will be copied before the sandboxed command, and whose contents should be
  42. // copied as if they were listed in copy_before.
  43. repeated RspFile rsp_files = 6;
  44. }
  45. // Copy describes a from-to pair of files to copy. The paths may be relative, the root that they
  46. // are relative to is specific to the context the Copy is used in and will be different for
  47. // from and to.
  48. message Copy {
  49. required string from = 1;
  50. required string to = 2;
  51. // If true, make the file executable after copying it.
  52. optional bool executable = 3;
  53. }
  54. // RspFile describes an rspfile that should be copied into the sandbox directory.
  55. message RspFile {
  56. // The path to the rsp file.
  57. required string file = 1;
  58. // A list of path mappings that should be applied to each file listed in the rsp file.
  59. repeated PathMapping path_mappings = 2;
  60. }
  61. // PathMapping describes a mapping from a path outside the sandbox to the path inside the sandbox.
  62. message PathMapping {
  63. required string from = 1;
  64. required string to = 2;
  65. }