kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/indexer/proto/search_path.h (about)

     1  /*
     2   * Copyright 2018 The Kythe Authors. All rights reserved.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *   http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  #ifndef KYTHE_CXX_INDEXER_PROTO_SEARCH_PATH_H_
    18  #define KYTHE_CXX_INDEXER_PROTO_SEARCH_PATH_H_
    19  
    20  #include <string>
    21  #include <vector>
    22  
    23  #include "google/protobuf/repeated_field.h"
    24  
    25  namespace kythe {
    26  namespace lang_proto {
    27  
    28  // Handles --proto_path and -I flags, which specify directories the proto
    29  // compiler should search to find imports. There are two overloads because we
    30  // use this both on command line args (vector) and args from a CompilationUnit
    31  // proto (repeated ptr field).
    32  void ParsePathSubstitutions(
    33      std::vector<std::string> args,
    34      std::vector<std::pair<std::string, std::string>>* substitutions,
    35      std::vector<std::string>* unprocessed);
    36  void ParsePathSubstitutions(
    37      google::protobuf::RepeatedPtrField<std::string> args,
    38      std::vector<std::pair<std::string, std::string>>* substitutions,
    39      std::vector<std::string>* unprocessed);
    40  
    41  // Converts a path substitutions map into a list of arguments that can be passed
    42  // to protoc. For example, given the substitution map {"": some/directory}, this
    43  // function would return ["--proto_path", "some/directory"].
    44  std::vector<std::string> PathSubstitutionsToArgs(
    45      const std::vector<std::pair<std::string, std::string>>& substitutions);
    46  
    47  }  // namespace lang_proto
    48  }  // namespace kythe
    49  
    50  #endif  // KYTHE_CXX_INDEXER_PROTO_SEARCH_PATH_H_