1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef TOOLS_GN_VALUE_EXTRACTORS_H_ 6 #define TOOLS_GN_VALUE_EXTRACTORS_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "gn/label_ptr.h" 12 #include "gn/lib_file.h" 13 #include "gn/unique_vector.h" 14 15 class BuildSettings; 16 class Err; 17 class Label; 18 class LabelPattern; 19 class SourceDir; 20 class SourceFile; 21 class Value; 22 23 // On failure, returns false and sets the error. 24 bool ExtractListOfStringValues(const Value& value, 25 std::vector<std::string>* dest, 26 Err* err); 27 28 // Looks for a list of source files relative to a given current dir. 29 bool ExtractListOfRelativeFiles(const BuildSettings* build_settings, 30 const Value& value, 31 const SourceDir& current_dir, 32 std::vector<SourceFile>* files, 33 Err* err); 34 35 // Extracts a list of libraries. When they contain a "/" they are treated as 36 // source paths and are otherwise treated as plain strings. 37 bool ExtractListOfLibs(const BuildSettings* build_settings, 38 const Value& value, 39 const SourceDir& current_dir, 40 std::vector<LibFile>* libs, 41 Err* err); 42 43 // Looks for a list of source directories relative to a given current dir. 44 bool ExtractListOfRelativeDirs(const BuildSettings* build_settings, 45 const Value& value, 46 const SourceDir& current_dir, 47 std::vector<SourceDir>* dest, 48 Err* err); 49 50 // Extracts the list of labels and their origins to the given vector. Only the 51 // labels are filled in, the ptr for each pair in the vector will be null. 52 bool ExtractListOfLabels(const BuildSettings* build_settings, 53 const Value& value, 54 const SourceDir& current_dir, 55 const Label& current_toolchain, 56 LabelTargetVector* dest, 57 Err* err); 58 59 bool ExtractListOfLabelsMapping(const std::string& label, 60 const BuildSettings* build_settings, 61 const Value& value, 62 const SourceDir& current_dir, 63 const Label& current_toolchain, 64 LabelTargetVector* dest, 65 LabelTargetVector* whole_dest, 66 LabelTargetVector* no_whole_dest, 67 Err* err); 68 69 bool ExtractListOfExternalDeps(const BuildSettings* build_settings, 70 const Value& value, 71 const SourceDir& current_dir, 72 const Label& current_toolchain, 73 LabelTargetVector* dest, 74 LabelTargetVector* whole_dest, 75 LabelTargetVector* no_whole_dest, 76 Err* err); 77 78 // Extracts the list of labels and their origins to the given vector. For the 79 // version taking Label*Pair, only the labels are filled in, the ptr for each 80 // pair in the vector will be null. Sets an error and returns false if a label 81 // is maformed or there are duplicates. 82 bool ExtractListOfUniqueLabels(const BuildSettings* build_settings, 83 const Value& value, 84 const SourceDir& current_dir, 85 const Label& current_toolchain, 86 UniqueVector<Label>* dest, 87 Err* err); 88 bool ExtractListOfUniqueLabels(const BuildSettings* build_settings, 89 const Value& value, 90 const SourceDir& current_dir, 91 const Label& current_toolchain, 92 UniqueVector<LabelConfigPair>* dest, 93 Err* err); 94 bool ExtractListOfUniqueLabels(const BuildSettings* build_settings, 95 const Value& value, 96 const SourceDir& current_dir, 97 const Label& current_toolchain, 98 UniqueVector<LabelTargetPair>* dest, 99 Err* err); 100 101 bool ExtractRelativeFile(const BuildSettings* build_settings, 102 const Value& value, 103 const SourceDir& current_dir, 104 SourceFile* file, 105 Err* err); 106 107 bool ExtractListOfLabelPatterns(const BuildSettings* build_settings, 108 const Value& value, 109 const SourceDir& current_dir, 110 std::vector<LabelPattern>* patterns, 111 Err* err); 112 113 bool ExtractListOfExterns(const BuildSettings* build_settings, 114 const Value& value, 115 const SourceDir& current_dir, 116 std::vector<std::pair<std::string, LibFile>>* externs, 117 Err* err); 118 119 #endif // TOOLS_GN_VALUE_EXTRACTORS_H_ 120