Skip to content

Commit

Permalink
Break association between current and software model type
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lacasse committed Jan 10, 2019
1 parent 83ed97f commit d2018d9
Show file tree
Hide file tree
Showing 54 changed files with 326 additions and 303 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.gradle.api.internal.file.collections.ImmutableFileCollection;
import org.gradle.language.cpp.CppBinary;
import org.gradle.language.cpp.CppComponent;
import org.gradle.language.cpp.CppPlatform;
import org.gradle.language.cpp.CppTargetMachine;
import org.gradle.language.cpp.internal.DefaultCppBinary;
import org.gradle.language.nativeplatform.internal.Dimensions;
import org.gradle.nativeplatform.toolchain.internal.MacroArgsConverter;
Expand Down Expand Up @@ -92,8 +92,8 @@ public String getVisualStudioConfigurationName() {
buildType = "release";
}

String operatingSystemFamilySuffix = Dimensions.createDimensionSuffix(getBinary().getTargetPlatform().getOperatingSystemFamily(), component.getBinaries().get().stream().map(CppBinary::getTargetPlatform).map(CppPlatform::getOperatingSystemFamily).collect(Collectors.toSet()));
String architectureSuffix = Dimensions.createDimensionSuffix(getBinary().getTargetPlatform().getArchitecture(), component.getBinaries().get().stream().map(CppBinary::getTargetPlatform).map(CppPlatform::getArchitecture).collect(Collectors.toSet()));
String operatingSystemFamilySuffix = Dimensions.createDimensionSuffix(getBinary().getTargetMachine().getOperatingSystemFamily(), component.getBinaries().get().stream().map(CppBinary::getTargetMachine).map(CppTargetMachine::getOperatingSystemFamily).collect(Collectors.toSet()));
String architectureSuffix = Dimensions.createDimensionSuffix(getBinary().getTargetMachine().getArchitecture(), component.getBinaries().get().stream().map(CppBinary::getTargetMachine).map(CppTargetMachine::getArchitecture).collect(Collectors.toSet()));

