use of org.gradle.language.nativeplatform.internal.Include in project gradle by gradle.
the class RegexBackedCSourceParser method parseFile.
private List<Include> parseFile(File file) {
List<Include> includes = Lists.newArrayList();
try {
BufferedReader bf = new BufferedReader(new PreprocessingReader(new BufferedReader(new FileReader(file))));
try {
String line;
while ((line = bf.readLine()) != null) {
Matcher m = includePattern.matcher(line.trim());
if (m.matches()) {
boolean isImport = "import".equals(m.group(1));
String value = m.group(2);
includes.add(DefaultInclude.parse(value, isImport));
}
}
} finally {
IOUtils.closeQuietly(bf);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return includes;
}
use of org.gradle.language.nativeplatform.internal.Include in project gradle by gradle.
the class RegexBackedCSourceParser method parseSource.
protected IncludeDirectives parseSource(Reader sourceReader) throws IOException {
Set<Include> includes = Sets.newLinkedHashSet();
List<Macro> macros = Lists.newArrayList();
List<MacroFunction> macroFunctions = Lists.newArrayList();
BufferedReader reader = new BufferedReader(sourceReader);
PreprocessingReader lineReader = new PreprocessingReader(reader);
Buffer buffer = new Buffer();
while (true) {
buffer.reset();
if (!lineReader.readNextLine(buffer.value)) {
break;
}
buffer.consumeWhitespace();
if (!buffer.consume('#')) {
continue;
}
buffer.consumeWhitespace();
if (buffer.consume("define")) {
parseDefineDirectiveBody(buffer, macros, macroFunctions);
} else if (buffer.consume("include")) {
parseIncludeOrImportDirectiveBody(buffer, false, includes);
} else if (buffer.consume("import")) {
parseIncludeOrImportDirectiveBody(buffer, true, includes);
}
}
return new DefaultIncludeDirectives(ImmutableList.copyOf(includes), ImmutableList.copyOf(macros), ImmutableList.copyOf(macroFunctions));
}
use of org.gradle.language.nativeplatform.internal.Include in project gradle by gradle.
the class NativeCompiler method maybeGetPCHArgs.
protected List<String> maybeGetPCHArgs(final T spec, File sourceFile) {
if (spec.getPreCompiledHeader() == null) {
return Lists.newArrayList();
}
final IncludeDirectives includes = spec.getSourceFileIncludeDirectives().get(sourceFile);
final String header = spec.getPreCompiledHeader();
List<Include> headers = includes.getAll();
boolean usePCH = !headers.isEmpty() && header.equals(headers.get(0).getValue());
if (usePCH) {
return getPCHArgs(spec);
} else {
boolean containsHeader = CollectionUtils.any(headers, new Spec<Include>() {
@Override
public boolean isSatisfiedBy(Include include) {
return include.getValue().equals(header);
}
});
if (containsHeader) {
logger.log(LogLevel.WARN, getCantUsePCHMessage(spec.getPreCompiledHeader(), sourceFile));
}
return Lists.newArrayList();
}
}
Aggregations