blob: e1b9e7defd831363546eef985ea1cc0fa6a5d585 [file] [log] [blame]
lpinob379f652017-04-07 12:05:09 +00001// Copyright 2017 The Bazel Authors. All rights reserved.
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
lpino233b72d2017-07-05 11:08:40 -040015#ifndef BAZEL_SRC_MAIN_CPP_OPTION_PROCESSOR_INTERNAL_H_
16#define BAZEL_SRC_MAIN_CPP_OPTION_PROCESSOR_INTERNAL_H_
lpinob379f652017-04-07 12:05:09 +000017
18#include <algorithm>
ccalvarin5e5ee0d2018-08-23 08:56:01 -070019#include <set>
lpinob379f652017-04-07 12:05:09 +000020
ccalvarinfec75f42018-04-23 10:40:26 -070021#include "src/main/cpp/rc_file.h"
22#include "src/main/cpp/util/exit_code.h"
lpinob379f652017-04-07 12:05:09 +000023#include "src/main/cpp/util/file.h"
24
25namespace blaze {
26namespace internal {
27
lpino233b72d2017-07-05 11:08:40 -040028// Returns the deduped set of bazelrc paths (with respect to its canonical form)
Laszlo Csomor9b83bd72018-12-17 08:42:44 -080029// preserving the original order.
30// All paths in the result were verified to exist (otherwise their canonical
31// form couldn't have been computed). The paths that cannot be resolved are
lpinob379f652017-04-07 12:05:09 +000032// omitted.
33std::vector<std::string> DedupeBlazercPaths(
34 const std::vector<std::string>& paths);
35
ccalvarin8ceaa652018-08-24 12:44:31 -070036// Given the set of already-ready files, warns if any of the newly loaded_rcs
37// are duplicates. All paths are expected to be canonical.
38void WarnAboutDuplicateRcFiles(const std::set<std::string>& read_files,
39 const std::deque<std::string>& loaded_rcs);
40
ccalvarin5e5ee0d2018-08-23 08:56:01 -070041// Get the legacy list of rc files that would have been loaded - this is to
42// provide a useful warning if files are being ignored that were loaded in a
43// previous version of Bazel.
44// TODO(b/3616816): Remove this once the warning is no longer useful.
45std::set<std::string> GetOldRcPaths(
46 const WorkspaceLayout* workspace_layout, const std::string& workspace,
47 const std::string& cwd, const std::string& path_to_binary,
48 const std::vector<std::string>& startup_args);
49
50// Returns what the "user bazelrc" would have been in the legacy rc list.
51std::string FindLegacyUserBazelrc(const char* cmd_line_rc_file,
52 const std::string& workspace);
53
ccalvarinbccf9c62018-06-20 15:05:23 -070054std::string FindSystemWideRc();
55
ccalvarinfec75f42018-04-23 10:40:26 -070056std::string FindRcAlongsideBinary(const std::string& cwd,
57 const std::string& path_to_binary);
58
59blaze_exit_code::ExitCode ParseErrorToExitCode(RcFile::ParseError parse_error);
60
lpinob379f652017-04-07 12:05:09 +000061} // namespace internal
62} // namespace blaze
63
lpino233b72d2017-07-05 11:08:40 -040064#endif // BAZEL_SRC_MAIN_CPP_OPTION_PROCESSOR_INTERNAL_H_