blob: 59c0a232943a6c20a46258318f633e6f2d3775dc [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.runtime;
16
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010017import com.google.devtools.build.lib.vfs.Path;
18import com.google.devtools.build.lib.vfs.PathFragment;
Lukacs Berki18f7ace2016-11-15 09:26:31 +000019import com.google.devtools.common.options.OptionsParsingException;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010020import 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 */
27public 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 Adamsc26ca402016-03-29 17:01:18 +000041 ProjectFile getProjectFile(Path workingDirectory, List<Path> packagePath, PathFragment path)
Lukacs Berki18f7ace2016-11-15 09:26:31 +000042 throws OptionsParsingException;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010043 }
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}