aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-02-22 09:19:56 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-22 09:22:03 -0800
commitca93b67eb4b2c78e82c6f523ebc2e15acb831683 (patch)
tree27eba77fb0a5f610c9252085d108ba6b83c7d8c1 /src/main
parent79fa35b0b7571ffbbbfaba1209119ec52c7b2eb5 (diff)
CcToolchain: add optional ar and as attributes
These may be used to retrieve the ar and as programs associated with the compiler toolchain. RELNOTES: None. PiperOrigin-RevId: 186626548
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java10
3 files changed, 37 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java
index 64cc3bdadd..62cd8cc307 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java
@@ -409,6 +409,8 @@ public class CcToolchain implements RuleConfiguredTargetFactory {
final NestedSet<Artifact> compile = getFiles(ruleContext, "compiler_files");
final NestedSet<Artifact> strip = getFiles(ruleContext, "strip_files");
final NestedSet<Artifact> objcopy = getFiles(ruleContext, "objcopy_files");
+ final NestedSet<Artifact> as = getOptionalFiles(ruleContext, "as_files");
+ final NestedSet<Artifact> ar = getOptionalFiles(ruleContext, "ar_files");
final NestedSet<Artifact> link = getFiles(ruleContext, "linker_files");
final NestedSet<Artifact> dwp = getFiles(ruleContext, "dwp_files");
final NestedSet<Artifact> libcLink = inputsForLibc(ruleContext);
@@ -550,6 +552,8 @@ public class CcToolchain implements RuleConfiguredTargetFactory {
compile,
strip,
objcopy,
+ as,
+ ar,
fullInputsForLink(ruleContext, link),
ruleContext.getPrerequisiteArtifact("$interface_library_builder", Mode.HOST),
dwp,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java
index 5fc4b76a00..1921c364bf 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java
@@ -62,6 +62,8 @@ public final class CcToolchainProvider extends ToolchainInfo {
NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
+ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
+ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
null,
NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
@@ -91,6 +93,8 @@ public final class CcToolchainProvider extends ToolchainInfo {
private final NestedSet<Artifact> compile;
private final NestedSet<Artifact> strip;
private final NestedSet<Artifact> objCopy;
+ private final NestedSet<Artifact> as;
+ private final NestedSet<Artifact> ar;
private final NestedSet<Artifact> link;
private final Artifact interfaceSoBuilder;
private final NestedSet<Artifact> dwp;
@@ -123,6 +127,8 @@ public final class CcToolchainProvider extends ToolchainInfo {
NestedSet<Artifact> compile,
NestedSet<Artifact> strip,
NestedSet<Artifact> objCopy,
+ NestedSet<Artifact> as,
+ NestedSet<Artifact> ar,
NestedSet<Artifact> link,
Artifact interfaceSoBuilder,
NestedSet<Artifact> dwp,
@@ -153,6 +159,8 @@ public final class CcToolchainProvider extends ToolchainInfo {
this.compile = Preconditions.checkNotNull(compile);
this.strip = Preconditions.checkNotNull(strip);
this.objCopy = Preconditions.checkNotNull(objCopy);
+ this.as = Preconditions.checkNotNull(as);
+ this.ar = Preconditions.checkNotNull(ar);
this.link = Preconditions.checkNotNull(link);
this.interfaceSoBuilder = interfaceSoBuilder;
this.dwp = Preconditions.checkNotNull(dwp);
@@ -297,6 +305,22 @@ public final class CcToolchainProvider extends ToolchainInfo {
}
/**
+ * Returns the files necessary for an 'as' invocation. May be empty if the CROSSTOOL
+ * file does not define as_files.
+ */
+ public NestedSet<Artifact> getAs() {
+ return as;
+ }
+
+ /**
+ * Returns the files necessary for an 'ar' invocation. May be empty if the CROSSTOOL
+ * file does not define ar_files.
+ */
+ public NestedSet<Artifact> getAr() {
+ return ar;
+ }
+
+ /**
* Returns the files necessary for linking, including the files needed for libc.
*/
public NestedSet<Artifact> getLink() {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java
index e7bb964bbe..7539500a2a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java
@@ -90,7 +90,15 @@ public final class CcToolchainRule implements RuleDefinition {
attr("objcopy_files", LABEL)
.legacyAllowAnyFileType()
.cfg(HostTransition.INSTANCE)
- .mandatory())
+ .mandatory())
+ .add(
+ attr("as_files", LABEL)
+ .legacyAllowAnyFileType()
+ .cfg(HostTransition.INSTANCE))
+ .add(
+ attr("ar_files", LABEL)
+ .legacyAllowAnyFileType()
+ .cfg(HostTransition.INSTANCE))
.add(
attr("linker_files", LABEL)
.legacyAllowAnyFileType()