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.runtime; |
| 16 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 17 | import com.google.devtools.build.lib.vfs.Path; |
| 18 | import com.google.devtools.build.lib.vfs.PathFragment; |
Lukacs Berki | 18f7ace | 2016-11-15 09:26:31 +0000 | [diff] [blame] | 19 | import com.google.devtools.common.options.OptionsParsingException; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 20 | import java.util.List; |
| 21 | |
| 22 | /** |
| 23 | * A file that describes a project - for large source trees that are worked on by multiple |
| 24 | * independent teams, it is useful to have a larger unit than a package which combines a set of |
| 25 | * target patterns and a set of corresponding options. |
| 26 | */ |
| 27 | public interface ProjectFile { |
| 28 | |
| 29 | /** |
| 30 | * A provider for a project file - we generally expect the provider to cache parsed files |
| 31 | * internally and return a cached version if it can ascertain that that is still correct. |
| 32 | * |
| 33 | * <p>Note in particular that packages may be moved between different package path entries, which |
| 34 | * should lead to cache invalidation. |
| 35 | */ |
| 36 | public interface Provider { |
| 37 | /** |
| 38 | * Returns an (optionally cached) project file instance. If there is no such file, or if the |
| 39 | * file cannot be parsed, then it throws an exception. |
| 40 | */ |
Ulf Adams | c26ca40 | 2016-03-29 17:01:18 +0000 | [diff] [blame] | 41 | ProjectFile getProjectFile(Path workingDirectory, List<Path> packagePath, PathFragment path) |
Lukacs Berki | 18f7ace | 2016-11-15 09:26:31 +0000 | [diff] [blame] | 42 | throws OptionsParsingException; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | /** |
| 46 | * A string name of the project file that is reported to the user. It should be in such a format |
| 47 | * that passing it back in on the command line works. |
| 48 | */ |
| 49 | String getName(); |
| 50 | |
| 51 | /** |
| 52 | * A list of strings that are parsed into the options for the command. |
| 53 | * |
| 54 | * @param command An action from the command line, e.g. "build" or "test". |
| 55 | * @throws UnsupportedOperationException if an unknown command is passed. |
| 56 | */ |
| 57 | List<String> getCommandLineFor(String command); |
| 58 | } |