Search in sources :

Example 1 with NativeLibraryBinary

use of org.gradle.nativeplatform.NativeLibraryBinary in project gradle by gradle.

the class ProjectLibraryBinaryLocator method getBinaries.

// Converts the binaries of a project library into regular binary instances
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier libraryIdentifier) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(libraryIdentifier.getProjectPath());
    ComponentSpecContainer components = projectModel.find("components", ComponentSpecContainer.class);
    if (components == null) {
        return null;
    }
    String libraryName = libraryIdentifier.getLibraryName();
    NativeLibrarySpec library = components.withType(NativeLibrarySpec.class).get(libraryName);
    if (library == null) {
        return null;
    }
    ModelMap<NativeBinarySpec> projectBinaries = library.getBinaries().withType(NativeBinarySpec.class);
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    for (NativeBinarySpec nativeBinarySpec : projectBinaries.values()) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
Also used : NativeLibraryBinary(org.gradle.nativeplatform.NativeLibraryBinary) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) NativeBinarySpec(org.gradle.nativeplatform.NativeBinarySpec) ComponentSpecContainer(org.gradle.platform.base.ComponentSpecContainer) NativeLibrarySpec(org.gradle.nativeplatform.NativeLibrarySpec) DefaultDomainObjectSet(org.gradle.api.internal.DefaultDomainObjectSet) Nullable(org.gradle.api.Nullable)

Example 2 with NativeLibraryBinary

use of org.gradle.nativeplatform.NativeLibraryBinary in project gradle by gradle.

the class LibraryNativeDependencyResolver method resolve.

@Override
public void resolve(NativeBinaryResolveResult resolution) {
    for (NativeBinaryRequirementResolveResult requirementResolution : resolution.getPendingResolutions()) {
        DefaultLibraryResolver libraryResolver = new DefaultLibraryResolver(libraryBinaryLocator, requirementResolution.getRequirement(), resolution.getTarget());
        NativeLibraryBinary libraryBinary = libraryResolver.resolveLibraryBinary();
        requirementResolution.setLibraryBinary(libraryBinary);
        requirementResolution.setNativeDependencySet(new DefaultNativeDependencySet(libraryBinary));
    }
}
Also used : NativeLibraryBinary(org.gradle.nativeplatform.NativeLibraryBinary)

Example 3 with NativeLibraryBinary

use of org.gradle.nativeplatform.NativeLibraryBinary in project gradle by gradle.

the class NativeDependentBinariesResolutionStrategy method buildState.

private State buildState() {
    State state = new State();
    List<ProjectInternal> orderedProjects = Ordering.usingToString().sortedCopy(projectRegistry.getAllProjects());
    for (ProjectInternal project : orderedProjects) {
        if (project.getPlugins().hasPlugin(ComponentModelBasePlugin.class)) {
            ModelRegistry modelRegistry = projectModelResolver.resolveProjectModel(project.getPath());
            ModelMap<NativeComponentSpec> components = modelRegistry.realize("components", ModelTypes.modelMap(NativeComponentSpec.class));
            for (NativeBinarySpecInternal binary : allBinariesOf(components.withType(VariantComponentSpec.class))) {
                state.registerBinary(binary);
            }
            ModelMap<Object> testSuites = modelRegistry.find("testSuites", ModelTypes.modelMap(Object.class));
            if (testSuites != null) {
                for (NativeBinarySpecInternal binary : allBinariesOf(testSuites.withType(NativeComponentSpec.class).withType(VariantComponentSpec.class))) {
                    state.registerBinary(binary);
                }
            }
        }
    }
    for (NativeBinarySpecInternal nativeBinary : state.dependencies.keySet()) {
        for (NativeLibraryBinary libraryBinary : nativeBinary.getDependentBinaries()) {
            // Skip prebuilt libraries
            if (libraryBinary instanceof NativeBinarySpecInternal) {
                // Unfortunate cast! see LibraryBinaryLocator
                state.dependencies.get(nativeBinary).add((NativeBinarySpecInternal) libraryBinary);
            }
        }
        if (testSupport != null) {
            state.dependencies.get(nativeBinary).addAll(testSupport.getTestDependencies(nativeBinary));
        }
    }
    return state;
}
Also used : NativeLibraryBinary(org.gradle.nativeplatform.NativeLibraryBinary) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) VariantComponentSpec(org.gradle.platform.base.VariantComponentSpec) NativeComponentSpec(org.gradle.nativeplatform.NativeComponentSpec) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Aggregations

NativeLibraryBinary (org.gradle.nativeplatform.NativeLibraryBinary)3 ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)2 Nullable (org.gradle.api.Nullable)1 DefaultDomainObjectSet (org.gradle.api.internal.DefaultDomainObjectSet)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 NativeBinarySpec (org.gradle.nativeplatform.NativeBinarySpec)1 NativeComponentSpec (org.gradle.nativeplatform.NativeComponentSpec)1 NativeLibrarySpec (org.gradle.nativeplatform.NativeLibrarySpec)1 ComponentSpecContainer (org.gradle.platform.base.ComponentSpecContainer)1 VariantComponentSpec (org.gradle.platform.base.VariantComponentSpec)1