From bb2f07124c7ebf5cb28c8cd4b57cf6156c1c7b0d Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 18 Mar 2016 17:33:12 +0000 Subject: Export cc build information in an aspect for IDE support. -- MOS_MIGRATED_REVID=117560803 --- .../build/lib/rules/cpp/CcSkylarkApiProvider.java | 65 ++++++++++++++++++++++ .../build/lib/rules/cpp/CppConfiguration.java | 6 ++ 2 files changed, 71 insertions(+) (limited to 'src/main/java/com/google/devtools/build/lib/rules') diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java index 674e68c6ca..4f250b7b18 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java @@ -80,6 +80,71 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { return ccLinkParams.getCcLinkParams(true, false).flattenedLinkopts(); } + @SkylarkCallable( + name = "defines", + structField = true, + doc = + "Returns the immutable set of defines used to compile this target " + + "(possibly empty but never None).") + public ImmutableList getDefines() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + return ccContext == null ? ImmutableList.of() : ccContext.getDefines(); + } + + @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 getSystemIncludeDirs() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + if (ccContext == null) { + return ImmutableList.of(); + } + ImmutableList.Builder builder = ImmutableList.builder(); + for (PathFragment path : ccContext.getSystemIncludeDirs()) { + builder.add(path.getSafePathString()); + } + return builder.build(); + } + + @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 getIncludeDirs() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + if (ccContext == null) { + return ImmutableList.of(); + } + ImmutableList.Builder builder = ImmutableList.builder(); + for (PathFragment path : ccContext.getIncludeDirs()) { + builder.add(path.getSafePathString()); + } + return builder.build(); + } + + @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 getQuoteIncludeDirs() { + CppCompilationContext ccContext = getInfo().getProvider(CppCompilationContext.class); + if (ccContext == null) { + return ImmutableList.of(); + } + ImmutableList.Builder builder = ImmutableList.builder(); + for (PathFragment path : ccContext.getQuoteIncludeDirs()) { + builder.add(path.getSafePathString()); + } + return builder.build(); + } + @SkylarkCallable( name = "compile_flags", structField = true, diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index e46d1f76d6..f1adbe878b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -1193,6 +1193,10 @@ public class CppConfiguration extends BuildConfiguration.Fragment { * They may be absolute if they are also installed on the remote build nodes or * for local compilation. */ + @SkylarkCallable(name = "built_in_include_directories", structField = true, + doc = "Built-in system include paths for the toolchain compiler. All paths in this list" + + " should be relative to the exec directory. They may be absolute if they are also installed" + + " on the remote build nodes or for local compilation.") public List getBuiltInIncludeDirectories() { return builtInIncludeDirectories; } @@ -1699,6 +1703,8 @@ public class CppConfiguration extends BuildConfiguration.Fragment { * Returns the path to the GNU binutils 'cpp' binary that should be used * by this build. Relative paths are relative to the execution root. */ + @SkylarkCallable(name = "preprocessor_executable", structField = true, + doc = "Path to C/C++ preprocessor binary") public PathFragment getCpreprocessorExecutable() { return getToolPathFragment(CppConfiguration.Tool.CPP); } -- cgit v1.2.3