Search in sources :

Example 1 with BuildData

use of com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData in project bazel by bazelbuild.

the class DashModule method gotOptions.

@Subscribe
public void gotOptions(GotOptionsEvent event) {
    BuildData.Builder builder = BuildData.newBuilder();
    BuildData.CommandLine.Builder cmdLineBuilder = BuildData.CommandLine.newBuilder();
    for (UnparsedOptionValueDescription option : event.getStartupOptions().asListOfUnparsedOptions()) {
        cmdLineBuilder.addStartupOptions(getOption(option));
    }
    for (UnparsedOptionValueDescription option : event.getOptions().asListOfUnparsedOptions()) {
        if (option.getName().equals("client_env")) {
            String[] env = option.getUnparsedValue().split("=");
            if (env.length == 1) {
                builder.addClientEnv(EnvironmentVar.newBuilder().setName(env[0]).setValue("true").build());
            } else if (env.length == 2) {
                builder.addClientEnv(EnvironmentVar.newBuilder().setName(env[0]).setValue(env[1]).build());
            }
        } else {
            cmdLineBuilder.addOptions(getOption(option));
        }
    }
    for (String residue : event.getOptions().getResidue()) {
        cmdLineBuilder.addResidue(residue);
    }
    builder.setCommandLine(cmdLineBuilder.build());
    // This can be called before handleOptions, so the BuildData is stored until we know if it
    // should be sent somewhere.
    optionsBuildData = builder.build();
}
Also used : BuildData(com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData) UnparsedOptionValueDescription(com.google.devtools.common.options.OptionsParser.UnparsedOptionValueDescription) ByteString(com.google.protobuf.ByteString) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)1 BuildData (com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData)1 UnparsedOptionValueDescription (com.google.devtools.common.options.OptionsParser.UnparsedOptionValueDescription)1 ByteString (com.google.protobuf.ByteString)1