blob: b25db9c92996c6f00137b2283208a67d26bc162f [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)
lpinob379f652017-04-07 12:05:09 +000029// preserving the original order. The paths that cannot be resolved are
30// omitted.
31std::vector<std::string> DedupeBlazercPaths(
32 const std::vector<std::string>& paths);
33
ccalvarin8ceaa652018-08-24 12:44:31 -070034// Given the set of already-ready files, warns if any of the newly loaded_rcs
35// are duplicates. All paths are expected to be canonical.
36void WarnAboutDuplicateRcFiles(const std::set<std::string>& read_files,
37 const std::deque<std::string>& loaded_rcs);
38
ccalvarin5e5ee0d2018-08-23 08:56:01 -070039// Get the legacy list of rc files that would have been loaded - this is to
40// provide a useful warning if files are being ignored that were loaded in a
41// previous version of Bazel.
42// TODO(b/3616816): Remove this once the warning is no longer useful.
43std::set<std::string> GetOldRcPaths(
44 const WorkspaceLayout* workspace_layout, const std::string& workspace,
45 const std::string& cwd, const std::string& path_to_binary,
46 const std::vector<std::string>& startup_args);
47
48// Returns what the "user bazelrc" would have been in the legacy rc list.
49std::string FindLegacyUserBazelrc(const char* cmd_line_rc_file,
50 const std::string& workspace);
51
ccalvarinbccf9c62018-06-20 15:05:23 -070052std::string FindSystemWideRc();
53
ccalvarinfec75f42018-04-23 10:40:26 -070054std::string FindRcAlongsideBinary(const std::string& cwd,
55 const std::string& path_to_binary);
56
57blaze_exit_code::ExitCode ParseErrorToExitCode(RcFile::ParseError parse_error);
58
lpinob379f652017-04-07 12:05:09 +000059} // namespace internal
60} // namespace blaze
61
lpino233b72d2017-07-05 11:08:40 -040062#endif // BAZEL_SRC_MAIN_CPP_OPTION_PROCESSOR_INTERNAL_H_