return buildType + operatingSystemFamilySuffix + architectureSuffix;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public void execute(Project project) {

String targetName = component.getModule().get();
final XcodeTarget target = newTarget(targetName, component.getModule().get(), toGradleCommand(project), getBridgeTaskPath(project), sources);
target.addBinary(DefaultXcodeProject.BUILD_DEBUG, component.getTestBinary().get().getInstallDirectory(), component.getTestBinary().get().getTargetPlatform().getArchitecture().getName());
target.addBinary(DefaultXcodeProject.BUILD_RELEASE, component.getTestBinary().get().getInstallDirectory(), component.getTestBinary().get().getTargetPlatform().getArchitecture().getName());
target.addBinary(DefaultXcodeProject.BUILD_DEBUG, component.getTestBinary().get().getInstallDirectory(), component.getTestBinary().get().getTargetMachine().getArchitecture().getName());
target.addBinary(DefaultXcodeProject.BUILD_RELEASE, component.getTestBinary().get().getInstallDirectory(), component.getTestBinary().get().getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.UNIT_TEST);
target.getCompileModules().from(component.getTestBinary().get().getCompileModules());
target.addTaskDependency(filterArtifactsFromImplicitBuilds(((DefaultSwiftBinary) component.getTestBinary().get()).getImportPathConfiguration()).getBuildDependencies());
Expand Down Expand Up @@ -258,13 +258,13 @@ public void execute(final Project project) {
@Override
public void execute(SwiftBinary swiftBinary) {
if (swiftBinary instanceof SwiftExecutable) {
target.addBinary(toBuildConfigurationName(component, swiftBinary), ((SwiftExecutable) swiftBinary).getDebuggerExecutableFile(), swiftBinary.getTargetPlatform().getArchitecture().getName());
target.addBinary(toBuildConfigurationName(component, swiftBinary), ((SwiftExecutable) swiftBinary).getDebuggerExecutableFile(), swiftBinary.getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.TOOL);
} else if (swiftBinary instanceof SwiftSharedLibrary) {
target.addBinary(toBuildConfigurationName(component, swiftBinary), ((SwiftSharedLibrary) swiftBinary).getRuntimeFile(), swiftBinary.getTargetPlatform().getArchitecture().getName());
target.addBinary(toBuildConfigurationName(component, swiftBinary), ((SwiftSharedLibrary) swiftBinary).getRuntimeFile(), swiftBinary.getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.DYNAMIC_LIBRARY);
} else if (swiftBinary instanceof SwiftStaticLibrary) {
target.addBinary(toBuildConfigurationName(component, swiftBinary), ((SwiftStaticLibrary) swiftBinary).getLinkFile(), swiftBinary.getTargetPlatform().getArchitecture().getName());
target.addBinary(toBuildConfigurationName(component, swiftBinary), ((SwiftStaticLibrary) swiftBinary).getLinkFile(), swiftBinary.getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.STATIC_LIBRARY);
}
target.getSwiftSourceCompatibility().set(swiftBinary.getSourceCompatibility());
Expand Down Expand Up @@ -329,13 +329,13 @@ public void execute(final Project project) {
@Override
public void execute(CppBinary cppBinary) {
if (cppBinary instanceof CppExecutable) {
target.addBinary(toBuildConfigurationName(component, cppBinary), ((CppExecutable) cppBinary).getDebuggerExecutableFile(), cppBinary.getTargetPlatform().getArchitecture().getName());
target.addBinary(toBuildConfigurationName(component, cppBinary), ((CppExecutable) cppBinary).getDebuggerExecutableFile(), cppBinary.getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.TOOL);
} else if (cppBinary instanceof CppSharedLibrary) {
target.addBinary(toBuildConfigurationName(component, cppBinary), ((CppSharedLibrary) cppBinary).getRuntimeFile(), cppBinary.getTargetPlatform().getArchitecture().getName());
target.addBinary(toBuildConfigurationName(component, cppBinary), ((CppSharedLibrary) cppBinary).getRuntimeFile(), cppBinary.getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.DYNAMIC_LIBRARY);
} else if (cppBinary instanceof CppStaticLibrary) {
target.addBinary(toBuildConfigurationName(component, cppBinary), ((CppStaticLibrary) cppBinary).getLinkFile(), cppBinary.getTargetPlatform().getArchitecture().getName());
target.addBinary(toBuildConfigurationName(component, cppBinary), ((CppStaticLibrary) cppBinary).getLinkFile(), cppBinary.getTargetMachine().getArchitecture().getName());
target.setProductType(PBXTarget.ProductType.STATIC_LIBRARY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public interface CppBinary extends ComponentWithObjectFiles, ComponentWithDepend
/**
* {@inheritDoc}
*
* @since 4.5
* @since 5.2
*/
CppPlatform getTargetPlatform();
CppTargetMachine getTargetMachine();

/**
* Returns the compile task for this binary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,13 @@
package org.gradle.language.cpp;

import org.gradle.api.Incubating;
import org.gradle.api.tasks.Nested;
import org.gradle.nativeplatform.OperatingSystemFamily;
import org.gradle.nativeplatform.platform.NativePlatform;
import org.gradle.nativeplatform.TargetMachine;

/**
* A target platform for building C++ binaries.
* A target machine for building C++ binaries.
*
* @since 4.5
* @since 5.2
*/
@Incubating
public interface CppPlatform extends NativePlatform {
/**
* The operating system family being targeted.
*
* @since 4.8
*/
@Nested
OperatingSystemFamily getOperatingSystemFamily();
public interface CppTargetMachine extends TargetMachine {
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.gradle.language.ComponentDependencies;
import org.gradle.language.cpp.CppApplication;
import org.gradle.language.cpp.CppExecutable;
import org.gradle.language.cpp.CppPlatform;
import org.gradle.language.cpp.CppTargetMachine;
import org.gradle.language.internal.DefaultComponentDependencies;
import org.gradle.language.nativeplatform.internal.PublicationAwareComponent;
import org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal;
Expand All @@ -50,8 +50,8 @@ public DefaultCppApplication(String name, ObjectFactory objectFactory, FileOpera
this.mainVariant = new MainExecutableVariant(collectionCallbackActionDecorator);
}

public DefaultCppExecutable addExecutable(NativeVariantIdentity identity, CppPlatform targetPlatform, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider) {
DefaultCppExecutable result = objectFactory.newInstance(DefaultCppExecutable.class, getNames().append(identity.getName()), getBaseName(), getCppSource(), getPrivateHeaderDirs(), getImplementationDependencies(), targetPlatform, toolChain, platformToolProvider, identity);
public DefaultCppExecutable addExecutable(NativeVariantIdentity identity, CppTargetMachine targetMachine, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider) {
DefaultCppExecutable result = objectFactory.newInstance(DefaultCppExecutable.class, getNames().append(identity.getName()), getBaseName(), getCppSource(), getPrivateHeaderDirs(), getImplementationDependencies(), targetMachine, toolChain, platformToolProvider, identity);
getBinaries().add(result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.TaskDependency;
import org.gradle.language.cpp.CppBinary;
import org.gradle.language.cpp.CppPlatform;
import org.gradle.language.cpp.CppTargetMachine;
import org.gradle.language.cpp.tasks.CppCompile;
import org.gradle.language.internal.DefaultNativeBinary;
import org.gradle.language.nativeplatform.internal.Names;
Expand All @@ -53,18 +53,18 @@ public class DefaultCppBinary extends DefaultNativeBinary implements CppBinary {
private final FileCollection includePath;
private final Configuration linkLibraries;
private final FileCollection runtimeLibraries;
private final CppPlatform targetPlatform;
private final CppTargetMachine targetMachine;
private final NativeToolChainInternal toolChain;
private final PlatformToolProvider platformToolProvider;
private final Configuration includePathConfiguration;
private final Property<CppCompile> compileTaskProperty;
private final NativeVariantIdentity identity;

public DefaultCppBinary(Names names, ObjectFactory objects, Provider<String> baseName, FileCollection sourceFiles, FileCollection componentHeaderDirs, ConfigurationContainer configurations, Configuration componentImplementation, CppPlatform targetPlatform, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider, NativeVariantIdentity identity) {
public DefaultCppBinary(Names names, ObjectFactory objects, Provider<String> baseName, FileCollection sourceFiles, FileCollection componentHeaderDirs, ConfigurationContainer configurations, Configuration componentImplementation, CppTargetMachine targetMachine, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider, NativeVariantIdentity identity) {
super(names, objects, componentImplementation);
this.baseName = baseName;
this.sourceFiles = sourceFiles;
this.targetPlatform = targetPlatform;
this.targetMachine = targetMachine;
this.toolChain = toolChain;
this.platformToolProvider = platformToolProvider;
this.compileTaskProperty = objects.property(CppCompile.class);
Expand Down Expand Up @@ -164,8 +164,8 @@ public Configuration getIncludePathConfiguration() {
}

@Override
public CppPlatform getTargetPlatform() {
return targetPlatform;
public CppTargetMachine getTargetMachine() {
return targetMachine;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.language.cpp.CppExecutable;
import org.gradle.language.cpp.CppPlatform;
import org.gradle.language.cpp.CppTargetMachine;
import org.gradle.language.nativeplatform.internal.ConfigurableComponentWithExecutable;
import org.gradle.language.nativeplatform.internal.ConfigurableComponentWithRuntimeUsage;
import org.gradle.language.nativeplatform.internal.Names;
Expand All @@ -59,8 +59,8 @@ public class DefaultCppExecutable extends DefaultCppBinary implements CppExecuta
private final RegularFileProperty debuggerExecutableFile;

@Inject
public DefaultCppExecutable(Names names, ObjectFactory objectFactory, FileOperations fileOperations, Provider<String> baseName, FileCollection sourceFiles, FileCollection componentHeaderDirs, ConfigurationContainer configurations, Configuration implementation, CppPlatform targetPlatform, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider, NativeVariantIdentity identity) {
super(names, objectFactory, baseName, sourceFiles, componentHeaderDirs, configurations, implementation, targetPlatform, toolChain, platformToolProvider, identity);
public DefaultCppExecutable(Names names, ObjectFactory objectFactory, FileOperations fileOperations, Provider<String> baseName, FileCollection sourceFiles, FileCollection componentHeaderDirs, ConfigurationContainer configurations, Configuration implementation, CppTargetMachine targetMachine, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider, NativeVariantIdentity identity) {
super(names, objectFactory, baseName, sourceFiles, componentHeaderDirs, configurations, implementation, targetMachine, toolChain, platformToolProvider, identity);
this.executableFile = objectFactory.fileProperty();
this.executableFileProducer = objectFactory.property(Task.class);
this.debuggerExecutableFile = objectFactory.fileProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.gradle.language.LibraryDependencies;
import org.gradle.language.cpp.CppBinary;
import org.gradle.language.cpp.CppLibrary;
import org.gradle.language.cpp.CppPlatform;
import org.gradle.language.cpp.CppTargetMachine;
import org.gradle.language.internal.DefaultLibraryDependencies;
import org.gradle.language.nativeplatform.internal.PublicationAwareComponent;
import org.gradle.nativeplatform.Linkage;
Expand Down Expand Up @@ -77,14 +77,14 @@ public DefaultCppLibrary(String name, ObjectFactory objectFactory, FileOperation
mainVariant = new MainLibraryVariant("api", apiUsage, apiElements, collectionCallbackActionDecorator);
}

public DefaultCppSharedLibrary addSharedLibrary(NativeVariantIdentity identity, CppPlatform targetPlatform, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider) {
DefaultCppSharedLibrary result = objectFactory.newInstance(DefaultCppSharedLibrary.class, getNames().append(identity.getName()), getBaseName(), getCppSource(), getAllHeaderDirs(), getImplementationDependencies(), targetPlatform, toolChain, platformToolProvider, identity);
public DefaultCppSharedLibrary addSharedLibrary(NativeVariantIdentity identity, CppTargetMachine targetMachine, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider) {
DefaultCppSharedLibrary result = objectFactory.newInstance(DefaultCppSharedLibrary.class, getNames().append(identity.getName()), getBaseName(), getCppSource(), getAllHeaderDirs(), getImplementationDependencies(), targetMachine, toolChain, platformToolProvider, identity);
getBinaries().add(result);
return result;
}

public DefaultCppStaticLibrary addStaticLibrary(NativeVariantIdentity identity, CppPlatform targetPlatform, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider) {
DefaultCppStaticLibrary result = objectFactory.newInstance(DefaultCppStaticLibrary.class, getNames().append(identity.getName()), getBaseName(), getCppSource(), getAllHeaderDirs(), getImplementationDependencies(), targetPlatform, toolChain, platformToolProvider, identity);
public DefaultCppStaticLibrary addStaticLibrary(NativeVariantIdentity identity, CppTargetMachine targetMachine, NativeToolChainInternal toolChain, PlatformToolProvider platformToolProvider) {
DefaultCppStaticLibrary result = objectFactory.newInstance(DefaultCppStaticLibrary.class, getNames().append(identity.getName()), getBaseName(), getCppSource(), getAllHeaderDirs(), getImplementationDependencies(), targetMachine, toolChain, platformToolProvider, identity);
getBinaries().add(result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,12 @@

package org.gradle.language.cpp.internal;

import org.gradle.language.cpp.CppPlatform;
import org.gradle.nativeplatform.OperatingSystemFamily;
import org.gradle.language.cpp.CppTargetMachine;
import org.gradle.nativeplatform.TargetMachine;
import org.gradle.nativeplatform.platform.internal.ImmutableDefaultNativePlatform;
import org.gradle.nativeplatform.platform.internal.NativePlatformInternal;
import org.gradle.nativeplatform.internal.DefaultTargetMachine;

public class DefaultCppPlatform extends ImmutableDefaultNativePlatform implements CppPlatform {
private final OperatingSystemFamily operatingSystemFamily;

public DefaultCppPlatform(String name, TargetMachine targetMachine, NativePlatformInternal targetNativePlatform) {
super(name, targetNativePlatform.getOperatingSystem(), targetNativePlatform.getArchitecture());
this.operatingSystemFamily = targetMachine.getOperatingSystemFamily();
}

@Override
public OperatingSystemFamily getOperatingSystemFamily() {
return operatingSystemFamily;
public class DefaultCppPlatform extends DefaultTargetMachine implements CppTargetMachine {
public DefaultCppPlatform(TargetMachine targetMachine) {
super(targetMachine.getOperatingSystemFamily(), targetMachine.getArchitecture());
}
}
Loading

0 comments on commit d2018d9

Please sign in to comment.