blob: d6588bb3e5fb8d06eb1eebae25edc1a1029d8ce0 [file] [log] [blame]
fellyc986d762019-06-04 10:00:16 -07001// Copyright 2019 The Bazel Authors. 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
15package com.google.devtools.build.lib.runtime;
16
17import com.google.common.collect.ImmutableList;
18import com.google.devtools.build.lib.buildeventstream.BuildEvent;
19import com.google.devtools.build.lib.buildeventstream.BuildEventContext;
20import com.google.devtools.build.lib.buildeventstream.BuildEventId;
21import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
22import com.google.devtools.build.lib.vfs.Path;
23import java.util.Collection;
24
25/** An event that receives the execRoot of this blaze invocation. */
26public class ExecRootEvent implements BuildEvent {
27
28 private final Path execRoot;
29
30 public ExecRootEvent(Path execRoot) {
31 this.execRoot = execRoot;
32 }
33
34 @Override
35 public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventContext context) {
36 BuildEventStreamProtos.WorkspaceConfig workspaceConfigEvent =
37 BuildEventStreamProtos.WorkspaceConfig.newBuilder()
38 .setLocalExecRoot(execRoot.getPathString())
39 .build();
40 return BuildEventStreamProtos.BuildEvent.newBuilder()
41 .setId(getEventId().asStreamProto())
42 .setWorkspaceInfo(workspaceConfigEvent)
43 .build();
44 }
45
46 @Override
47 public BuildEventId getEventId() {
48 return BuildEventId.workspaceConfigId();
49 }
50
51 @Override
52 public Collection<BuildEventId> getChildrenEvents() {
53 return ImmutableList.of();
54 }
55}