use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider 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);
}
use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class AbstractGccCompatibleToolChain method select.
@Override
public PlatformToolProvider select(NativeLanguage sourceLanguage, NativePlatformInternal targetMachine) {
PlatformToolProvider toolProvider = getProviderForPlatform(targetMachine);
switch(sourceLanguage) {
case CPP:
if (toolProvider instanceof UnsupportedPlatformToolProvider) {
return toolProvider;
}
ToolSearchResult cppCompiler = toolProvider.locateTool(ToolType.CPP_COMPILER);
if (cppCompiler.isAvailable()) {
return toolProvider;
}
// No C++ compiler, complain about it
return new UnavailablePlatformToolProvider(targetMachine.getOperatingSystem(), cppCompiler);
case ANY:
if (toolProvider instanceof UnsupportedPlatformToolProvider) {
return toolProvider;
}
ToolSearchResult cCompiler = toolProvider.locateTool(ToolType.C_COMPILER);
if (cCompiler.isAvailable()) {
return toolProvider;
}
ToolSearchResult compiler = toolProvider.locateTool(ToolType.CPP_COMPILER);
if (compiler.isAvailable()) {
return toolProvider;
}
compiler = toolProvider.locateTool(ToolType.OBJECTIVEC_COMPILER);
if (compiler.isAvailable()) {
return toolProvider;
}
compiler = toolProvider.locateTool(ToolType.OBJECTIVECPP_COMPILER);
if (compiler.isAvailable()) {
return toolProvider;
}
// No compilers available, complain about the missing C compiler
return new UnavailablePlatformToolProvider(targetMachine.getOperatingSystem(), cCompiler);
default:
return new UnsupportedPlatformToolProvider(targetMachine.getOperatingSystem(), String.format("Don't know how to compile language %s.", sourceLanguage));
}
}
use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class AbstractGccCompatibleToolChain method getProviderForPlatform.
private PlatformToolProvider getProviderForPlatform(NativePlatformInternal targetPlatform) {
PlatformToolProvider toolProvider = toolProviders.get(targetPlatform);
if (toolProvider == null) {
toolProvider = createPlatformToolProvider(targetPlatform);
toolProviders.put(targetPlatform, toolProvider);
}
return toolProvider;
}
use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class CppModelBuilder method binariesFor.
private List<DefaultCppBinaryModel> binariesFor(CppComponent component, Iterable<File> headerDirs, DefaultProjectIdentifier projectIdentifier, CompilerOutputFileNamingSchemeFactory namingSchemeFactory) {
List<File> headerDirsCopy = ImmutableList.copyOf(headerDirs);
List<DefaultCppBinaryModel> binaries = new ArrayList<DefaultCppBinaryModel>();
for (CppBinary binary : component.getBinaries().get()) {
DefaultCppBinary cppBinary = (DefaultCppBinary) binary;
PlatformToolProvider platformToolProvider = cppBinary.getPlatformToolProvider();
CppCompile compileTask = binary.getCompileTask().get();
List<DefaultSourceFile> sourceFiles = sourceFiles(namingSchemeFactory, platformToolProvider, compileTask.getObjectFileDir().get().getAsFile(), binary.getCppSource().getFiles());
List<File> systemIncludes = ImmutableList.copyOf(compileTask.getSystemIncludes().getFiles());
List<File> userIncludes = ImmutableList.copyOf(compileTask.getIncludes().getFiles());
List<DefaultMacroDirective> macroDefines = macroDefines(compileTask);
List<String> additionalArgs = args(compileTask.getCompilerArgs().get());
CommandLineToolSearchResult compilerLookup = platformToolProvider.locateTool(ToolType.CPP_COMPILER);
File compilerExe = compilerLookup.isAvailable() ? compilerLookup.getTool() : null;
LaunchableGradleTask compileTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, compileTask);
DefaultCompilationDetails compilationDetails = new DefaultCompilationDetails(compileTaskModel, compilerExe, compileTask.getObjectFileDir().get().getAsFile(), sourceFiles, headerDirsCopy, systemIncludes, userIncludes, macroDefines, additionalArgs);
if (binary instanceof CppExecutable || binary instanceof CppTestExecutable) {
ComponentWithExecutable componentWithExecutable = (ComponentWithExecutable) binary;
LinkExecutable linkTask = componentWithExecutable.getLinkTask().get();
LaunchableGradleTask linkTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, componentWithExecutable.getExecutableFileProducer().get());
DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(linkTaskModel, componentWithExecutable.getExecutableFile().get().getAsFile(), args(linkTask.getLinkerArgs().get()));
binaries.add(new DefaultCppExecutableModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
} else if (binary instanceof CppSharedLibrary) {
CppSharedLibrary sharedLibrary = (CppSharedLibrary) binary;
LinkSharedLibrary linkTask = sharedLibrary.getLinkTask().get();
LaunchableGradleTask linkTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, sharedLibrary.getLinkFileProducer().get());
DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(linkTaskModel, sharedLibrary.getLinkFile().get().getAsFile(), args(linkTask.getLinkerArgs().get()));
binaries.add(new DefaultCppSharedLibraryModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
} else if (binary instanceof CppStaticLibrary) {
CppStaticLibrary staticLibrary = (CppStaticLibrary) binary;
LaunchableGradleTask createTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, staticLibrary.getLinkFileProducer().get());
DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(createTaskModel, staticLibrary.getLinkFile().get().getAsFile(), Collections.<String>emptyList());
binaries.add(new DefaultCppStaticLibraryModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
}
}
return binaries;
}
Aggregations