aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-11-06 17:49:58 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-11-06 22:53:20 +0000
commit0c4e3bf1bfb77198a1ac03715fabb253844a4f8d (patch)
tree6be2f10fd3c4dc7895aa15a76d61dfd3c2ef7e1f /src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java
parentf1ed27d220281a066ecdea0334b079dc72a41e36 (diff)
bazel: support linking accumulated libraries into C++ binaries
This CL permits a cc_binary to have a set of dependencies that are all gathered together when the cc_binary is linked, producing a set of LibraryToLink objects to link into the cc_binary. Each such dependency will an instance of a class that extends BuildLibraryToLink to a CcLinkParams. All instances of the same class will be gathered together. At link time the BuildLibraryToLink method buildLibraries will be called to build the LibraryToLink objects. -- MOS_MIGRATED_REVID=107242331
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java
new file mode 100644
index 0000000000..52b2a0822a
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java
@@ -0,0 +1,63 @@
+// Copyright 2015 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.rules.cpp;
+
+import com.google.devtools.build.lib.analysis.RuleContext;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
+import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink;
+
+/**
+ * An extra library to include in a link. The actual library is built
+ * at link time.
+ *
+ * <p>This can be used for non-C++ inputs to a C++ link. A class that
+ * implements this interface will support transitively gathering all
+ * inputs from link dependencies, and then combine them all together
+ * into a set of C++ libraries.
+ *
+ * <p>Any implementations must be immutable (and therefore thread-safe),
+ * because this is passed between rules and accessed in a multi-threaded
+ * context.
+ */
+public interface ExtraLinkTimeLibrary {
+ /**
+ * Build the LibraryToLink inputs to pass to the C++ linker.
+ */
+ NestedSet<LibraryToLink> buildLibraries(RuleContext context);
+
+ /**
+ * Get a new Builder for this ExtraLinkTimeLibrary class. This acts
+ * like a static method, in that the result does not depend on the
+ * current state of the object, and the new Builder starts out
+ * empty.
+ */
+ Builder getBuilder();
+
+ /**
+ * The Builder interface builds an ExtraLinkTimeLibrary.
+ */
+ public interface Builder {
+ /**
+ * Add the inputs associated with another instance of the same
+ * underlying ExtraLinkTimeLibrary type.
+ */
+ void addTransitive(ExtraLinkTimeLibrary dep);
+
+ /**
+ * Build the ExtraLinkTimeLibrary based on the inputs.
+ */
+ ExtraLinkTimeLibrary build();
+ }
+}