mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Gradle/C++: import compiler kind
This commit is contained in:
@@ -24,10 +24,7 @@ import org.gradle.language.cpp.tasks.CppCompile;
|
||||
import org.gradle.language.nativeplatform.ComponentWithExecutable;
|
||||
import org.gradle.language.nativeplatform.internal.ConfigurableComponentWithExecutable;
|
||||
import org.gradle.nativeplatform.tasks.LinkExecutable;
|
||||
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.*;
|
||||
import org.gradle.nativeplatform.toolchain.internal.NativeLanguageTools;
|
||||
import org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider;
|
||||
import org.gradle.nativeplatform.toolchain.internal.ToolType;
|
||||
@@ -129,8 +126,9 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
// 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(
|
||||
compileTaskName, cppCompilerExecutable, compilerWorkingDir, compilerArgs, compileIncludePath, systemIncludes);
|
||||
compileKind, compileTaskName, cppCompilerExecutable, compilerWorkingDir, compilerArgs, compileIncludePath, systemIncludes);
|
||||
LinkerDetails linkerDetails = new LinkerDetailsImpl(linkTaskName, executableFile);
|
||||
cppProject.addBinary(new CppBinaryImpl(baseName, variantName, sources, compilerDetails, linkerDetails, targetType));
|
||||
}
|
||||
@@ -142,6 +140,28 @@ public class CppModelBuilder implements ModelBuilderService {
|
||||
return cppProject;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static File getExecutableFile(LinkExecutable linkExecutable) {
|
||||
File executableFile;
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.util.Set;
|
||||
public interface CompilerDetails extends Serializable {
|
||||
String getCompileTaskName();
|
||||
|
||||
String getCompilerKind();
|
||||
|
||||
Set<File> getIncludePath();
|
||||
|
||||
Set<File> getSystemIncludes();
|
||||
|
||||
@@ -17,16 +17,19 @@ 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 compileTaskName,
|
||||
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;
|
||||
@@ -36,7 +39,7 @@ public class CompilerDetailsImpl implements CompilerDetails {
|
||||
}
|
||||
|
||||
public CompilerDetailsImpl(CompilerDetails details) {
|
||||
this(details.getCompileTaskName(), details.getExecutable(), details.getWorkingDir(), details.getArgs(),
|
||||
this(details.getCompilerKind(), details.getCompileTaskName(), details.getExecutable(), details.getWorkingDir(), details.getArgs(),
|
||||
details.getIncludePath(), details.getSystemIncludes());
|
||||
}
|
||||
|
||||
@@ -45,6 +48,11 @@ public class CompilerDetailsImpl implements CompilerDetails {
|
||||
return myCompileTaskName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompilerKind() {
|
||||
return myCompileKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getIncludePath() {
|
||||
return Collections.unmodifiableSet(myIncludePath);
|
||||
|
||||
Reference in New Issue
Block a user