use of org.gradle.nativeplatform.TargetMachine in project gradle by gradle.
the class NativeBasePlugin method addLifecycleTasks.
private void addLifecycleTasks(final Project project, final TaskContainer tasks, final SoftwareComponentContainer components) {
components.withType(ComponentWithBinaries.class, component -> {
// Register each child of each component
component.getBinaries().whenElementKnown(binary -> components.add(binary));
if (component instanceof ProductionComponent) {
// Add an assemble task for each binary and also wire the development binary in to the `assemble` task
component.getBinaries().whenElementFinalized(ComponentWithOutputs.class, binary -> {
// Determine which output to produce at development time.
final FileCollection outputs = binary.getOutputs();
Names names = ((ComponentWithNames) binary).getNames();
tasks.register(names.getTaskName("assemble"), task -> task.dependsOn(outputs));
if (binary == ((ProductionComponent) component).getDevelopmentBinary().get()) {
tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME, task -> task.dependsOn(outputs));
}
});
}
if (component instanceof ComponentWithTargetMachines) {
ComponentWithTargetMachines componentWithTargetMachines = (ComponentWithTargetMachines) component;
tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME, task -> {
task.dependsOn((Callable) () -> {
TargetMachine currentHost = ((DefaultTargetMachineFactory) targetMachineFactory).host();
boolean targetsCurrentMachine = componentWithTargetMachines.getTargetMachines().get().stream().anyMatch(targetMachine -> currentHost.getOperatingSystemFamily().equals(targetMachine.getOperatingSystemFamily()));
if (!targetsCurrentMachine) {
task.getLogger().warn("'" + component.getName() + "' component in project '" + project.getPath() + "' does not target this operating system.");
}
return Collections.emptyList();
});
});
}
});
}
Aggregations