public WorkerGenerationJob(CodegenJobOptions options, IFileSystem fileSystem, DetailsStore detailsStore) : base(options.AsEditor(), fileSystem, detailsStore) { const string jobName = nameof(WorkerGenerationJob); Logger.Trace($"Initialising {jobName}."); var workerTypesToGenerate = ExtractWorkerTypes(CodeGeneratorOptions.Instance.WorkerJsonDirectory); Logger.Trace($"Adding job target {WorkerFileName}."); AddJobTarget(Path.Combine(relativeEditorPath, WorkerFileName), () => UnityWorkerMenuGenerator.Generate(workerTypesToGenerate)); Logger.Trace($"Adding job target for {BuildSystemFileName}."); AddJobTarget(Path.Combine(relativeEditorPath, BuildSystemFileName), () => BuildSystemAssemblyGenerator.Generate()); Logger.Trace($"Adding job target for {WorkerListFileName}."); AddJobTarget(Path.Combine(relativeOutputPath, WorkerListFileName), () => string.Join(Environment.NewLine, workerTypesToGenerate)); Logger.Trace($"Finished initialising {jobName}."); }
public ComponentVisualElementJob(CodegenJobOptions options, IFileSystem fileSystem, DetailsStore detailsStore) : base(options.AsEditor(), fileSystem, detailsStore) { const string jobName = nameof(ComponentVisualElementJob); Logger.Trace($"Initialising {jobName}."); Logger.Trace($"Adding job target for {DebugAsmdefFileName}"); AddJobTarget(Path.Combine(relativeOutputPath, DebugAsmdefFileName), () => DebugAssemblyGenerator.Generate()); var componentsToGenerate = detailsStore.Components.Values.ToList(); var componentGenerator = new ComponentVisualElementGenerator(detailsStore); AddGenerators(relativeOutputPath, componentsToGenerate, component => ($"{component.Name}Renderer.cs", componentGenerator.Generate)); Logger.Trace($"Added job targets for {componentsToGenerate.Count} components"); // Types Logger.Trace("Gathering nested types."); var allNestedTypes = detailsStore.Types .SelectMany(kv => detailsStore.GetNestedTypes(kv.Key)) .ToHashSet(); Logger.Trace("Gathering types details."); var typesToGenerate = detailsStore.Types .Where(kv => !allNestedTypes.Contains(kv.Key)) .Select(kv => kv.Value) .ToList(); var typeGenerator = new TypeVisualElementGenerator(detailsStore); AddGenerators(relativeOutputPath, typesToGenerate, type => ($"{type.Name}Renderer.cs", typeGenerator.Generate)); Logger.Trace($"Added job targets for {typesToGenerate.Count} types"); }