blob: f6918cbb69be35ad45b7228d0315f8bc1dd0b7ea [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.packages;
16
John Fielda97e17f2015-11-13 02:19:52 +000017import com.google.devtools.build.lib.cmdline.Label;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010018import com.google.devtools.build.lib.events.EventHandler;
Dmitry Lomovc15ba2e2015-10-30 15:50:01 +000019import com.google.devtools.build.lib.packages.NativeAspectClass.NativeAspectFactory;
Francois-Rene Rideau89312fb2015-09-10 18:53:03 +000020import com.google.devtools.build.lib.syntax.Environment;
21import com.google.devtools.build.lib.syntax.Environment.Extension;
22import com.google.devtools.build.lib.syntax.Mutability;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010023
24import java.util.Map;
25
Francois-Rene Rideau89312fb2015-09-10 18:53:03 +000026import javax.annotation.Nullable;
27
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010028/**
29 * The collection of the supported build rules. Provides an Environment for Skylark rule creation.
30 */
31public interface RuleClassProvider {
Ulf Adamsfdfdd922015-09-01 08:36:29 +000032
33 /**
John Fielda97e17f2015-11-13 02:19:52 +000034 * Label referencing the prelude file.
Ulf Adamsfdfdd922015-09-01 08:36:29 +000035 */
John Fielda97e17f2015-11-13 02:19:52 +000036 Label getPreludeLabel();
Ulf Adamsfdfdd922015-09-01 08:36:29 +000037
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010038 /**
Ulf Adamsd13207c2015-09-04 14:53:43 +000039 * The default runfiles prefix (may be overwritten by the WORKSPACE file).
40 */
41 String getRunfilesPrefix();
42
43 /**
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010044 * Returns a map from rule names to rule class objects.
45 */
46 Map<String, RuleClass> getRuleClassMap();
47
48 /**
Francois-Rene Rideau89312fb2015-09-10 18:53:03 +000049 * Returns a new Skylark Environment instance for rule creation.
50 * Implementations need to be thread safe.
51 * Be sure to close() the mutability before you return the results of said evaluation.
52 * @param mutability the Mutability for the current evaluation context
53 * @param eventHandler the EventHandler for warnings, errors, etc.
54 * @param astFileContentHashCode the hash code identifying this environment.
55 * @return an Environment, in which to evaluate load time skylark forms.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010056 */
Francois-Rene Rideau89312fb2015-09-10 18:53:03 +000057 Environment createSkylarkRuleClassEnvironment(
58 Mutability mutability,
59 EventHandler eventHandler,
60 @Nullable String astFileContentHashCode,
John Field1ea7fc32015-12-22 19:37:19 +000061 @Nullable Map<String, Extension> importMap);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010062
63 /**
Dmitry Lomovc15ba2e2015-10-30 15:50:01 +000064 * Returns a map from aspect names to aspect factory objects.
65 */
66 Map<String, Class<? extends NativeAspectFactory>> getAspectFactoryMap();
67
68 /**
Lukacs Berkie753ecf2015-06-15 07:12:46 +000069 * Returns the default content of the WORKSPACE file.
70 *
71 * <p>Used to provide external dependencies for built-in rules. Rules defined here can be
72 * overwritten in the WORKSPACE file in the actual workspace.
Kristina Chodorowbc4b4b12015-02-11 15:54:50 +000073 */
Lukacs Berkie753ecf2015-06-15 07:12:46 +000074 String getDefaultWorkspaceFile();
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010075}