Skip to content

Commit

Permalink
Aggregate commands includes this project commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamarao committed Feb 21, 2024
1 parent 169c5b8 commit 92df560
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static void registerMain (Project project, MetalComponent component)
task.setSource(sourceDirectory);
task.getOutput().convention(output);
});
component.getCommandFiles().from(commandsTask).builtBy(commandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(commandsTask));
}

Expand Down Expand Up @@ -98,6 +99,7 @@ static void registerTest (Project project, MetalComponent component)
task.setSource(sourceDirectory);
task.getOutput().convention(output);
});
component.getCommandFiles().from(commandsTask).builtBy(commandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(commandsTask));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.tasks.SourceTask;

import java.io.IOException;
Expand Down Expand Up @@ -148,12 +147,17 @@ public void apply (Project project)

// aggregate commands task

final var inputFiles = project.files(commandsDependencies);
final var outputFile = project.file("compile_commands.json");

project.getTasks().register("aggregateCommands",SourceTask.class).configure(task ->
{
task.dependsOn(commandsDependencies.map(Configuration::getBuildDependencies));
final var inputFiles = task.getProject().getObjects().fileCollection();
inputFiles.from(commandsDependencies);
final var application = task.getProject().getExtensions().findByType(MetalApplication.class);
if (application != null) inputFiles.from(application.getCommandFiles());
final var library = task.getProject().getExtensions().findByType(MetalLibrary.class);
if (library != null) inputFiles.from(library.getCommandFiles());

final var outputFile = task.getProject().file("compile_commands.json");

task.setGroup("metal");
task.getOutputs().file(outputFile);
task.setSource(inputFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static void registerMain (Project project, MetalComponent component)
task.setSource(sourceDirectory);
task.getOutput().convention(output);
});
component.getCommandFiles().from(commandsTask).builtBy(commandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(commandsTask));
}

Expand Down Expand Up @@ -122,6 +123,7 @@ static void registerTest (Project project, MetalComponent component)
task.setSource(sourceDirectory);
task.getOutput().convention(output);
});
component.getCommandFiles().from(commandsTask).builtBy(commandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(commandsTask));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ public abstract class MetalComponent
*/
public abstract SetProperty<String> getTargets ();

abstract ConfigurableFileCollection getCommandFiles ();

abstract ConfigurableFileCollection getObjectFiles ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void registerMain (Project project, MetalComponent component)
task.setSource(projectDirectory.dir("src/main/ixx"));
task.getOutput().convention(output);
});
component.getCommandFiles().from(precommandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(precommandsTask));

final var compileImports = precompileTask.zip(importPath,(precompile,dependencies) -> {
Expand Down Expand Up @@ -130,6 +131,7 @@ static void registerMain (Project project, MetalComponent component)
task.setSource(compileSources);
task.getOutput().convention(output);
});
component.getCommandFiles().from(commandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(commandsTask));
}

Expand Down Expand Up @@ -188,6 +190,7 @@ static void registerTest (Project project, MetalComponent component)
task.setSource(projectDirectory.dir("src/test/ixx"));
task.getOutput().convention(output);
});
component.getCommandFiles().from(precommandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(precommandsTask));

final var compileImports = precompileTask.zip(importPath,(precompile,dependencies) -> {
Expand Down Expand Up @@ -227,6 +230,7 @@ static void registerTest (Project project, MetalComponent component)
task.setSource(compileSources);
task.getOutput().convention(output);
});
component.getCommandFiles().from(commandsTask);
commandsElements.configure(it -> it.getOutgoing().artifact(commandsTask));
}
}

0 comments on commit 92df560

Please sign in to comment.