aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar dslomov <dslomov@google.com>2017-07-24 10:50:10 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-07-24 13:18:53 +0200
commit4dfb271df9dcdf01413a216ad046d955669160b7 (patch)
tree4d099b57f44e0c269a34208f6e2aa066d21530c3
parent403b2a5e295b96c2053e21d3ba97d057192d8264 (diff)
Expose to Skylark Strings instead of PathFragments from CppConfiguration.
Fixes #2931. RELNOTES: None. PiperOrigin-RevId: 162907348
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java110
1 files changed, 76 insertions, 34 deletions
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 8d00fc9ff5..784ab88a7b 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
@@ -980,11 +980,6 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
return useStartEndLib() ? Link.ArchiveType.START_END_LIB : Link.ArchiveType.REGULAR;
}
- /**
- * Returns the built-in list of 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.
- */
@SkylarkCallable(
name = "built_in_include_directories",
structField = true,
@@ -993,11 +988,19 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
+ " 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 ImmutableList<PathFragment> getBuiltInIncludeDirectories()
+ public ImmutableList<String> getBuiltInIncludeDirectoriesForSkylark()
throws InvalidConfigurationException {
- return getBuiltInIncludeDirectories(nonConfiguredSysroot);
+ return getBuiltInIncludeDirectories(nonConfiguredSysroot)
+ .stream()
+ .map(PathFragment::getPathString)
+ .collect(ImmutableList.toImmutableList());
}
+ /**
+ * Returns the built-in list of 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 ImmutableList<PathFragment> getBuiltInIncludeDirectories(PathFragment sysroot)
throws InvalidConfigurationException {
ImmutableList.Builder<PathFragment> builtInIncludeDirectoriesBuilder = ImmutableList.builder();
@@ -1016,8 +1019,8 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
doc = "Returns the sysroot to be used. If the toolchain compiler does not support "
+ "different sysroots, or the sysroot is the same as the default sysroot, then "
+ "this method returns <code>None</code>.")
- public PathFragment getSysroot() {
- return nonConfiguredSysroot;
+ public String getSysroot() {
+ return nonConfiguredSysroot.getPathString();
}
public Label getSysrootLabel() {
@@ -1544,20 +1547,34 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
structField = true,
doc = "Path to GNU binutils 'objcopy' binary."
)
- public PathFragment getObjCopyExecutable() {
- return getToolPathFragment(CppConfiguration.Tool.OBJCOPY);
+ public String getObjCopyExecutableForSkylark() {
+ PathFragment objCopyExecutable = getObjCopyExecutable();
+ return objCopyExecutable != null ? objCopyExecutable.getPathString() : "";
}
/**
- * Returns the path to the GNU binutils 'gcc' binary that should be used by this build. This
- * binary should support compilation of both C (*.c) and C++ (*.cc) files. Relative paths are
- * relative to the execution root.
+ * Returns the path to the GNU binutils 'objcopy' binary to use for this build. (Corresponds to
+ * $(OBJCOPY) in make-dbg.) Relative paths are relative to the execution root.
*/
+ public PathFragment getObjCopyExecutable() {
+ return getToolPathFragment(CppConfiguration.Tool.OBJCOPY);
+ }
+
@SkylarkCallable(
name = "compiler_executable",
structField = true,
doc = "Path to C/C++ compiler binary."
)
+ public String getCppExecutableForSkylark() {
+ PathFragment cppExecutable = getCppExecutable();
+ return cppExecutable != null ? cppExecutable.getPathString() : "";
+ }
+
+ /**
+ * Returns the path to the GNU binutils 'gcc' binary that should be used by this build. This
+ * binary should support compilation of both C (*.c) and C++ (*.cc) files. Relative paths are
+ * relative to the execution root.
+ */
public PathFragment getCppExecutable() {
return getToolPathFragment(CppConfiguration.Tool.GCC);
}
@@ -1571,15 +1588,20 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
return getToolPathFragment(CppConfiguration.Tool.GCC);
}
- /**
- * 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 String getCpreprocessorExecutableForSkylark() {
+ PathFragment cpreprocessorExecutable = getCpreprocessorExecutable();
+ return cpreprocessorExecutable != null ? cpreprocessorExecutable.getPathString() : "";
+ }
+
+ /**
+ * Returns the path to the GNU binutils 'cpp' binary that should be used by this build. Relative
+ * paths are relative to the execution root.
+ */
public PathFragment getCpreprocessorExecutable() {
return getToolPathFragment(CppConfiguration.Tool.CPP);
}
@@ -1601,54 +1623,74 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
return getToolPathFragment(CppConfiguration.Tool.GCOVTOOL);
}
- /**
- * Returns the path to the GNU binutils 'nm' executable that should be used by this build. Used
- * only for testing. Relative paths are relative to the execution root.
- */
@SkylarkCallable(
name = "nm_executable",
structField = true,
doc = "Path to GNU binutils 'nm' binary."
)
- public PathFragment getNmExecutable() {
- return getToolPathFragment(CppConfiguration.Tool.NM);
+ public String getNmExecutableForSkylark() {
+ PathFragment nmExecutable = getNmExecutable();
+ return nmExecutable != null ? nmExecutable.getPathString() : "";
}
/**
- * Returns the path to the GNU binutils 'objdump' executable that should be used by this build.
- * Used only for testing. Relative paths are relative to the execution root.
+ * Returns the path to the GNU binutils 'nm' executable that should be used by this build. Used
+ * only for testing. Relative paths are relative to the execution root.
*/
+ public PathFragment getNmExecutable() {
+ return getToolPathFragment(CppConfiguration.Tool.NM);
+ }
+
@SkylarkCallable(
name = "objdump_executable",
structField = true,
doc = "Path to GNU binutils 'objdump' binary."
)
- public PathFragment getObjdumpExecutable() {
- return getToolPathFragment(CppConfiguration.Tool.OBJDUMP);
+ public String getObjdumpExecutableForSkylark() {
+ PathFragment objdumpExecutable = getObjdumpExecutable();
+ return objdumpExecutable != null ? objdumpExecutable.getPathString() : "";
}
/**
- * Returns the path to the GNU binutils 'ar' binary to use for this build. Relative paths are
- * relative to the execution root.
+ * Returns the path to the GNU binutils 'objdump' executable that should be used by this build.
+ * Used only for testing. Relative paths are relative to the execution root.
*/
+ public PathFragment getObjdumpExecutable() {
+ return getToolPathFragment(CppConfiguration.Tool.OBJDUMP);
+ }
+
@SkylarkCallable(
name = "ar_executable",
structField = true,
doc = "Path to GNU binutils 'ar' binary."
)
- public PathFragment getArExecutable() {
- return getToolPathFragment(CppConfiguration.Tool.AR);
+ public String getArExecutableForSkylark() {
+ PathFragment arExecutable = getArExecutable();
+ return arExecutable != null ? arExecutable.getPathString() : "";
}
/**
- * Returns the path to the GNU binutils 'strip' executable that should be used by this build.
- * Relative paths are relative to the execution root.
+ * Returns the path to the GNU binutils 'ar' binary to use for this build. Relative paths are
+ * relative to the execution root.
*/
+ public PathFragment getArExecutable() {
+ return getToolPathFragment(CppConfiguration.Tool.AR);
+ }
+
@SkylarkCallable(
name = "strip_executable",
structField = true,
doc = "Path to GNU binutils 'strip' binary."
)
+ public String getStripExecutableForSkylark() {
+ PathFragment stripExecutable = getStripExecutable();
+ return stripExecutable != null ? stripExecutable.getPathString() : "";
+ }
+
+ /**
+ * Returns the path to the GNU binutils 'strip' executable that should be used by this build.
+ * Relative paths are relative to the execution root.
+ */
public PathFragment getStripExecutable() {
return getToolPathFragment(CppConfiguration.Tool.STRIP);
}