Skip to content

Commit

Permalink
Fix plugin name and clean up some rough edges
Browse files Browse the repository at this point in the history
  • Loading branch information
ghale committed Jul 1, 2024
1 parent 5879b69 commit 01f08fc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ string os() {
#ifdef __MACH__
return "macOS";
#else
return "unknown OS"
return "unknown OS";
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gradlePlugin {
implementationClass = "org.gradle.api.experimental.cpp.StandaloneCppApplicationPlugin"
tags = setOf("declarative-gradle")
}
create("swift-ecosystem") {
create("cpp-ecosystem") {
id = "org.gradle.experimental.cpp-ecosystem"
implementationClass = "org.gradle.api.experimental.cpp.CppEcosystemPlugin"
tags = setOf("declarative-gradle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
import org.gradle.util.internal.TextUtil;

public abstract class StandaloneCppApplicationPlugin implements Plugin<Project> {
@SoftwareType(name = "cppApplication", modelPublicType = CppApplication.class)
public static final String CPP_APPLICATION = "cppApplication";

@SoftwareType(name = CPP_APPLICATION)
abstract public CppApplication getApplication();

@Override
public void apply(Project target) {
CppApplication application = getApplication();
target.getExtensions().add(CPP_APPLICATION, application);

target.getPlugins().apply(CppApplicationPlugin.class);
target.getPlugins().apply(CliApplicationConventionsPlugin.class);
Expand All @@ -33,8 +36,8 @@ private void linkDslModelToPlugin(Project project, CppApplication application) {

model.getImplementationDependencies().getDependencies().addAllLater(application.getDependencies().getImplementation().getDependencies());

project.afterEvaluate(p -> {
for (CppBinary binary : model.getBinaries().get()) {
project.getComponents().withType(org.gradle.language.cpp.CppApplication.class).configureEach(applicationComponent ->
applicationComponent.getBinaries().configureEach(binary -> {
binary.getCompileTask().get().getCompilerArgs().add(application.getCppVersion().map(v -> "--std=" + v));
if (binary instanceof CppExecutable) {
Provider<RegularFile> executable = ((CppExecutable) binary).getDebuggerExecutableFile();
Expand All @@ -44,7 +47,7 @@ private void linkDslModelToPlugin(Project project, CppApplication application) {
});
application.getRunTasks().add(runTask);
}
}
});
})
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import org.gradle.language.cpp.plugins.CppLibraryPlugin;

public abstract class StandaloneCppLibraryPlugin implements Plugin<Project> {
@SoftwareType(name = "cppLibrary", modelPublicType = CppLibrary.class)
public static final String CPP_LIBRARY = "cppLibrary";

@SoftwareType(name = CPP_LIBRARY)
abstract public CppLibrary getLibrary();

@Override
public void apply(Project target) {
CppLibrary library = getLibrary();
target.getExtensions().add(CPP_LIBRARY, library);

target.getPlugins().apply(CppLibraryPlugin.class);

Expand All @@ -25,10 +28,10 @@ private void linkDslModelToPlugin(Project project, CppLibrary library) {
model.getImplementationDependencies().getDependencies().addAllLater(library.getDependencies().getImplementation().getDependencies());
model.getApiDependencies().getDependencies().addAllLater(library.getDependencies().getApi().getDependencies());

project.afterEvaluate(p -> {
for (CppBinary binary : model.getBinaries().get()) {
project.getComponents().withType(org.gradle.language.cpp.CppLibrary.class).configureEach(libraryComponent ->
libraryComponent.getBinaries().configureEach(binary -> {
binary.getCompileTask().get().getCompilerArgs().add(library.getCppVersion().map(v -> "--std=" + v));
}
});
})
);
}
}

0 comments on commit 01f08fc

Please sign in to comment.