depgraph: begin transition build_target => sysroot

Also make sysroot optional, since there are times when a recipe needs
the SDK, and does not need a sysrpoot.

BUG=chromium:1081828, chromium:1053703
TEST=generate

Cq-Depend: chromium:2197226
Change-Id: I95ee83e9db5af215996bac30d3ae09bff7cd7d75
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra/proto/+/2197281
Tested-by: LaMont Jones <lamontjones@chromium.org>
Commit-Queue: LaMont Jones <lamontjones@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
diff --git a/go/chromite/api/depgraph.pb.go b/go/chromite/api/depgraph.pb.go
index 15bb44b..86499b7 100644
--- a/go/chromite/api/depgraph.pb.go
+++ b/go/chromite/api/depgraph.pb.go
@@ -28,14 +28,18 @@
 // Message contains data about the portage dependency graph and the packages'
 // dependency source paths.
 type DepGraph struct {
-	// The board whose dependency graph is being created for.
+	// TODO(crbug/1081828): drop when no longer used.  Use sysroot instead.
+	// The board whose dependency graph this is.
 	BuildTarget *chromiumos.BuildTarget `protobuf:"bytes,1,opt,name=build_target,json=buildTarget,proto3" json:"build_target,omitempty"`
 	// List of packages in the dependency graph and their infos, which include
 	// dependency packages and the source paths.
-	PackageDeps          []*PackageDepInfo `protobuf:"bytes,2,rep,name=package_deps,json=packageDeps,proto3" json:"package_deps,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
-	XXX_unrecognized     []byte            `json:"-"`
-	XXX_sizecache        int32             `json:"-"`
+	PackageDeps []*PackageDepInfo `protobuf:"bytes,2,rep,name=package_deps,json=packageDeps,proto3" json:"package_deps,omitempty"`
+	// The sysroot whose dependency graph is being created.  If no sysroot is
+	// being used, may be unspecified.
+	Sysroot              *Sysroot `protobuf:"bytes,3,opt,name=sysroot,proto3" json:"sysroot,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
 }
 
 func (m *DepGraph) Reset()         { *m = DepGraph{} }
@@ -77,6 +81,13 @@
 	return nil
 }
 
