Search in sources :

Example 1 with IncludeDirectives

use of org.gradle.language.nativeplatform.internal.IncludeDirectives 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();
    }
}
Also used : IncludeDirectives(org.gradle.language.nativeplatform.internal.IncludeDirectives) Include(org.gradle.language.nativeplatform.internal.Include)

Example 2 with IncludeDirectives

use of org.gradle.language.nativeplatform.internal.IncludeDirectives in project gradle by gradle.

the class DefaultSourceIncludesResolver method resolveMacro.

private void resolveMacro(MacroLookup visibleMacros, Expression expression, ExpressionVisitor visitor, TokenLookup tokenLookup) {
    boolean found = false;
    for (IncludeDirectives includeDirectives : visibleMacros) {
        Iterable<Macro> macros = includeDirectives.getMacros(expression.getValue());
        for (Macro macro : macros) {
            found = true;
            resolveExpression(visibleMacros, macro, visitor, tokenLookup);
        }
    }
    if (!found) {
        visitor.visitIdentifier(new SimpleExpression(expression.getValue(), IncludeType.IDENTIFIER));
    }
}
Also used : IncludeDirectives(org.gradle.language.nativeplatform.internal.IncludeDirectives) Macro(org.gradle.language.nativeplatform.internal.Macro) SimpleExpression(org.gradle.language.nativeplatform.internal.incremental.sourceparser.SimpleExpression)

Example 3 with IncludeDirectives

use of org.gradle.language.nativeplatform.internal.IncludeDirectives in project gradle by gradle.

the class DefaultSourceIncludesResolver method resolveMacroFunction.

private void resolveMacroFunction(MacroLookup visibleMacros, Expression expression, ExpressionVisitor visitor, TokenLookup tokenLookup) {
    boolean found = false;
    for (IncludeDirectives includeDirectives : visibleMacros) {
        Iterable<MacroFunction> macroFunctions = includeDirectives.getMacroFunctions(expression.getValue());
        for (MacroFunction macro : macroFunctions) {
            List<Expression> arguments = expression.getArguments();
            if (arguments.isEmpty() && macro.getParameterCount() == 1) {
                // Provide an implicit empty argument
                arguments = Collections.singletonList(SimpleExpression.EMPTY_EXPRESSIONS);
            }
            if (macro.getParameterCount() == arguments.size()) {
                found = true;
                Expression result = macro.evaluate(arguments);
                resolveExpression(visibleMacros, result, visitor, tokenLookup);
            }
        }
    }
    if (!found) {
        visitor.visitUnresolved();
    }
}
Also used : IncludeDirectives(org.gradle.language.nativeplatform.internal.IncludeDirectives) MacroFunction(org.gradle.language.nativeplatform.internal.MacroFunction) Expression(org.gradle.language.nativeplatform.internal.Expression) ComplexExpression(org.gradle.language.nativeplatform.internal.incremental.sourceparser.ComplexExpression) SimpleExpression(org.gradle.language.nativeplatform.internal.incremental.sourceparser.SimpleExpression)

Aggregations

IncludeDirectives (org.gradle.language.nativeplatform.internal.IncludeDirectives)3 SimpleExpression (org.gradle.language.nativeplatform.internal.incremental.sourceparser.SimpleExpression)2 Expression (org.gradle.language.nativeplatform.internal.Expression)1 Include (org.gradle.language.nativeplatform.internal.Include)1 Macro (org.gradle.language.nativeplatform.internal.Macro)1 MacroFunction (org.gradle.language.nativeplatform.internal.MacroFunction)1 ComplexExpression (org.gradle.language.nativeplatform.internal.incremental.sourceparser.ComplexExpression)1