// Main task entry point. public override bool Execute() { base.UseCommandProcessor = false; bool ok = base.Execute(); if (!ok) { return(false); } // Read dependency output file from the compiler to retrieve the // definitive list of created files. Report the dependency file // itself as having been written to. if (DependencyOut != null) { string[] outputs = DepFileUtil.ReadDependencyOutputs(DependencyOut, Log); if (HasLoggedErrors) { return(false); } GeneratedFiles = new ITaskItem[outputs.Length]; for (int i = 0; i < outputs.Length; i++) { GeneratedFiles[i] = new TaskItem(outputs[i]); } AdditionalFileWrites = new ITaskItem[] { new TaskItem(DependencyOut) }; } return(true); }
public override bool Execute() { // Read dependency files, where available. There might be none, // just use a best effort. if (ProtoDepDir != null) { var dependencies = new List <ITaskItem>(); foreach (var proto in Protobuf) { string[] deps = DepFileUtil.ReadDependencyInputs(ProtoDepDir, proto.ItemSpec, Log); foreach (string dep in deps) { var ti = new TaskItem(dep); ti.SetMetadata(Metadata.Source, proto.ItemSpec); dependencies.Add(ti); } } Dependencies = dependencies.ToArray(); } else { Dependencies = new ITaskItem[0]; } return(!Log.HasLoggedErrors); }
// Called by base class to validate arguments and make them consistent. protected override bool ValidateParameters() { // Part of proto command line switches, must be lowercased. Generator = Generator.ToLowerInvariant(); if (!System.Array.Exists(s_supportedGenerators, g => g == Generator)) { Log.LogError("Invalid value for Generator='{0}'. Supported generators: {1}", Generator, string.Join(", ", s_supportedGenerators)); } if (ProtoDepDir != null && DependencyOut != null) { Log.LogError("Properties ProtoDepDir and DependencyOut may not be both specified"); } if (Protobuf.Length > 1 && (ProtoDepDir != null || DependencyOut != null)) { Log.LogError("Proto compiler currently allows only one input when " + "--dependency_out is specified (via ProtoDepDir or DependencyOut). " + "Tracking issue: https://github.com/google/protobuf/pull/3959"); } // Use ProtoDepDir to autogenerate DependencyOut if (ProtoDepDir != null) { DependencyOut = DepFileUtil.GetDepFilenameForProto(ProtoDepDir, Protobuf[0].ItemSpec); } if (GrpcPluginExe == null) { GrpcOutputOptions = null; GrpcOutputDir = null; } else if (GrpcOutputDir == null) { // Use OutputDir for gRPC output if not specified otherwise by user. GrpcOutputDir = OutputDir; } return(!Log.HasLoggedErrors && base.ValidateParameters()); }