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 ExtractListOfExternalDeps(const BuildSettings* build_settings, 60 const Value& value, 61 const SourceDir& current_dir, 62 const Label& current_toolchain, 63 LabelTargetVector* dest, 64 Err* err); 65 66 // Extracts the list of labels and their origins to the given vector. For the 67 // version taking Label*Pair, only the labels are filled in, the ptr for each 68 // pair in the vector will be null. Sets an error and returns false if a label 69 // is maformed or there are duplicates. 70 bool ExtractListOfUniqueLabels(const BuildSettings* build_settings, 71 const Value& value, 72 const SourceDir& current_dir, 73 const Label& current_toolchain, 74 UniqueVector<Label>* dest, 75 Err* err); 76 bool ExtractListOfUniqueLabels(const BuildSettings* build_settings, 77 const Value& value, 78 const SourceDir& current_dir, 79 const Label& current_toolchain, 80 UniqueVector<LabelConfigPair>* dest, 81 Err* err); 82 bool ExtractListOfUniqueLabels(const BuildSettings* build_settings, 83 const Value& value, 84 const SourceDir& current_dir, 85 const Label& current_toolchain, 86 UniqueVector<LabelTargetPair>* dest, 87 Err* err); 88 89 bool ExtractRelativeFile(const BuildSettings* build_settings, 90 const Value& value, 91 const SourceDir& current_dir, 92 SourceFile* file, 93 Err* err); 94 95 bool ExtractListOfLabelPatterns(const BuildSettings* build_settings, 96 const Value& value, 97 const SourceDir& current_dir, 98 std::vector<LabelPattern>* patterns, 99 Err* err); 100 101 bool ExtractListOfExterns(const BuildSettings* build_settings, 102 const Value& value, 103 const SourceDir& current_dir, 104 std::vector<std::pair<std::string, LibFile>>* externs, 105 Err* err); 106 107 #endif // TOOLS_GN_VALUE_EXTRACTORS_H_ 108