use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.
the class CcSkylarkApiProvider method getIncludeDirs.
@SkylarkCallable(name = "include_directories", structField = true, doc = "Returns the immutable set of include directories used to compile this target " + "(possibly empty but never None).")
public ImmutableList<String> getIncludeDirs() {
CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class);
if (ccContext == null) {
return ImmutableList.of();
}
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (PathFragment path : ccContext.getIncludeDirs()) {
builder.add(path.getSafePathString());
}
return builder.build();
}
use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.
the class CcSkylarkApiProvider method getSystemIncludeDirs.
@SkylarkCallable(name = "system_include_directories", structField = true, doc = "Returns the immutable set of system include directories used to compile this target " + "(possibly empty but never None).")
public ImmutableList<String> getSystemIncludeDirs() {
CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class);
if (ccContext == null) {
return ImmutableList.of();
}
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (PathFragment path : ccContext.getSystemIncludeDirs()) {
builder.add(path.getSafePathString());
}
return builder.build();
}
use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.
the class CcSkylarkApiProvider method getQuoteIncludeDirs.
@SkylarkCallable(name = "quote_include_directories", structField = true, doc = "Returns the immutable set of quote include directories used to compile this target " + "(possibly empty but never None).")
public ImmutableList<String> getQuoteIncludeDirs() {
CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class);
if (ccContext == null) {
return ImmutableList.of();
}
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (PathFragment path : ccContext.getQuoteIncludeDirs()) {
builder.add(path.getSafePathString());
}
return builder.build();
}
use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.
the class SkylarkDocumentationCollector method collectJavaObjects.
/**
* Collects and returns all the Java objects reachable in Skylark from (and including)
* firstClass with the corresponding SkylarkModule annotation.
*
* <p>Note that the {@link SkylarkModule} annotation for firstClass - firstModule -
* is also an input parameter, because some top level Skylark built-in objects and methods
* are not annotated on the class, but on a field referencing them.
*/
@VisibleForTesting
static void collectJavaObjects(SkylarkModule firstModule, Class<?> firstClass, Map<String, SkylarkModuleDoc> modules) {
Set<Class<?>> done = new HashSet<>();
Deque<Class<?>> toProcess = new LinkedList<>();
Map<Class<?>, SkylarkModule> annotations = new HashMap<>();
toProcess.addLast(firstClass);
annotations.put(firstClass, firstModule);
while (!toProcess.isEmpty()) {
Class<?> c = toProcess.removeFirst();
SkylarkModule annotation = annotations.get(c);
done.add(c);
if (!modules.containsKey(annotation.name())) {
modules.put(annotation.name(), new SkylarkModuleDoc(annotation, c));
}
SkylarkModuleDoc module = modules.get(annotation.name());
if (module.javaMethodsNotCollected()) {
ImmutableMap<Method, SkylarkCallable> methods = FuncallExpression.collectSkylarkMethodsWithAnnotation(c);
for (Map.Entry<Method, SkylarkCallable> entry : methods.entrySet()) {
module.addMethod(new SkylarkJavaMethodDoc(module, entry.getKey(), entry.getValue()));
}
for (Map.Entry<Method, SkylarkCallable> method : methods.entrySet()) {
Class<?> returnClass = method.getKey().getReturnType();
if (returnClass.isAnnotationPresent(SkylarkModule.class) && !done.contains(returnClass)) {
toProcess.addLast(returnClass);
annotations.put(returnClass, returnClass.getAnnotation(SkylarkModule.class));
}
}
}
}
}
use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.
the class SkylarkRuleContext method newFile.
// Kept for compatibility with old code.
@SkylarkCallable(documented = false)
public Artifact newFile(Root root, Artifact baseArtifact, String suffix) {
PathFragment original = baseArtifact.getRootRelativePath();
PathFragment fragment = original.replaceName(original.getBaseName() + suffix);
return ruleContext.getDerivedArtifact(fragment, root);
}
Aggregations