use of org.gradle.nativeplatform.platform.internal.ArchitectureInternal in project gradle by gradle.
the class GccVersionDeterminer method transform.
private GccVersionResult transform(String output, File gccBinary) {
BufferedReader reader = new BufferedReader(new StringReader(output));
String line;
Map<String, String> defines = new HashMap<String, String>();
try {
while ((line = reader.readLine()) != null) {
Matcher matcher = DEFINE_PATTERN.matcher(line);
if (!matcher.matches()) {
return new BrokenResult(String.format("Could not determine %s version: %s produced unexpected output.", getDescription(), gccBinary.getName()));
}
defines.put(matcher.group(1), matcher.group(2));
}
} catch (IOException e) {
// Should not happen reading from a StringReader
throw new UncheckedIOException(e);
}
if (!defines.containsKey("__GNUC__")) {
return new BrokenResult(String.format("Could not determine %s version: %s produced unexpected output.", getDescription(), gccBinary.getName()));
}
int major;
int minor;
int patch;
if (clang) {
if (!defines.containsKey("__clang__")) {
return new BrokenResult(String.format("%s appears to be GCC rather than Clang. Treating it as GCC.", gccBinary.getName()));
}
major = toInt(defines.get("__clang_major__"));
minor = toInt(defines.get("__clang_minor__"));
patch = toInt(defines.get("__clang_patchlevel__"));
} else {
if (defines.containsKey("__clang__")) {
return new BrokenResult(String.format("XCode %s is a wrapper around Clang. Treating it as Clang and not GCC.", gccBinary.getName()));
}
major = toInt(defines.get("__GNUC__"));
minor = toInt(defines.get("__GNUC_MINOR__"));
patch = toInt(defines.get("__GNUC_PATCHLEVEL__"));
}
final ArchitectureInternal architecture = determineArchitecture(defines);
return new DefaultGccVersionResult(new VersionNumber(major, minor, patch, null), architecture, clang);
}
use of org.gradle.nativeplatform.platform.internal.ArchitectureInternal in project gradle by gradle.
the class GccVersionDeterminer method determineArchitecture.
private ArchitectureInternal determineArchitecture(Map<String, String> defines) {
boolean i386 = defines.containsKey("__i386__");
boolean amd64 = defines.containsKey("__amd64__");
final ArchitectureInternal architecture;
if (i386) {
architecture = Architectures.forInput("i386");
} else if (amd64) {
architecture = Architectures.forInput("amd64");
} else {
architecture = DefaultNativePlatform.getCurrentArchitecture();
}
return architecture;
}
Aggregations