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