+func (m *DepGraph) GetSysroot() *Sysroot {
+	if m != nil {
+		return m.Sysroot
+	}
+	return nil
+}
+
 // Message describing a package and its dependencies.
 type PackageDepInfo struct {
 	// The package itself.
@@ -180,8 +191,13 @@
 // Example Json:
 // {"build_target":{"name":"board"},"output_file":"/tmp/depgraph.json"}
 type GetBuildDependencyGraphRequest struct {
-	// Required.
-	// The board whose dependency graph is being created.
+	// The sysroot whose dependency graph is being created.  If no sysroot is
+	// being used, may be unspecified.
+	Sysroot *Sysroot `protobuf:"bytes,4,opt,name=sysroot,proto3" json:"sysroot,omitempty"`
+	// TODO(crbug/1081828): drop when no longer used.
+	// DEPRECATED: Use sysroot instead.
+	// The board whose dependency graph is being created.  If both sysroot and
+	// build_target are given, sysroot is used.
 	BuildTarget *chromiumos.BuildTarget `protobuf:"bytes,1,opt,name=build_target,json=buildTarget,proto3" json:"build_target,omitempty"`
 	// The chroot to use to execute the endpoint.
 	Chroot *chromiumos.Chroot `protobuf:"bytes,2,opt,name=chroot,proto3" json:"chroot,omitempty"`
@@ -218,6 +234,13 @@
 
 var xxx_messageInfo_GetBuildDependencyGraphRequest proto.InternalMessageInfo
 
+func (m *GetBuildDependencyGraphRequest) GetSysroot() *Sysroot {
+	if m != nil {
+		return m.Sysroot
+	}
+	return nil
+}
+
 func (m *GetBuildDependencyGraphRequest) GetBuildTarget() *chromiumos.BuildTarget {
 	if m != nil {
 		return m.BuildTarget
@@ -380,40 +403,42 @@
 func init() { proto.RegisterFile("chromite/api/depgraph.proto", fileDescriptor_7a5308b238ddba97) }
 
 var fileDescriptor_7a5308b238ddba97 = []byte{
-	// 518 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x8b, 0xd3, 0x40,
-	0x14, 0x27, 0xad, 0x2e, 0xdd, 0x97,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, 0xeb, 0x30, 0xc6, 0x49, 0xaa, 0xee, 0xa2, 0x4a, 0x53, 0x27, 0x62, 0x1c, 0x4a, 0xc4,
-	0xf9, 0x04, 0x0f, 0xb7, 0xf8, 0x94, 0x53, 0xb9, 0x70, 0xbb, 0xd8, 0x0d, 0xe3, 0xc0, 0x6e, 0x14,
-	0xb4, 0xd1, 0xb7, 0x0e, 0x9c, 0xea, 0x84, 0x2e, 0x69, 0x76, 0x93, 0x84, 0x14, 0xdd, 0xc0, 0x60,
-	0x47, 0x7c, 0xe8, 0x45, 0xdb, 0x71, 0xff, 0x96, 0xd8, 0x2f, 0xff, 0x91, 0x5d, 0x76, 0x4f, 0xe0,
-	0x74, 0x63, 0x34, 0xf4, 0x74, 0xc3, 0x63, 0x6b, 0x86, 0xf6, 0xb3, 0x83, 0xbc, 0xe2, 0x5f, 0x6c,
-	0xf4, 0xeb, 0x8f, 0x7d, 0x02, 0xa0, 0x3f, 0x8e, 0xbb, 0xc6, 0xc5, 0xeb, 0xcf, 0xaf, 0x22, 0x56,
-	0x87, 0xee, 0xb2, 0x2c, 0xf2, 0x1a, 0x6f, 0x56, 0x92, 0x2e, 0x32, 0xec, 0xa9, 0x27, 0xcb, 0x8b,
-	0x98, 0xd7, 0x7c, 0xeb, 0xe6, 0x47, 0xea, 0x78, 0xfc, 0x37, 0x00, 0x00, 0xff, 0xff, 0x29, 0x9d,
-	0x5e, 0x27, 0x2d, 0x05, 0x00, 0x00,
+	// 551 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x30,
+	0x1c, 0x57, 0xda, 0x31, 0xba, 0x7f, 0xcb, 0xc4, 0x8c, 0x46, 0x43, 0x98, 0xa0, 0xca, 0x01, 0x26,
+	0x04, 0x89, 0xd4, 0x4a, 0x08, 0x71, 0x41, 0x1a, 0x15, 0x05, 0x71, 0xa9, 0xb2,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85, 0x5d, 0x41, 0x16, 0xe5, 0xc0, 0xfe, 0x00, 0xe6, 0x84, 0xca,
+	0x0b, 0xc6, 0x2e, 0x83, 0x08, 0xc7, 0x89, 0xda, 0xbc, 0xb2, 0x7e, 0xdd, 0x88, 0xb1, 0xab, 0x11,
+	0xfb, 0x33, 0x3c, 0x5a, 0xe3, 0x53, 0xa4, 0x72, 0xe0, 0x4e, 0x7e, 0x98, 0x8c, 0x1d, 0x87, 0x29,
+	0xa7, 0x0d, 0xbf, 0xb5, 0xe0, 0x48, 0x37, 0x74, 0x4e, 0xd3, 0xab, 0x38, 0xa0, 0xe8, 0x0a, 0xfa,
+	0x1b, 0xea, 0x43, 0x2f, 0x9b, 0x8e, 0xdb, 0x8f, 0x95, 0xf5, 0xea, 0x96, 0xec, 0x62, 0xf5, 0x04,
+	0x8e, 0x6e, 0x44, 0x43, 0xcf, 0x6e, 0x78, 0xac, 0xed, 0xd0, 0x7a, 0xbe, 0x93, 0x97, 0xcf, 0x62,
+	0xa1, 0x9f, 0xbf, 0xad, 0x43, 0x00, 0x7d, 0x9b, 0xee, 0x1b, 0x67, 0x6f, 0xbe, 0xbc, 0x0e, 0x59,
+	0x55, 0xba, 0xc3, 0xd2, 0xd0, 0xad, 0xbd, 0x8a, 0x71, 0x32, 0x4f, 0xb1, 0xab, 0x1e, 0x45, 0x37,
+	0x64, 0x6e, 0xfd, 0x2d, 0x9d, 0xed, 0xab, 0xdf, 0xa3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x58,
+	0x6b, 0x08, 0x88, 0xab, 0x05, 0x00, 0x00,
 }
 
 // Reference imports to suppress errors if they are not otherwise used.
diff --git a/src/chromite/api/depgraph.proto b/src/chromite/api/depgraph.proto
index a12fef6..63c9476 100644
--- a/src/chromite/api/depgraph.proto
+++ b/src/chromite/api/depgraph.proto
@@ -5,6 +5,7 @@
 option go_package = "go.chromium.org/chromiumos/infra/proto/go/chromite/api";
 
 import "chromite/api/build_api.proto";
+import "chromite/api/sysroot.proto";
 import "chromiumos/common.proto";
 
 
@@ -13,11 +14,16 @@
 // Message contains data about the portage dependency graph and the packages'
 // dependency source paths.
 message DepGraph {
-  // The board whose dependency graph is being created for.
+  // TODO(crbug/1081828): drop when no longer used.  Use sysroot instead.
+  // The board whose dependency graph this is.
   chromiumos.BuildTarget build_target = 1;
   // List of packages in the dependency graph and their infos, which include
   // dependency packages and the source paths.
   repeated PackageDepInfo package_deps = 2;
+
+  // The sysroot whose dependency graph is being created.  If no sysroot is
+  // being used, may be unspecified.
+  Sysroot sysroot = 3;
 }
 
 // Message describing a package and its dependencies.
@@ -37,13 +43,17 @@
   string path = 1;
 }
 
-
 // Message for creating dependency graph json map.
 // Example Json:
 // {"build_target":{"name":"board"},"output_file":"/tmp/depgraph.json"}
 message GetBuildDependencyGraphRequest {
-  // Required.
-  // The board whose dependency graph is being created.
+  // The sysroot whose dependency graph is being created.  If no sysroot is
+  // being used, may be unspecified.
+  Sysroot sysroot = 4;
+  // TODO(crbug/1081828): drop when no longer used.
+  // DEPRECATED: Use sysroot instead.
+  // The board whose dependency graph is being created.  If both sysroot and
+  // build_target are given, sysroot is used.
   chromiumos.BuildTarget build_target = 1;
   // The chroot to use to execute the endpoint.
   chromiumos.Chroot chroot = 2;