use of org.gradle.swiftpm.internal.NativeProjectPublication in project gradle by gradle.
the class CppBasePlugin method apply.
@Override
public void apply(final Project project) {
project.getPluginManager().apply(NativeBasePlugin.class);
project.getPluginManager().apply(StandardToolChainsPlugin.class);
final TaskContainer tasks = project.getTasks();
final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory();
// Create the tasks for each C++ binary that is registered
project.getComponents().withType(DefaultCppBinary.class, binary -> {
final Names names = binary.getNames();
String language = "cpp";
TaskProvider<CppCompile> compile = tasks.register(names.getCompileTaskName(language), CppCompile.class, task -> {
final Callable<List<File>> systemIncludes = () -> binary.getPlatformToolProvider().getSystemLibraries(ToolType.CPP_COMPILER).getIncludeDirs();
task.includes(binary.getCompileIncludePath());
task.getSystemIncludes().from(systemIncludes);
task.source(binary.getCppSource());
if (binary.isDebuggable()) {
task.setDebuggable(true);
}
if (binary.isOptimized()) {
task.setOptimized(true);
}
task.getTargetPlatform().set(binary.getNativePlatform());
task.getToolChain().set(binary.getToolChain());
task.getObjectFileDir().set(buildDirectory.dir("obj/" + names.getDirName()));
if (binary instanceof CppSharedLibrary) {
task.setPositionIndependentCode(true);
}
});
binary.getObjectsDir().set(compile.flatMap(task -> task.getObjectFileDir()));
binary.getCompileTask().set(compile);
});
project.getComponents().withType(ProductionCppComponent.class, component -> {
project.afterEvaluate(p -> {
DefaultCppComponent componentInternal = (DefaultCppComponent) component;
publicationRegistry.registerPublication((ProjectInternal) project, new NativeProjectPublication(componentInternal.getDisplayName(), new SwiftPmTarget(component.getBaseName().get())));
});
});
}
use of org.gradle.swiftpm.internal.NativeProjectPublication in project gradle by gradle.
the class SwiftBasePlugin method apply.
@Override
public void apply(final Project project) {
project.getPluginManager().apply(NativeBasePlugin.class);
project.getPluginManager().apply(SwiftCompilerPlugin.class);
final TaskContainer tasks = project.getTasks();
final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory();
project.getDependencies().getAttributesSchema().attribute(Usage.USAGE_ATTRIBUTE).getCompatibilityRules().add(SwiftCppUsageCompatibilityRule.class);
project.getComponents().withType(DefaultSwiftBinary.class, binary -> {
final Names names = binary.getNames();
TaskProvider<SwiftCompile> compile = tasks.register(names.getCompileTaskName("swift"), SwiftCompile.class, task -> {
task.getModules().from(binary.getCompileModules());
task.getSource().from(binary.getSwiftSource());
task.getDebuggable().set(binary.isDebuggable());
task.getOptimized().set(binary.isOptimized());
if (binary.isTestable()) {
task.getCompilerArgs().add("-enable-testing");
}
if (binary.getTargetMachine().getOperatingSystemFamily().isMacOs()) {
task.getCompilerArgs().add("-sdk");
task.getCompilerArgs().add(locator.find().getAbsolutePath());
}
task.getModuleName().set(binary.getModule());
task.getObjectFileDir().set(buildDirectory.dir("obj/" + names.getDirName()));
task.getModuleFile().set(buildDirectory.file(binary.getModule().map(moduleName -> "modules/" + names.getDirName() + moduleName + ".swiftmodule")));
task.getSourceCompatibility().set(binary.getTargetPlatform().getSourceCompatibility());
task.getTargetPlatform().set(binary.getNativePlatform());
// TODO - make this lazy
task.getToolChain().set(binary.getToolChain());
if (binary instanceof SwiftSharedLibrary || binary instanceof SwiftStaticLibrary) {
task.getCompilerArgs().add("-parse-as-library");
}
});
binary.getModuleFile().set(compile.flatMap(task -> task.getModuleFile()));
binary.getCompileTask().set(compile);
binary.getObjectsDir().set(compile.flatMap(task -> task.getObjectFileDir()));
});
project.getComponents().withType(ProductionSwiftComponent.class, component -> {
project.afterEvaluate(p -> {
DefaultNativeComponent componentInternal = (DefaultNativeComponent) component;
publicationRegistry.registerPublication((ProjectInternal) project, new NativeProjectPublication(componentInternal.getDisplayName(), new SwiftPmTarget(component.getModule().get())));
});
});
}
Aggregations