blob: 32455e83f19c360db817e226fc8fff01a235942b [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.analysis;
16
17/**
Lukacs Berki2300cd62016-05-19 11:06:37 +000018 * Contains rolled-up data about the transitive closure of a configured target.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010019 *
Lukacs Berki2300cd62016-05-19 11:06:37 +000020 * For more information about how analysis works, see
ulfjack26d0e492017-08-07 13:42:33 +020021 * {@link com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory}.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010022 * TransitiveInfoProviders need to be serializable, and for that reason they must conform to
23 * the following restrictions:
24 *
25 * <ul>
26 * <li>The provider interface must directly extend {@code TransitiveInfoProvider}.
27 * <li>Every method must return immutable data.</li>
28 * <li>Every method must return the same object if called multiple times with the same
29 * arguments.</li>
30 * <li>Overloading a method name multiple times is forbidden.</li>
31 * <li>The return type of a method must satisfy one of the following conditions:
32 * <ul>
Han-Wen Nienhuys18740ae2015-06-11 14:57:17 +000033 * <li>It must be from the set of {String, Integer, int, Boolean, bool, Label, PathFragment,
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010034 * Artifact}, OR</li>
Han-Wen Nienhuys18740ae2015-06-11 14:57:17 +000035 * <li>it must be an ImmutableList/List/Collection/Iterable of T, where T is either
Adam Michaelf3c32102016-08-19 17:24:33 +000036 * one of the types above with a default serializer or T implements ValueSerializer, OR</li>
Han-Wen Nienhuys18740ae2015-06-11 14:57:17 +000037 * <li>it must be serializable (TBD)</li>
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010038 * </ul>
39 * <li>If the method takes arguments, it must declare a custom serializer (TBD).</li>
40 * </ul>
41 *
42 * <p>Some typical uses of this interface are:
43 * <ul>
44 * <li>The set of Python source files in the transitive closure of this rule
45 * <li>The set of declared C++ header files in the transitive closure
46 * <li>The files that need to be built when the target is mentioned on the command line
47 * </ul>
48 *
49 * <p>Note that if implemented naively, this would result in the memory requirements
50 * being O(n^2): in a long dependency chain, if every target adds one single artifact, storing the
51 * transitive closures of every rule would take 1+2+3+...+n-1+n = O(n^2) memory.
52 *
Lukacs Berki2300cd62016-05-19 11:06:37 +000053 * <p>In order to avoid this, we introduce the concept of nested sets, {@link
54 * com.google.devtools.build.lib.collect.nestedset.NestedSet}. A nested set is an immutable
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010055 * data structure that can contain direct members and other nested sets (recursively). Nested sets
56 * are iterable and can be flattened into ordered sets, where the order depends on which
57 * implementation of NestedSet you pick.
58 *
59 * @see TransitiveInfoCollection
ulfjack26d0e492017-08-07 13:42:33 +020060 * @see com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010061 */
62public interface TransitiveInfoProvider {
dslomovf6a7e5a2017-07-05 07:23:31 -040063
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010064}