mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
Gradle/C++: migrate to new built-in gradle C++ tooling models
This commit is contained in:
@@ -7,20 +7,30 @@ import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.project.ContentRootData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
|
||||
import com.intellij.openapi.externalSystem.util.Order;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.gradle.tooling.model.DomainObjectSet;
|
||||
import org.gradle.tooling.model.Task;
|
||||
import org.gradle.tooling.model.cpp.CppExecutable;
|
||||
import org.gradle.tooling.model.cpp.CppSharedLibrary;
|
||||
import org.gradle.tooling.model.cpp.CppStaticLibrary;
|
||||
import org.gradle.tooling.model.cpp.LinkageDetails;
|
||||
import org.gradle.tooling.model.idea.IdeaModule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.DefaultExternalTask;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalTask;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.builder.CppModelBuilder;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppProject;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFolder;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl.CppProjectImpl;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.*;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl.*;
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -32,16 +42,21 @@ public class GradleNativeProjectResolver extends AbstractProjectResolverExtensio
|
||||
|
||||
@Override
|
||||
public void populateModuleContentRoots(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule) {
|
||||
CppProject cppProject = resolverCtx.getExtraProject(gradleModule, CppProject.class);
|
||||
CppProjectImpl cppProject = appendCppProject(gradleModule, ideModule);
|
||||
if (cppProject != null) {
|
||||
// store a local process copy of the object to get rid of proxy types for further serialization
|
||||
ideModule.createChild(CPP_PROJECT, new CppProjectImpl(cppProject));
|
||||
|
||||
Set<SourceFolder> sourceFolders = cppProject.getSourceFolders();
|
||||
for (SourceFolder folder : sourceFolders) {
|
||||
File baseDir = folder.getBaseDir();
|
||||
ContentRootData ideContentRoot = new ContentRootData(GradleConstants.SYSTEM_ID, baseDir.getAbsolutePath());
|
||||
ideContentRoot.storePath(ExternalSystemSourceType.SOURCE, baseDir.getAbsolutePath());
|
||||
CppComponent mainComponent = cppProject.getMainComponent();
|
||||
Set<File> sourceFolders = mainComponent == null ? ContainerUtil.newHashSet() : getSourceFolders(mainComponent);
|
||||
CppTestSuite testComponent = cppProject.getTestComponent();
|
||||
Set<File> testSourceFolders = testComponent == null ? ContainerUtil.newHashSet() : getSourceFolders(testComponent);
|
||||
testSourceFolders.removeAll(sourceFolders);
|
||||
for (File folder : sourceFolders) {
|
||||
ContentRootData ideContentRoot = new ContentRootData(GradleConstants.SYSTEM_ID, folder.getAbsolutePath());
|
||||
ideContentRoot.storePath(ExternalSystemSourceType.SOURCE, folder.getAbsolutePath());
|
||||
ideModule.createChild(ProjectKeys.CONTENT_ROOT, ideContentRoot);
|
||||
}
|
||||
for (File folder : testSourceFolders) {
|
||||
ContentRootData ideContentRoot = new ContentRootData(GradleConstants.SYSTEM_ID, folder.getAbsolutePath());
|
||||
ideContentRoot.storePath(ExternalSystemSourceType.TEST, folder.getAbsolutePath());
|
||||
ideModule.createChild(ProjectKeys.CONTENT_ROOT, ideContentRoot);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +67,7 @@ public class GradleNativeProjectResolver extends AbstractProjectResolverExtensio
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Class> getExtraProjectModelClasses() {
|
||||
return Collections.singleton(CppProject.class);
|
||||
return ContainerUtil.set(org.gradle.tooling.model.cpp.CppProject.class, CppProject.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -63,4 +78,147 @@ public class GradleNativeProjectResolver extends AbstractProjectResolverExtensio
|
||||
CppModelBuilder.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class> getTargetTypes() {
|
||||
return ContainerUtil.set(
|
||||
org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppExecutable.class,
|
||||
org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppSharedLibrary.class,
|
||||
org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppStaticLibrary.class
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CppProjectImpl appendCppProject(@NotNull IdeaModule gradleModule,
|
||||
@NotNull DataNode<ModuleData> ideModule) {
|
||||
CppProjectImpl cppProject = null;
|
||||
org.gradle.tooling.model.cpp.CppProject gradleCppProject =
|
||||
resolverCtx.getExtraProject(gradleModule, org.gradle.tooling.model.cpp.CppProject.class);
|
||||
if (gradleCppProject != null) {
|
||||
cppProject = convert(gradleCppProject);
|
||||
}
|
||||
else {
|
||||
// todo[Vlad] old experimental support for Gradle 4.1 - 4.9, to be removed in 2019.1
|
||||
CppProject customGradleCppProject = resolverCtx.getExtraProject(gradleModule, CppProject.class);
|
||||
if (customGradleCppProject != null) {
|
||||
// store a local process copy of the object to get rid of proxy types for further serialization
|
||||
cppProject = new CppProjectImpl(customGradleCppProject);
|
||||
}
|
||||
}
|
||||
if (cppProject != null) {
|
||||
ideModule.createChild(CPP_PROJECT, cppProject);
|
||||
}
|
||||
return cppProject;
|
||||
}
|
||||
|
||||
private static CppProjectImpl convert(@NotNull org.gradle.tooling.model.cpp.CppProject gradleCppProject) {
|
||||
CppProjectImpl cppProject = new CppProjectImpl();
|
||||
cppProject.setMainComponent(convert(gradleCppProject.getMainComponent()));
|
||||
cppProject.setTestComponent((CppTestSuite)convert(gradleCppProject.getTestComponent()));
|
||||
return cppProject;
|
||||
}
|
||||
|
||||
private static CppComponent convert(@Nullable org.gradle.tooling.model.cpp.CppComponent component) {
|
||||
if (component == null) return null;
|
||||
CppComponentImpl cppComponent;
|
||||
if (component instanceof org.gradle.tooling.model.cpp.CppTestSuite) {
|
||||
cppComponent = new CppTestSuiteImpl(component.getName(), component.getBaseName());
|
||||
}
|
||||
else {
|
||||
cppComponent = new CppComponentImpl(component.getName(), component.getBaseName());
|
||||
}
|
||||
for (org.gradle.tooling.model.cpp.CppBinary binary : component.getBinaries()) {
|
||||
cppComponent.addBinary(convert(binary));
|
||||
}
|
||||
return cppComponent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static CppBinaryImpl convert(@Nullable org.gradle.tooling.model.cpp.CppBinary binary) {
|
||||
CppBinaryImpl cppBinary;
|
||||
if (binary instanceof CppExecutable) {
|
||||
cppBinary = new CppExecutableImpl(binary.getName(), binary.getBaseName(), binary.getVariantName());
|
||||
}
|
||||
else if (binary instanceof CppSharedLibrary) {
|
||||
cppBinary = new CppSharedLibraryImpl(binary.getName(), binary.getBaseName(), binary.getVariantName());
|
||||
}
|
||||
else if (binary instanceof CppStaticLibrary) {
|
||||
cppBinary = new CppStaticLibraryImpl(binary.getName(), binary.getBaseName(), binary.getVariantName());
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
cppBinary.setCompilationDetails(convert(binary.getCompilationDetails()));
|
||||
cppBinary.setLinkageDetails(convert(binary.getLinkageDetails()));
|
||||
return cppBinary;
|
||||
}
|
||||
|
||||
private static LinkageDetailsImpl convert(LinkageDetails details) {
|
||||
LinkageDetailsImpl linkageDetails = new LinkageDetailsImpl();
|
||||
linkageDetails.setAdditionalArgs(new ArrayList<>(details.getAdditionalArgs()));
|
||||
linkageDetails.setLinkTask(convert(details.getLinkTask()));
|
||||
linkageDetails.setOutputLocation(details.getOutputLocation());
|
||||
return linkageDetails;
|
||||
}
|
||||
|
||||
private static ExternalTask convert(Task task) {
|
||||
if (task == null) return null;
|
||||
DefaultExternalTask externalTask = new DefaultExternalTask();
|
||||
externalTask.setDescription(task.getDescription());
|
||||
externalTask.setGroup(task.getGroup());
|
||||
externalTask.setName(task.getName());
|
||||
externalTask.setQName(task.getPath());
|
||||
//externalTask.setType(task.);
|
||||
return externalTask;
|
||||
}
|
||||
|
||||
private static CompilationDetailsImpl convert(org.gradle.tooling.model.cpp.CompilationDetails details) {
|
||||
CompilationDetailsImpl compilationDetails = new CompilationDetailsImpl();
|
||||
compilationDetails.setCompileTask(convert(details.getCompileTask()));
|
||||
compilationDetails.setAdditionalArgs(new ArrayList<>(details.getAdditionalArgs()));
|
||||
compilationDetails.setCompilerExecutable(details.getCompilerExecutable());
|
||||
compilationDetails.setCompileWorkingDir(details.getCompileWorkingDir());
|
||||
compilationDetails.setFrameworkSearchPaths(new ArrayList<>(details.getFrameworkSearchPaths()));
|
||||
compilationDetails.setHeaderDirs(new LinkedHashSet<>(details.getHeaderDirs()));
|
||||
compilationDetails.setMacroDefines(convert(details.getMacroDefines()));
|
||||
compilationDetails.setMacroUndefines(new LinkedHashSet<>(details.getMacroUndefines()));
|
||||
compilationDetails.setSources(convertSources(details.getSources()));
|
||||
compilationDetails.setSystemHeaderSearchPaths(new ArrayList<>(details.getSystemHeaderSearchPaths()));
|
||||
compilationDetails.setUserHeaderSearchPaths(new ArrayList<>(details.getUserHeaderSearchPaths()));
|
||||
return compilationDetails;
|
||||
}
|
||||
|
||||
private static Set<SourceFile> convertSources(DomainObjectSet<? extends org.gradle.tooling.model.cpp.SourceFile> sources) {
|
||||
Set<SourceFile> sourceFiles = new LinkedHashSet<>(sources.size());
|
||||
for (org.gradle.tooling.model.cpp.SourceFile sourceFile : sources) {
|
||||
sourceFiles.add(convert(sourceFile));
|
||||
}
|
||||
return sourceFiles;
|
||||
}
|
||||
|
||||
private static SourceFile convert(org.gradle.tooling.model.cpp.SourceFile sourceFile) {
|
||||
return new SourceFileImpl(sourceFile.getSourceFile(), sourceFile.getObjectFile());
|
||||
}
|
||||
|
||||
private static Set<MacroDirective> convert(DomainObjectSet<? extends org.gradle.tooling.model.cpp.MacroDirective> directives) {
|
||||
Set<MacroDirective> macroDirectives = new LinkedHashSet<>(directives.size());
|
||||
for (org.gradle.tooling.model.cpp.MacroDirective directive : directives) {
|
||||
macroDirectives.add(convert(directive));
|
||||
}
|
||||
return macroDirectives;
|
||||
}
|
||||
|
||||
private static MacroDirective convert(org.gradle.tooling.model.cpp.MacroDirective directive) {
|
||||
return new MacroDirectiveImpl(directive.getName(), directive.getValue());
|
||||
}
|
||||
|
||||
private static Set<File> getSourceFolders(CppComponent component) {
|
||||
Set<File> result = ContainerUtil.newLinkedHashSet();
|
||||
for (CppBinary binary : component.getBinaries()) {
|
||||
CompilationDetails compilationDetails = binary.getCompilationDetails();
|
||||
result.addAll(compilationDetails.getHeaderDirs());
|
||||
compilationDetails.getSources().forEach(sourceFile -> result.add(sourceFile.getSourceFile().getParentFile()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,13 @@ package org.jetbrains.plugins.gradle.nativeplatform.tooling.builder;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.component.SoftwareComponent;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.internal.project.DefaultProject;
|
||||
import org.gradle.api.plugins.PluginContainer;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.internal.impldep.org.apache.commons.lang.StringUtils;
|
||||
import org.gradle.internal.os.OperatingSystem;
|
||||
import org.gradle.language.cpp.CppBinary;
|
||||
import org.gradle.language.cpp.CppComponent;
|
||||
import org.gradle.language.cpp.CppSharedLibrary;
|
||||
import org.gradle.language.cpp.CppStaticLibrary;
|
||||
import org.gradle.language.cpp.*;
|
||||
import org.gradle.language.cpp.plugins.CppBasePlugin;
|
||||
import org.gradle.language.cpp.plugins.CppPlugin;
|
||||
import org.gradle.language.cpp.tasks.CppCompile;
|
||||
@@ -22,7 +18,11 @@ import org.gradle.language.nativeplatform.internal.ConfigurableComponentWithExec
|
||||
import org.gradle.nativeplatform.internal.CompilerOutputFileNamingScheme;
|
||||
import org.gradle.nativeplatform.internal.CompilerOutputFileNamingSchemeFactory;
|
||||
import org.gradle.nativeplatform.tasks.LinkExecutable;
|
||||
import org.gradle.nativeplatform.toolchain.*;
|
||||
import org.gradle.nativeplatform.test.cpp.CppTestSuite;
|
||||
import org.gradle.nativeplatform.toolchain.Clang;
|
||||
import org.gradle.nativeplatform.toolchain.Gcc;
|
||||
import org.gradle.nativeplatform.toolchain.NativeToolChain;
|
||||
import org.gradle.nativeplatform.toolchain.VisualCpp;
|
||||
import org.gradle.nativeplatform.toolchain.internal.NativeLanguageTools;
|
||||
import org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider;
|
||||
import org.gradle.nativeplatform.toolchain.internal.ToolType;
|
||||
@@ -32,12 +32,9 @@ import org.gradle.platform.base.internal.toolchain.ToolSearchResult;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSetImpl;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilerDetails;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppBinary.TargetType;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppFileSettings;
|
||||
import org.jetbrains.plugins.gradle.model.DefaultExternalTask;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppProject;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkerDetails;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFile;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl.*;
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder;
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService;
|
||||
@@ -51,9 +48,8 @@ import java.util.*;
|
||||
* The prototype of the C++ project gradle tooling model builder.
|
||||
* This implementation should be moved or replaced with the similar model builder from the Gradle distribution.
|
||||
*
|
||||
* @deprecated to be removed in 2019.1, use built-in 'org.gradle.tooling.model.cpp.CppComponent' available since Gradle 4.10
|
||||
*
|
||||
* @author Vladislav.Soroka
|
||||
* @deprecated to be removed in 2019.1, use built-in 'org.gradle.tooling.model.cpp.CppComponent' available since Gradle 4.10
|
||||
*/
|
||||
@Deprecated
|
||||
public class CppModelBuilder implements ModelBuilderService {
|
||||
@@ -73,8 +69,7 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object buildAll(final String modelName, final Project project) {
|
||||
// uncomment when 'org.gradle.tooling.model.cpp.CppComponent' will be used for the import
|
||||
if (!IS_41_OR_BETTER /*|| IS_410_OR_BETTER*/) {
|
||||
if (!IS_41_OR_BETTER || IS_410_OR_BETTER) {
|
||||
return null;
|
||||
}
|
||||
PluginContainer pluginContainer = project.getPlugins();
|
||||
@@ -90,31 +85,61 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
final CppProjectImpl cppProject = new CppProjectImpl();
|
||||
for (SoftwareComponent component : project.getComponents()) {
|
||||
if (component instanceof CppComponent) {
|
||||
File cppCompilerExecutable = null;
|
||||
CppComponent cppComponent = (CppComponent)component;
|
||||
String cppComponentName = cppComponent.getName();
|
||||
String cppComponentBaseName = cppComponent.getBaseName().get();
|
||||
|
||||
Set<File> headerDirs = new LinkedHashSet<File>(cppComponent.getPrivateHeaderDirs().getFiles());
|
||||
|
||||
CppComponentImpl ideCppComponent;
|
||||
if (cppComponent instanceof ProductionCppComponent) {
|
||||
ideCppComponent = new CppComponentImpl(cppComponentName, cppComponentBaseName);
|
||||
cppProject.setMainComponent(ideCppComponent);
|
||||
}
|
||||
else if (cppComponent instanceof CppTestSuite) {
|
||||
CppTestSuiteImpl cppTestSuite = new CppTestSuiteImpl(cppComponentName, cppComponentBaseName);
|
||||
ideCppComponent = cppTestSuite;
|
||||
cppProject.setTestComponent(cppTestSuite);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CppBinary cppBinary : cppComponent.getBinaries().get()) {
|
||||
if (cppCompilerExecutable == null) {
|
||||
cppCompilerExecutable = findCppCompilerExecutable(project, cppBinary);
|
||||
}
|
||||
|
||||
List<String> compilerArgs = new ArrayList<String>();
|
||||
Set<File> compileIncludePath = new LinkedHashSet<File>(cppBinary.getCompileIncludePath().getFiles());
|
||||
|
||||
Map<File, CppFileSettings> sources = new HashMap<File, CppFileSettings>();
|
||||
for (File file : cppBinary.getCppSource().getFiles()) {
|
||||
sources.put(file, new CppFileSettingsImpl());
|
||||
}
|
||||
|
||||
String binaryName = cppBinary.getName();
|
||||
String baseName = cppBinary.getBaseName().getOrElse("");
|
||||
String variantName = StringUtils.removeStart(cppBinary.getName(), "main");
|
||||
String compileTaskName = null;
|
||||
Set<File> systemIncludes = new LinkedHashSet<File>();
|
||||
Provider<CppCompile> compileTask = cppBinary.getCompileTask();
|
||||
if (compileTask.isPresent()) {
|
||||
CppCompile cppCompile = compileTask.get();
|
||||
compileTaskName = cppCompile.getPath();
|
||||
compilerArgs.addAll(cppCompile.getCompilerArgs().getOrElse(Collections.<String>emptyList()));
|
||||
String variantName = StringUtils.uncapitalize(StringUtils.removeStart(binaryName, "main"));
|
||||
|
||||
boolean isExecutable = cppBinary instanceof ComponentWithExecutable;
|
||||
CppBinaryImpl binary;
|
||||
if (cppBinary instanceof CppSharedLibrary) {
|
||||
binary = new CppSharedLibraryImpl(binaryName, baseName, variantName);
|
||||
}
|
||||
else if (cppBinary instanceof CppStaticLibrary) {
|
||||
binary = new CppStaticLibraryImpl(binaryName, baseName, variantName);
|
||||
}
|
||||
else if (isExecutable) {
|
||||
binary = new CppExecutableImpl(binaryName, baseName, variantName);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
ideCppComponent.addBinary(binary);
|
||||
|
||||
Provider<CppCompile> cppCompileProvider = cppBinary.getCompileTask();
|
||||
if (cppCompileProvider.isPresent()) {
|
||||
CppCompile cppCompile = cppCompileProvider.get();
|
||||
CompilationDetailsImpl compilationDetails = new CompilationDetailsImpl();
|
||||
binary.setCompilationDetails(compilationDetails);
|
||||
|
||||
String compileTaskName = cppCompile.getPath();
|
||||
DefaultExternalTask compileTask = new DefaultExternalTask();
|
||||
compileTask.setName(compileTaskName);
|
||||
compileTask.setQName(compileTaskName);
|
||||
compilationDetails.setCompileTask(compileTask);
|
||||
|
||||
Set<File> compileIncludePath = new LinkedHashSet<File>(cppBinary.getCompileIncludePath().getFiles());
|
||||
Set<File> systemIncludes = new LinkedHashSet<File>();
|
||||
//Since Gradle 4.8, system header include directories should be accessed separately via the systemIncludes property
|
||||
//see https://github.com/gradle/gradle-native/blob/master/docs/RELEASE-NOTES.md#better-control-over-system-include-path-for-native-compilation---583
|
||||
if (IS_48_OR_BETTER) {
|
||||
@@ -124,55 +149,50 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
else {
|
||||
systemIncludes.addAll(cppCompile.getIncludes().getFiles());
|
||||
}
|
||||
compilationDetails.setSystemHeaderSearchPaths(new ArrayList<File>(systemIncludes));
|
||||
compilationDetails.setUserHeaderSearchPaths(new ArrayList<File>(compileIncludePath));
|
||||
compilationDetails.setHeaderDirs(headerDirs);
|
||||
|
||||
appendFileSettings(sources, project, cppBinary, cppCompile);
|
||||
Set<SourceFile> sources = getSources(project, cppBinary, cppCompile);
|
||||
compilationDetails.setSources(sources);
|
||||
|
||||
File compilerWorkingDir = cppCompile.getObjectFileDir().get().getAsFile();
|
||||
compilationDetails.setCompileWorkingDir(compilerWorkingDir);
|
||||
File cppCompilerExecutable = findCppCompilerExecutable(project, cppBinary);
|
||||
compilationDetails.setCompilerExecutable(cppCompilerExecutable);
|
||||
|
||||
List<String> compilerArgs = new ArrayList<String>(cppCompile.getCompilerArgs().getOrElse(Collections.<String>emptyList()));
|
||||
compilationDetails.setAdditionalArgs(compilerArgs);
|
||||
}
|
||||
|
||||
File executableFile = null;
|
||||
String linkTaskName = null;
|
||||
boolean isExecutable = cppBinary instanceof ComponentWithExecutable;
|
||||
LinkageDetailsImpl linkageDetails = new LinkageDetailsImpl();
|
||||
binary.setLinkageDetails(linkageDetails);
|
||||
DefaultExternalTask linkTask = new DefaultExternalTask();
|
||||
linkageDetails.setLinkTask(linkTask);
|
||||
linkTask.setName("");
|
||||
linkTask.setQName("");
|
||||
if (isExecutable) {
|
||||
Provider<? extends LinkExecutable> fileProvider = ((ComponentWithExecutable)cppBinary).getLinkTask();
|
||||
if (fileProvider.isPresent()) {
|
||||
LinkExecutable linkExecutable = fileProvider.get();
|
||||
linkTaskName = linkExecutable.getPath();
|
||||
executableFile = getExecutableFile(linkExecutable);
|
||||
String linkTaskName = linkExecutable.getPath();
|
||||
linkTask.setName(linkTaskName);
|
||||
linkTask.setQName(linkTaskName);
|
||||
File executableFile = getExecutableFile(linkExecutable);
|
||||
linkageDetails.setOutputLocation(executableFile);
|
||||
}
|
||||
}
|
||||
|
||||
TargetType targetType = null;
|
||||
if (isExecutable) {
|
||||
targetType = TargetType.EXECUTABLE;
|
||||
}
|
||||
else if (cppBinary instanceof CppSharedLibrary) {
|
||||
targetType = TargetType.SHARED_LIBRARY;
|
||||
}
|
||||
else if (cppBinary instanceof CppStaticLibrary) {
|
||||
targetType = TargetType.STATIC_LIBRARY;
|
||||
}
|
||||
|
||||
// resolve compiler working dir as compiler executable file parent dir
|
||||
// https://github.com/gradle/gradle/blob/7422d5fc2e04d564dfd73bc539a37b62f8e2113a/subprojects/platform-native/src/main/java/org/gradle/nativeplatform/toolchain/internal/metadata/AbstractMetadataProvider.java#L61
|
||||
File compilerWorkingDir = cppCompilerExecutable == null ? null : cppCompilerExecutable.getParentFile();
|
||||
String compileKind = getCompilerKind(cppBinary);
|
||||
CompilerDetails compilerDetails = new CompilerDetailsImpl(
|
||||
compileKind, compileTaskName, cppCompilerExecutable, compilerWorkingDir, compilerArgs, compileIncludePath, systemIncludes);
|
||||
LinkerDetails linkerDetails = new LinkerDetailsImpl(linkTaskName, executableFile);
|
||||
cppProject.addBinary(new CppBinaryImpl(baseName, variantName, sources, compilerDetails, linkerDetails, targetType));
|
||||
}
|
||||
|
||||
addSourceFolders(cppProject, cppComponent);
|
||||
}
|
||||
}
|
||||
|
||||
return cppProject;
|
||||
}
|
||||
|
||||
private static void appendFileSettings(Map<File, CppFileSettings> sources,
|
||||
Project project,
|
||||
CppBinary cppBinary,
|
||||
CppCompile cppCompile) {
|
||||
|
||||
private static Set<SourceFile> getSources(Project project, CppBinary cppBinary, CppCompile cppCompile) {
|
||||
Set<SourceFile> sources = new LinkedHashSet<SourceFile>();
|
||||
for (File file : cppBinary.getCppSource().getFiles()) {
|
||||
sources.add(new SourceFileImpl(file, null));
|
||||
}
|
||||
if (cppCompile.getObjectFileDir().isPresent()) {
|
||||
File objectFileDir = cppCompile.getObjectFileDir().get().getAsFile();
|
||||
Iterator<CompilerOutputFileNamingSchemeFactory> it =
|
||||
@@ -183,34 +203,13 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
CompilerOutputFileNamingScheme outputFileNamingScheme = outputFileNamingSchemeFactory.create();
|
||||
outputFileNamingScheme.withOutputBaseFolder(objectFileDir).withObjectFileNameSuffix(objectFileExtension);
|
||||
|
||||
for (Map.Entry<File, CppFileSettings> fileSettingsEntry : sources.entrySet()) {
|
||||
File objectFile = outputFileNamingScheme.map(fileSettingsEntry.getKey());
|
||||
((CppFileSettingsImpl)fileSettingsEntry.getValue()).setObjectFile(objectFile);
|
||||
for (SourceFile sourceFile : sources) {
|
||||
File objectFile = outputFileNamingScheme.map(sourceFile.getSourceFile());
|
||||
((SourceFileImpl)sourceFile).setObjectFile(objectFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getCompilerKind(CppBinary cppBinary) {
|
||||
final String compileKind;
|
||||
NativeToolChain toolChain = cppBinary.getToolChain();
|
||||
if (toolChain instanceof Clang) {
|
||||
compileKind = "Clang";
|
||||
}
|
||||
else if (toolChain instanceof Gcc) {
|
||||
compileKind = "GCC";
|
||||
}
|
||||
else if (toolChain instanceof VisualCpp) {
|
||||
compileKind = "MSVC";
|
||||
}
|
||||
else if (toolChain instanceof Swiftc) {
|
||||
compileKind = "Swiftc";
|
||||
}
|
||||
else {
|
||||
compileKind = "Unknown";
|
||||
}
|
||||
return compileKind;
|
||||
return sources;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -236,24 +235,6 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
return executableFile;
|
||||
}
|
||||
|
||||
private static void addSourceFolders(final CppProjectImpl cppProject, CppComponent cppComponent) {
|
||||
for (File dir : cppComponent.getPrivateHeaderDirs()) {
|
||||
cppProject.addSourceFolder(
|
||||
new SourceFolderImpl(dir, new FilePatternSetImpl(Collections.<String>emptySet(), Collections.<String>emptySet())));
|
||||
}
|
||||
|
||||
FileCollection cppSource = cppComponent.getCppSource();
|
||||
// resolve cpp source folders
|
||||
Set<File> dirs = new LinkedHashSet<File>();
|
||||
for (File file : cppSource.getFiles()) {
|
||||
dirs.add(file.getParentFile());
|
||||
}
|
||||
for (File dir : dirs) {
|
||||
cppProject.addSourceFolder(new SourceFolderImpl(
|
||||
dir, new FilePatternSetImpl(Collections.<String>emptySet(), Collections.<String>emptySet())));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static File findCppCompilerExecutable(Project project, CppBinary cppBinary) {
|
||||
Throwable throwable = null;
|
||||
@@ -266,6 +247,7 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
}
|
||||
else {
|
||||
Method isToolAvailableMethod = toolProvider.getClass().getDeclaredMethod("isToolAvailable", ToolType.class);
|
||||
isToolAvailableMethod.setAccessible(true);
|
||||
toolSearchResult = (ToolSearchResult)isToolAvailableMethod.invoke(toolProvider, ToolType.CPP_COMPILER);
|
||||
}
|
||||
if (toolSearchResult.isAvailable()) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CompilationDetails extends Serializable {
|
||||
ExternalTask getCompileTask();
|
||||
|
||||
@Nullable
|
||||
File getCompilerExecutable();
|
||||
|
||||
File getCompileWorkingDir();
|
||||
|
||||
@NotNull
|
||||
List<File> getFrameworkSearchPaths();
|
||||
|
||||
@NotNull
|
||||
List<File> getSystemHeaderSearchPaths();
|
||||
|
||||
@NotNull
|
||||
List<File> getUserHeaderSearchPaths();
|
||||
|
||||
@NotNull
|
||||
Set<? extends SourceFile> getSources();
|
||||
|
||||
@NotNull
|
||||
Set<File> getHeaderDirs();
|
||||
|
||||
@NotNull
|
||||
Set<? extends MacroDirective> getMacroDefines();
|
||||
|
||||
@NotNull
|
||||
Set<String> getMacroUndefines();
|
||||
|
||||
@NotNull
|
||||
List<String> getAdditionalArgs();
|
||||
}
|
||||
@@ -1,45 +1,20 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CppBinary extends Serializable {
|
||||
/**
|
||||
* Returns the base name of this component. This is used by Gradle to calculate output file names.
|
||||
*/
|
||||
String getBaseName();
|
||||
|
||||
/**
|
||||
* Returns the binary variant name, e.g. Debug, Release etc.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
String getVariantName();
|
||||
|
||||
Map<File, CppFileSettings> getSources();
|
||||
String getBaseName();
|
||||
|
||||
CompilerDetails getCompilerDetails();
|
||||
CompilationDetails getCompilationDetails();
|
||||
|
||||
Set<File> getCompileIncludePath();
|
||||
|
||||
File getCompilerExecutable();
|
||||
|
||||
List<String> getCompilerArgs();
|
||||
|
||||
LinkerDetails getLinkerDetails();
|
||||
|
||||
File getOutputFile();
|
||||
|
||||
TargetType getTargetType();
|
||||
|
||||
enum TargetType {
|
||||
EXECUTABLE,
|
||||
STATIC_LIBRARY,
|
||||
SHARED_LIBRARY
|
||||
}
|
||||
LinkageDetails getLinkageDetails();
|
||||
}
|
||||
|
||||
+6
-7
@@ -1,14 +1,13 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface LinkerDetails extends Serializable {
|
||||
File getOutputFile();
|
||||
public interface CppComponent extends Serializable {
|
||||
String getName();
|
||||
|
||||
String getLinkTaskName();
|
||||
String getBaseName();
|
||||
|
||||
Set<? extends CppBinary> getBinaries();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
public interface CppExecutable extends CppBinary {
|
||||
}
|
||||
@@ -2,14 +2,17 @@
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CppProject extends Serializable {
|
||||
Set<SourceFolder> getSourceFolders();
|
||||
@Nullable
|
||||
CppComponent getMainComponent();
|
||||
|
||||
Set<CppBinary> getBinaries();
|
||||
@Nullable
|
||||
CppTestSuite getTestComponent();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
public interface CppSharedLibrary extends CppBinary {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
public interface CppStaticLibrary extends CppBinary {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
public interface CppTestSuite extends CppComponent {
|
||||
}
|
||||
+8
-13
@@ -1,26 +1,21 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CompilerDetails extends Serializable {
|
||||
String getCompileTaskName();
|
||||
public interface LinkageDetails extends Serializable {
|
||||
ExternalTask getLinkTask();
|
||||
|
||||
String getCompilerKind();
|
||||
File getOutputLocation();
|
||||
|
||||
Set<File> getIncludePath();
|
||||
|
||||
Set<File> getSystemIncludes();
|
||||
|
||||
File getExecutable();
|
||||
|
||||
File getWorkingDir();
|
||||
|
||||
List<String> getArgs();
|
||||
@NotNull
|
||||
List<String> getAdditionalArgs();
|
||||
}
|
||||
+5
-8
@@ -1,16 +1,13 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface SourceFolder extends Serializable {
|
||||
File getBaseDir();
|
||||
public interface MacroDirective extends Serializable {
|
||||
String getName();
|
||||
|
||||
FilePatternSet getPatterns();
|
||||
@Nullable
|
||||
String getValue();
|
||||
}
|
||||
+3
-1
@@ -4,6 +4,8 @@ package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface CppFileSettings extends Serializable {
|
||||
public interface SourceFile extends Serializable {
|
||||
File getSourceFile();
|
||||
|
||||
File getObjectFile();
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.DefaultExternalTask;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalTask;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilationDetails;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.MacroDirective;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CompilationDetailsImpl implements CompilationDetails {
|
||||
|
||||
private File myCompilerExecutable;
|
||||
private ExternalTask myCompileTask;
|
||||
private File myCompileWorkingDir;
|
||||
@NotNull
|
||||
private List<File> myFrameworkSearchPaths;
|
||||
@NotNull
|
||||
private List<File> mySystemHeaderSearchPaths;
|
||||
@NotNull
|
||||
private List<File> myUserHeaderSearchPaths;
|
||||
@NotNull
|
||||
private Set<SourceFile> mySources;
|
||||
@NotNull
|
||||
private Set<File> myHeaderDirs;
|
||||
@NotNull
|
||||
private Set<MacroDirective> myMacroDefines;
|
||||
@NotNull
|
||||
private Set<String> myMacroUndefines;
|
||||
@NotNull
|
||||
private List<String> myAdditionalArgs;
|
||||
|
||||
public CompilationDetailsImpl() {
|
||||
myFrameworkSearchPaths = Collections.emptyList();
|
||||
mySystemHeaderSearchPaths = Collections.emptyList();
|
||||
myUserHeaderSearchPaths = Collections.emptyList();
|
||||
mySources = Collections.emptySet();
|
||||
myHeaderDirs = Collections.emptySet();
|
||||
myMacroDefines = Collections.emptySet();
|
||||
myMacroUndefines = Collections.emptySet();
|
||||
myAdditionalArgs = Collections.emptyList();
|
||||
}
|
||||
|
||||
public CompilationDetailsImpl(CompilationDetails compilationDetails) {
|
||||
myCompilerExecutable = compilationDetails.getCompilerExecutable();
|
||||
myCompileTask = new DefaultExternalTask(compilationDetails.getCompileTask());
|
||||
myCompileWorkingDir = compilationDetails.getCompileWorkingDir();
|
||||
myFrameworkSearchPaths = new ArrayList<File>(compilationDetails.getFrameworkSearchPaths());
|
||||
mySystemHeaderSearchPaths = new ArrayList<File>(compilationDetails.getSystemHeaderSearchPaths());
|
||||
myUserHeaderSearchPaths = new ArrayList<File>(compilationDetails.getUserHeaderSearchPaths());
|
||||
mySources = new LinkedHashSet<SourceFile>(compilationDetails.getSources().size());
|
||||
for (SourceFile source : compilationDetails.getSources()) {
|
||||
mySources.add(new SourceFileImpl(source));
|
||||
}
|
||||
myHeaderDirs = new LinkedHashSet<File>(compilationDetails.getHeaderDirs());
|
||||
|
||||
myMacroDefines = new LinkedHashSet<MacroDirective>(compilationDetails.getMacroDefines().size());
|
||||
for (MacroDirective macroDirective : compilationDetails.getMacroDefines()) {
|
||||
myMacroDefines.add(new MacroDirectiveImpl(macroDirective));
|
||||
}
|
||||
myMacroUndefines = new LinkedHashSet<String>(compilationDetails.getMacroUndefines());
|
||||
myAdditionalArgs = new ArrayList<String>(compilationDetails.getAdditionalArgs());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalTask getCompileTask() {
|
||||
return myCompileTask;
|
||||
}
|
||||
|
||||
public void setCompileTask(ExternalTask compileTask) {
|
||||
myCompileTask = compileTask;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getCompilerExecutable() {
|
||||
return myCompilerExecutable;
|
||||
}
|
||||
|
||||
public void setCompilerExecutable(File compilerExecutable) {
|
||||
myCompilerExecutable = compilerExecutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getCompileWorkingDir() {
|
||||
return myCompileWorkingDir;
|
||||
}
|
||||
|
||||
public void setCompileWorkingDir(File compileWorkingDir) {
|
||||
myCompileWorkingDir = compileWorkingDir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<File> getFrameworkSearchPaths() {
|
||||
return myFrameworkSearchPaths;
|
||||
}
|
||||
|
||||
public void setFrameworkSearchPaths(@NotNull List<File> frameworkSearchPaths) {
|
||||
myFrameworkSearchPaths = frameworkSearchPaths;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<File> getSystemHeaderSearchPaths() {
|
||||
return mySystemHeaderSearchPaths;
|
||||
}
|
||||
|
||||
public void setSystemHeaderSearchPaths(@NotNull List<File> systemHeaderSearchPaths) {
|
||||
mySystemHeaderSearchPaths = systemHeaderSearchPaths;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<File> getUserHeaderSearchPaths() {
|
||||
return myUserHeaderSearchPaths;
|
||||
}
|
||||
|
||||
public void setUserHeaderSearchPaths(@NotNull List<File> userHeaderSearchPaths) {
|
||||
myUserHeaderSearchPaths = userHeaderSearchPaths;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<? extends SourceFile> getSources() {
|
||||
return mySources;
|
||||
}
|
||||
|
||||
public void setSources(@NotNull Set<SourceFile> sources) {
|
||||
mySources = sources;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<File> getHeaderDirs() {
|
||||
return myHeaderDirs;
|
||||
}
|
||||
|
||||
public void setHeaderDirs(@NotNull Set<File> headerDirs) {
|
||||
myHeaderDirs = headerDirs;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<? extends MacroDirective> getMacroDefines() {
|
||||
return myMacroDefines;
|
||||
}
|
||||
|
||||
public void setMacroDefines(@NotNull Set<MacroDirective> macroDefines) {
|
||||
myMacroDefines = macroDefines;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getMacroUndefines() {
|
||||
return myMacroUndefines;
|
||||
}
|
||||
|
||||
public void setMacroUndefines(@NotNull Set<String> macroUndefines) {
|
||||
myMacroUndefines = macroUndefines;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getAdditionalArgs() {
|
||||
return myAdditionalArgs;
|
||||
}
|
||||
|
||||
public void setAdditionalArgs(@NotNull List<String> additionalArgs) {
|
||||
myAdditionalArgs = additionalArgs;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilerDetails;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CompilerDetailsImpl implements CompilerDetails {
|
||||
|
||||
private final Set<File> myIncludePath;
|
||||
private final Set<File> mySystemIncludes;
|
||||
private final String myCompileTaskName;
|
||||
private final String myCompileKind;
|
||||
private final File myExecutable;
|
||||
private final File myWorkingDir;
|
||||
private final List<String> myArgs;
|
||||
|
||||
public CompilerDetailsImpl(String compileKind,
|
||||
String compileTaskName,
|
||||
File executable,
|
||||
File workingDir,
|
||||
List<String> args,
|
||||
Set<File> includePath,
|
||||
Set<File> systemIncludes) {
|
||||
myCompileKind = compileKind;
|
||||
myCompileTaskName = compileTaskName;
|
||||
myExecutable = executable;
|
||||
myWorkingDir = workingDir;
|
||||
myArgs = args;
|
||||
myIncludePath = new LinkedHashSet<File>(includePath);
|
||||
mySystemIncludes = new LinkedHashSet<File>(systemIncludes);
|
||||
}
|
||||
|
||||
public CompilerDetailsImpl(CompilerDetails details) {
|
||||
this(details.getCompilerKind(), details.getCompileTaskName(), details.getExecutable(), details.getWorkingDir(), details.getArgs(),
|
||||
details.getIncludePath(), details.getSystemIncludes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompileTaskName() {
|
||||
return myCompileTaskName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompilerKind() {
|
||||
return myCompileKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getIncludePath() {
|
||||
return Collections.unmodifiableSet(myIncludePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getSystemIncludes() {
|
||||
return Collections.unmodifiableSet(mySystemIncludes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getExecutable() {
|
||||
return myExecutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDir() {
|
||||
return myWorkingDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getArgs() {
|
||||
return Collections.unmodifiableList(myArgs);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,36 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilerDetails;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppBinary;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppFileSettings;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkerDetails;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CppBinaryImpl implements CppBinary {
|
||||
private final String myName;
|
||||
private final String myBaseName;
|
||||
private final String myVariantName;
|
||||
private final Map<File, CppFileSettings> mySources;
|
||||
private final CompilerDetails myCompilerDetails;
|
||||
private final LinkerDetails myLinkerDetails;
|
||||
private final TargetType myTargetType;
|
||||
private CompilationDetailsImpl myCompilationDetails;
|
||||
private LinkageDetailsImpl myLinkageDetails;
|
||||
|
||||
public CppBinaryImpl(String baseName, String variantName,
|
||||
Map<File, CppFileSettings> sources,
|
||||
CompilerDetails compilerDetails,
|
||||
LinkerDetails linkerDetails,
|
||||
TargetType targetType) {
|
||||
public CppBinaryImpl(String name, String baseName, String variantName) {
|
||||
myName = name;
|
||||
myBaseName = baseName;
|
||||
myVariantName = variantName;
|
||||
mySources = new LinkedHashMap<File, CppFileSettings>();
|
||||
for (Map.Entry<File, CppFileSettings> fileSettingsEntry : sources.entrySet()) {
|
||||
mySources.put(fileSettingsEntry.getKey(), new CppFileSettingsImpl(fileSettingsEntry.getValue()));
|
||||
}
|
||||
myCompilerDetails = compilerDetails;
|
||||
myLinkerDetails = linkerDetails;
|
||||
myTargetType = targetType;
|
||||
myCompilationDetails = new CompilationDetailsImpl();
|
||||
myLinkageDetails = new LinkageDetailsImpl();
|
||||
}
|
||||
|
||||
public CppBinaryImpl(CppBinary binary) {
|
||||
this(binary.getBaseName(), binary.getVariantName(), binary.getSources(),
|
||||
new CompilerDetailsImpl(binary.getCompilerDetails()), new LinkerDetailsImpl(binary.getLinkerDetails()), binary.getTargetType());
|
||||
this(binary.getName(), binary.getBaseName(), binary.getVariantName());
|
||||
myCompilationDetails = new CompilationDetailsImpl(binary.getCompilationDetails());
|
||||
myLinkageDetails = new LinkageDetailsImpl(binary.getLinkageDetails());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return myBaseName;
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,42 +39,25 @@ public class CppBinaryImpl implements CppBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<File, CppFileSettings> getSources() {
|
||||
return Collections.unmodifiableMap(mySources);
|
||||
public String getBaseName() {
|
||||
return myBaseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerDetails getCompilerDetails() {
|
||||
return myCompilerDetails;
|
||||
public CompilationDetailsImpl getCompilationDetails() {
|
||||
return myCompilationDetails;
|
||||
}
|
||||
|
||||
public void setCompilationDetails(@NotNull CompilationDetailsImpl compilationDetails) {
|
||||
myCompilationDetails = compilationDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getCompileIncludePath() {
|
||||
return myCompilerDetails.getIncludePath();
|
||||
public LinkageDetailsImpl getLinkageDetails() {
|
||||
return myLinkageDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getCompilerExecutable() {
|
||||
return myCompilerDetails.getExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilerArgs() {
|
||||
return myCompilerDetails.getArgs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkerDetails getLinkerDetails() {
|
||||
return myLinkerDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getOutputFile() {
|
||||
return myLinkerDetails.getOutputFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetType getTargetType() {
|
||||
return myTargetType;
|
||||
public void setLinkageDetails(@NotNull LinkageDetailsImpl linkageDetails) {
|
||||
myLinkageDetails = linkageDetails;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.*;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CppComponentImpl implements CppComponent {
|
||||
private final String myName;
|
||||
private final String myBaseName;
|
||||
private final Set<CppBinary> myBinaries;
|
||||
|
||||
public CppComponentImpl(String name, String baseName) {
|
||||
myName = name;
|
||||
myBaseName = baseName;
|
||||
myBinaries = new LinkedHashSet<CppBinary>();
|
||||
}
|
||||
|
||||
public CppComponentImpl(CppComponent component) {
|
||||
this(component.getName(), component.getBaseName());
|
||||
for (CppBinary binary : component.getBinaries()) {
|
||||
myBinaries.add(newCopy(binary));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return myBaseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends CppBinary> getBinaries() {
|
||||
return myBinaries;
|
||||
}
|
||||
|
||||
public void addBinary(CppBinary binary) {
|
||||
myBinaries.add(binary);
|
||||
}
|
||||
|
||||
|
||||
private static CppBinary newCopy(CppBinary binary) {
|
||||
if (binary instanceof CppSharedLibrary) {
|
||||
return new CppSharedLibraryImpl((CppSharedLibrary)binary);
|
||||
}
|
||||
if (binary instanceof CppStaticLibrary) {
|
||||
return new CppStaticLibraryImpl((CppStaticLibrary)binary);
|
||||
}
|
||||
if (binary instanceof CppExecutable) {
|
||||
return new CppExecutableImpl((CppExecutable)binary);
|
||||
}
|
||||
return new CppBinaryImpl(binary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppExecutable;
|
||||
|
||||
public class CppExecutableImpl extends CppBinaryImpl implements CppExecutable {
|
||||
public CppExecutableImpl(String name, String baseName, String variantName) {
|
||||
super(name, baseName, variantName);
|
||||
}
|
||||
|
||||
public CppExecutableImpl(CppExecutable binary) {
|
||||
super(binary);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppFileSettings;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CppFileSettingsImpl implements CppFileSettings {
|
||||
|
||||
private File myObjectFile;
|
||||
|
||||
public CppFileSettingsImpl() {
|
||||
}
|
||||
|
||||
public CppFileSettingsImpl(CppFileSettings fileSettings) {
|
||||
myObjectFile = fileSettings.getObjectFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getObjectFile() {
|
||||
return myObjectFile;
|
||||
}
|
||||
|
||||
public void setObjectFile(File objectFile) {
|
||||
myObjectFile = objectFile;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,52 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppBinary;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppComponent;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppProject;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFolder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppTestSuite;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CppProjectImpl implements CppProject {
|
||||
|
||||
private final Set<SourceFolder> mySourceFolders = new LinkedHashSet<SourceFolder>();
|
||||
private final Set<CppBinary> binaries = new LinkedHashSet<CppBinary>();
|
||||
@Nullable
|
||||
private CppComponent myMainComponent;
|
||||
@Nullable
|
||||
private CppTestSuite myTestComponent;
|
||||
|
||||
public CppProjectImpl() {
|
||||
}
|
||||
|
||||
public CppProjectImpl(CppProject cppProject) {
|
||||
for (CppBinary binary : cppProject.getBinaries()) {
|
||||
addBinary(new CppBinaryImpl(binary));
|
||||
CppComponent mainComponent = cppProject.getMainComponent();
|
||||
if (mainComponent != null) {
|
||||
myMainComponent = new CppComponentImpl(mainComponent);
|
||||
}
|
||||
for (SourceFolder sourceFolder : cppProject.getSourceFolders()) {
|
||||
addSourceFolder(new SourceFolderImpl(sourceFolder));
|
||||
CppTestSuite testComponent = cppProject.getTestComponent();
|
||||
if (testComponent != null) {
|
||||
myTestComponent = new CppTestSuiteImpl(testComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Set<SourceFolder> getSourceFolders() {
|
||||
return Collections.unmodifiableSet(mySourceFolders);
|
||||
public CppComponent getMainComponent() {
|
||||
return myMainComponent;
|
||||
}
|
||||
|
||||
public void addSourceFolder(SourceFolder folder) {
|
||||
mySourceFolders.add(folder);
|
||||
public void setMainComponent(@Nullable CppComponent mainComponent) {
|
||||
myMainComponent = mainComponent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Set<CppBinary> getBinaries() {
|
||||
return Collections.unmodifiableSet(binaries);
|
||||
public CppTestSuite getTestComponent() {
|
||||
return myTestComponent;
|
||||
}
|
||||
|
||||
public void addBinary(CppBinary binary) {
|
||||
binaries.add(binary);
|
||||
public void setTestComponent(@Nullable CppTestSuite testComponent) {
|
||||
myTestComponent = testComponent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppSharedLibrary;
|
||||
|
||||
public class CppSharedLibraryImpl extends CppBinaryImpl implements CppSharedLibrary {
|
||||
public CppSharedLibraryImpl(String name, String baseName, String variantName) {
|
||||
super(name, baseName, variantName);
|
||||
}
|
||||
|
||||
public CppSharedLibraryImpl(CppSharedLibrary binary) {
|
||||
super(binary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppStaticLibrary;
|
||||
|
||||
public class CppStaticLibraryImpl extends CppBinaryImpl implements CppStaticLibrary {
|
||||
public CppStaticLibraryImpl(String name, String baseName, String variantName) {
|
||||
super(name, baseName, variantName);
|
||||
}
|
||||
|
||||
public CppStaticLibraryImpl(CppStaticLibrary binary) {
|
||||
super(binary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppTestSuite;
|
||||
|
||||
public class CppTestSuiteImpl extends CppComponentImpl implements CppTestSuite {
|
||||
public CppTestSuiteImpl(String name, String baseName) {
|
||||
super(name, baseName);
|
||||
}
|
||||
|
||||
public CppTestSuiteImpl(CppTestSuite component) {
|
||||
super(component);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.model.DefaultExternalTask;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalTask;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkageDetails;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class LinkageDetailsImpl implements LinkageDetails {
|
||||
private ExternalTask myLinkTask;
|
||||
private File myOutputLocation;
|
||||
@NotNull
|
||||
private List<String> myAdditionalArgs;
|
||||
|
||||
public LinkageDetailsImpl() {
|
||||
myAdditionalArgs = Collections.emptyList();
|
||||
}
|
||||
|
||||
public LinkageDetailsImpl(LinkageDetails details) {
|
||||
myLinkTask = new DefaultExternalTask(details.getLinkTask());
|
||||
myOutputLocation = details.getOutputLocation();
|
||||
myAdditionalArgs = new ArrayList<String>(details.getAdditionalArgs());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalTask getLinkTask() {
|
||||
return myLinkTask;
|
||||
}
|
||||
|
||||
public void setLinkTask(ExternalTask linkTask) {
|
||||
myLinkTask = linkTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getOutputLocation() {
|
||||
return myOutputLocation;
|
||||
}
|
||||
|
||||
public void setOutputLocation(File outputLocation) {
|
||||
myOutputLocation = outputLocation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getAdditionalArgs() {
|
||||
return myAdditionalArgs;
|
||||
}
|
||||
|
||||
public void setAdditionalArgs(@NotNull List<String> additionalArgs) {
|
||||
myAdditionalArgs = additionalArgs;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkerDetails;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class LinkerDetailsImpl implements LinkerDetails {
|
||||
private final String myLinkTaskName;
|
||||
private final File myOutputFile;
|
||||
|
||||
public LinkerDetailsImpl(String linkTaskName, File outputFile) {
|
||||
myLinkTaskName = linkTaskName;
|
||||
myOutputFile = outputFile;
|
||||
}
|
||||
|
||||
public LinkerDetailsImpl(LinkerDetails details) {
|
||||
this(details.getLinkTaskName(), details.getOutputFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getOutputFile() {
|
||||
return myOutputFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkTaskName() {
|
||||
return myLinkTaskName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.MacroDirective;
|
||||
|
||||
public class MacroDirectiveImpl implements MacroDirective {
|
||||
|
||||
private String myName;
|
||||
private String myValue;
|
||||
|
||||
public MacroDirectiveImpl(String name, String value) {
|
||||
myName = name;
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public MacroDirectiveImpl(MacroDirective directive) {
|
||||
this(directive.getName(), directive.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
myValue = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SourceFileImpl implements SourceFile {
|
||||
private File mySourceFile;
|
||||
private File myObjectFile;
|
||||
|
||||
public SourceFileImpl() {
|
||||
}
|
||||
|
||||
public SourceFileImpl(File sourceFile, File objectFile) {
|
||||
mySourceFile = sourceFile;
|
||||
myObjectFile = objectFile;
|
||||
}
|
||||
|
||||
public SourceFileImpl(SourceFile source) {
|
||||
this(source.getSourceFile(), source.getObjectFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSourceFile() {
|
||||
return mySourceFile;
|
||||
}
|
||||
|
||||
public void setSourceFile(File sourceFile) {
|
||||
mySourceFile = sourceFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getObjectFile() {
|
||||
return myObjectFile;
|
||||
}
|
||||
|
||||
public void setObjectFile(File objectFile) {
|
||||
myObjectFile = objectFile;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSet;
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSetImpl;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFolder;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class SourceFolderImpl implements SourceFolder {
|
||||
private final File myBaseDir;
|
||||
private final FilePatternSet myPatterns;
|
||||
|
||||
public SourceFolderImpl(File dir, FilePatternSet patterns) {
|
||||
myBaseDir = dir;
|
||||
myPatterns = patterns;
|
||||
}
|
||||
|
||||
public SourceFolderImpl(SourceFolder folder) {
|
||||
this(folder.getBaseDir(), folder.getPatterns() != null
|
||||
? new FilePatternSetImpl(folder.getPatterns().getIncludes(), folder.getPatterns().getExcludes()) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getBaseDir() {
|
||||
return myBaseDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilePatternSet getPatterns() {
|
||||
return myPatterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SourceFolderImpl folder = (SourceFolderImpl)o;
|
||||
|
||||
if (myBaseDir != null ? !myBaseDir.equals(folder.myBaseDir) : folder.myBaseDir != null) return false;
|
||||
if (myPatterns != null ? !myPatterns.equals(folder.myPatterns) : folder.myPatterns != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myBaseDir != null ? myBaseDir.hashCode() : 0;
|
||||
result = 31 * result + (myPatterns != null ? myPatterns.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+10
@@ -655,6 +655,16 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class> getTargetTypes() {
|
||||
return ContainerUtil.set(
|
||||
ExternalProjectDependency.class,
|
||||
ExternalLibraryDependency.class,
|
||||
FileCollectionDependency.class,
|
||||
UnresolvedExternalDependency.class
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Pair<String, String>> getExtraJvmArgs() {
|
||||
|
||||
+2
@@ -225,6 +225,8 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
// pre-import checks
|
||||
resolverExtension.preImportCheck();
|
||||
|
||||
projectImportAction.addTargetTypes(resolverExtension.getTargetTypes());
|
||||
|
||||
if(!resolverCtx.isPreviewMode()){
|
||||
// register classes of extra gradle project models required for extensions (e.g. com.android.builder.model.AndroidProject)
|
||||
try {
|
||||
|
||||
+9
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.GradleManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -103,6 +104,14 @@ public interface GradleProjectResolverExtension extends ParametersEnhancer {
|
||||
@NotNull
|
||||
Set<Class> getToolingExtensionsClasses();
|
||||
|
||||
/**
|
||||
* add target types to be used in the polymorphic containers
|
||||
* @return
|
||||
*/
|
||||
default Set<Class> getTargetTypes() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
List<Pair<String, String>> getExtraJvmArgs();
|
||||
|
||||
|
||||
+9
-5
@@ -40,6 +40,7 @@ import java.util.*;
|
||||
public class ProjectImportAction implements BuildAction<ProjectImportAction.AllModels>, Serializable {
|
||||
|
||||
private final Set<Class> myExtraProjectModelClasses = new LinkedHashSet<Class>();
|
||||
private final Set<Class> myTargetTypes = new LinkedHashSet<Class>();
|
||||
private final boolean myIsPreviewMode;
|
||||
private final boolean myIsGradleProjectDirSupported;
|
||||
private final boolean myIsCompositeBuildsSupported;
|
||||
@@ -58,6 +59,10 @@ public class ProjectImportAction implements BuildAction<ProjectImportAction.AllM
|
||||
myExtraProjectModelClasses.addAll(projectModelClasses);
|
||||
}
|
||||
|
||||
public void addTargetTypes(@NotNull Set<Class> targetTypes) {
|
||||
myTargetTypes.addAll(targetTypes);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AllModels execute(final BuildController controller) {
|
||||
@@ -100,7 +105,7 @@ public class ProjectImportAction implements BuildAction<ProjectImportAction.AllM
|
||||
return allModels;
|
||||
}
|
||||
|
||||
private static void configureAdditionalTypes(BuildController controller) {
|
||||
private void configureAdditionalTypes(BuildController controller) {
|
||||
try {
|
||||
Field adapterField;
|
||||
try {
|
||||
@@ -126,10 +131,9 @@ public class ProjectImportAction implements BuildAction<ProjectImportAction.AllM
|
||||
//noinspection unchecked
|
||||
Map<String, Class<?>> targetTypes = (Map<String, Class<?>>)targetTypesField.get(typeProvider);
|
||||
|
||||
targetTypes.put(ExternalProjectDependency.class.getCanonicalName(), ExternalProjectDependency.class);
|
||||
targetTypes.put(ExternalLibraryDependency.class.getCanonicalName(), ExternalLibraryDependency.class);
|
||||
targetTypes.put(FileCollectionDependency.class.getCanonicalName(), FileCollectionDependency.class);
|
||||
targetTypes.put(UnresolvedExternalDependency.class.getCanonicalName(), UnresolvedExternalDependency.class);
|
||||
for (Class targetType : myTargetTypes) {
|
||||
targetTypes.put(targetType.getCanonicalName(), targetType);
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
// TODO handle error
|
||||
|
||||
Reference in New Issue
Block a user