use of org.gradle.language.cpp.CppPlatform in project gradle by gradle.
the class CppApplicationPlugin method apply.
@Override
public void apply(final Project project) {
project.getPluginManager().apply(CppBasePlugin.class);
final ObjectFactory objectFactory = project.getObjects();
final ProviderFactory providers = project.getProviders();
// Add the application and extension
final DefaultCppApplication application = componentFactory.newInstance(CppApplication.class, DefaultCppApplication.class, "main");
project.getExtensions().add(CppApplication.class, "application", application);
project.getComponents().add(application);
// Configure the component
application.getBaseName().convention(project.getName());
application.getTargetMachines().convention(useHostAsDefaultTargetMachine(targetMachineFactory));
application.getDevelopmentBinary().convention(project.provider(() -> {
// Prefer the host architecture, if present, else use the first architecture specified
return application.getBinaries().get().stream().filter(CppExecutable.class::isInstance).map(CppExecutable.class::cast).filter(binary -> !binary.isOptimized() && Architectures.forInput(binary.getTargetMachine().getArchitecture().getName()).equals(DefaultNativePlatform.host().getArchitecture())).findFirst().orElse(application.getBinaries().get().stream().filter(CppExecutable.class::isInstance).map(CppExecutable.class::cast).filter(binary -> !binary.isOptimized()).findFirst().orElse(null));
}));
application.getBinaries().whenElementKnown(binary -> {
application.getMainPublication().addVariant(binary);
});
project.afterEvaluate(p -> {
// TODO: make build type configurable for components
Dimensions.applicationVariants(application.getBaseName(), application.getTargetMachines(), objectFactory, attributesFactory, providers.provider(() -> project.getGroup().toString()), providers.provider(() -> project.getVersion().toString()), variantIdentity -> {
if (tryToBuildOnHost(variantIdentity)) {
ToolChainSelector.Result<CppPlatform> result = toolChainSelector.select(CppPlatform.class, new DefaultCppPlatform(variantIdentity.getTargetMachine()));
application.addExecutable(variantIdentity, result.getTargetPlatform(), result.getToolChain(), result.getPlatformToolProvider());
} else {
// Known, but not buildable
application.getMainPublication().addVariant(variantIdentity);
}
});
// Configure the binaries
application.getBinaries().realizeNow();
});
}
use of org.gradle.language.cpp.CppPlatform in project gradle by gradle.
the class DefaultToolChainSelector method select.
public Result<CppPlatform> select(CppPlatform requestPlatform) {
DefaultNativePlatform targetNativePlatform = newNativePlatform(requestPlatform.getTargetMachine());
// TODO - push all this stuff down to the tool chain and let it create the specific platform and provider
NativeLanguage sourceLanguage = NativeLanguage.CPP;
NativeToolChainInternal toolChain = getToolChain(sourceLanguage, targetNativePlatform);
// TODO - don't select again here, as the selection is already performed to select the toolchain
PlatformToolProvider toolProvider = toolChain.select(sourceLanguage, targetNativePlatform);
CppPlatform targetPlatform = new DefaultCppPlatform(requestPlatform.getTargetMachine(), targetNativePlatform);
return new DefaultResult<CppPlatform>(toolChain, toolProvider, targetPlatform);
}
Aggregations