Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 2 | // |
| 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 | |
| 15 | package com.google.devtools.build.lib.packages; |
| 16 | |
John Field | a97e17f | 2015-11-13 02:19:52 +0000 | [diff] [blame] | 17 | import com.google.devtools.build.lib.cmdline.Label; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 18 | import com.google.devtools.build.lib.events.EventHandler; |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 19 | import com.google.devtools.build.lib.packages.NativeAspectClass.NativeAspectFactory; |
Francois-Rene Rideau | 89312fb | 2015-09-10 18:53:03 +0000 | [diff] [blame] | 20 | import com.google.devtools.build.lib.syntax.Environment; |
| 21 | import com.google.devtools.build.lib.syntax.Environment.Extension; |
| 22 | import com.google.devtools.build.lib.syntax.Mutability; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 23 | |
| 24 | import java.util.Map; |
| 25 | |
Francois-Rene Rideau | 89312fb | 2015-09-10 18:53:03 +0000 | [diff] [blame] | 26 | import javax.annotation.Nullable; |
| 27 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 28 | /** |
| 29 | * The collection of the supported build rules. Provides an Environment for Skylark rule creation. |
| 30 | */ |
| 31 | public interface RuleClassProvider { |
Ulf Adams | fdfdd92 | 2015-09-01 08:36:29 +0000 | [diff] [blame] | 32 | |
| 33 | /** |
John Field | a97e17f | 2015-11-13 02:19:52 +0000 | [diff] [blame] | 34 | * Label referencing the prelude file. |
Ulf Adams | fdfdd92 | 2015-09-01 08:36:29 +0000 | [diff] [blame] | 35 | */ |
John Field | a97e17f | 2015-11-13 02:19:52 +0000 | [diff] [blame] | 36 | Label getPreludeLabel(); |
Ulf Adams | fdfdd92 | 2015-09-01 08:36:29 +0000 | [diff] [blame] | 37 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 38 | /** |
Ulf Adams | d13207c | 2015-09-04 14:53:43 +0000 | [diff] [blame] | 39 | * The default runfiles prefix (may be overwritten by the WORKSPACE file). |
| 40 | */ |
| 41 | String getRunfilesPrefix(); |
| 42 | |
| 43 | /** |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 44 | * Returns a map from rule names to rule class objects. |
| 45 | */ |
| 46 | Map<String, RuleClass> getRuleClassMap(); |
| 47 | |
| 48 | /** |
Francois-Rene Rideau | 89312fb | 2015-09-10 18:53:03 +0000 | [diff] [blame] | 49 | * 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 56 | */ |
Francois-Rene Rideau | 89312fb | 2015-09-10 18:53:03 +0000 | [diff] [blame] | 57 | Environment createSkylarkRuleClassEnvironment( |
| 58 | Mutability mutability, |
| 59 | EventHandler eventHandler, |
| 60 | @Nullable String astFileContentHashCode, |
John Field | 1ea7fc3 | 2015-12-22 19:37:19 +0000 | [diff] [blame] | 61 | @Nullable Map<String, Extension> importMap); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 62 | |
| 63 | /** |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 64 | * Returns a map from aspect names to aspect factory objects. |
| 65 | */ |
| 66 | Map<String, Class<? extends NativeAspectFactory>> getAspectFactoryMap(); |
| 67 | |
| 68 | /** |
Lukacs Berki | e753ecf | 2015-06-15 07:12:46 +0000 | [diff] [blame] | 69 | * 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 Chodorow | bc4b4b1 | 2015-02-11 15:54:50 +0000 | [diff] [blame] | 73 | */ |
Lukacs Berki | e753ecf | 2015-06-15 07:12:46 +0000 | [diff] [blame] | 74 | String getDefaultWorkspaceFile(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 75 | } |