use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class CppBasePlugin method apply.
@Override
public void apply(final ProjectInternal project) {
project.getPluginManager().apply(NativeBasePlugin.class);
project.getPluginManager().apply(StandardToolChainsPlugin.class);
final TaskContainerInternal tasks = project.getTasks();
final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory();
// Enable the use of Gradle metadata. This is a temporary opt-in switch until available by default
project.getGradle().getServices().get(FeaturePreviews.class).enableFeature(GRADLE_METADATA);
// Create the tasks for each C++ binary that is registered
project.getComponents().withType(DefaultCppBinary.class, new Action<DefaultCppBinary>() {
@Override
public void execute(final DefaultCppBinary binary) {
final Names names = binary.getNames();
String language = "cpp";
final NativePlatform currentPlatform = binary.getTargetPlatform();
// TODO - make this lazy
final NativeToolChainInternal toolChain = binary.getToolChain();
Callable<List<File>> systemIncludes = new Callable<List<File>>() {
@Override
public List<File> call() {
PlatformToolProvider platformToolProvider = binary.getPlatformToolProvider();
return platformToolProvider.getSystemLibraries(ToolType.CPP_COMPILER).getIncludeDirs();
}
};
CppCompile compile = tasks.create(names.getCompileTaskName(language), CppCompile.class);
compile.includes(binary.getCompileIncludePath());
compile.includes(systemIncludes);
compile.source(binary.getCppSource());
if (binary.isDebuggable()) {
compile.setDebuggable(true);
}
if (binary.isOptimized()) {
compile.setOptimized(true);
}
compile.getTargetPlatform().set(currentPlatform);
compile.getToolChain().set(toolChain);
compile.getObjectFileDir().set(buildDirectory.dir("obj/" + names.getDirName()));
binary.getObjectsDir().set(compile.getObjectFileDir());
binary.getCompileTask().set(compile);
}
});
project.getComponents().withType(CppSharedLibrary.class, new Action<CppSharedLibrary>() {
@Override
public void execute(CppSharedLibrary library) {
library.getCompileTask().get().setPositionIndependentCode(true);
}
});
project.getComponents().withType(ProductionCppComponent.class, new Action<ProductionCppComponent>() {
@Override
public void execute(final ProductionCppComponent component) {
project.afterEvaluate(new Action<Project>() {
@Override
public void execute(Project project) {
DefaultCppComponent componentInternal = (DefaultCppComponent) component;
publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(componentInternal.getDisplayName(), new SwiftPmTarget(component.getBaseName().get()), false));
}
});
}
});
}
use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class StripSymbols method createCompiler.
private Compiler<StripperSpec> createCompiler() {
NativePlatformInternal targetPlatform = Cast.cast(NativePlatformInternal.class, this.targetPlatform.get());
NativeToolChainInternal toolChain = Cast.cast(NativeToolChainInternal.class, getToolChain().get());
PlatformToolProvider toolProvider = toolChain.select(targetPlatform);
return toolProvider.newCompiler(StripperSpec.class);
}
use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class SwiftcToolChain method select.
@Override
public PlatformToolProvider select(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 AbstractNativeCompileTask method compile.
@TaskAction
protected void compile(InputChanges inputs) {
BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
NativeCompileSpec spec = createCompileSpec();
spec.setTargetPlatform(targetPlatform.get());
spec.setTempDir(getTemporaryDir());
spec.setObjectFileDir(objectFileDir.get().getAsFile());
spec.include(includes);
spec.systemInclude(systemIncludes);
spec.source(getSource());
spec.setMacros(getMacros());
spec.args(getCompilerArgs().get());
spec.setPositionIndependentCode(isPositionIndependentCode());
spec.setDebuggable(isDebuggable());
spec.setOptimized(isOptimized());
spec.setIncrementalCompile(inputs.isIncremental());
spec.setOperationLogger(operationLogger);
configureSpec(spec);
NativeToolChainInternal nativeToolChain = (NativeToolChainInternal) toolChain.get();
NativePlatformInternal nativePlatform = (NativePlatformInternal) targetPlatform.get();
PlatformToolProvider platformToolProvider = nativeToolChain.select(nativePlatform);
setDidWork(doCompile(spec, platformToolProvider).getDidWork());
}
use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.
the class AbstractNativeSourceCompileTask method getCompilerVersion.
/**
* The compiler used, including the type and the version.
*
* @since 4.4
*/
@Nullable
@Optional
@Nested
protected CompilerVersion getCompilerVersion() {
NativeToolChainInternal toolChain = (NativeToolChainInternal) getToolChain().get();
NativePlatformInternal targetPlatform = (NativePlatformInternal) getTargetPlatform().get();
PlatformToolProvider toolProvider = toolChain.select(targetPlatform);
Compiler<? extends NativeCompileSpec> compiler = toolProvider.newCompiler(createCompileSpec().getClass());
if (!(compiler instanceof VersionAwareCompiler)) {
return null;
}
return ((VersionAwareCompiler) compiler).getVersion();
}
Aggregations