OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/runtime_deps.h" | 5 #include "tools/gn/runtime_deps.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // the found_files list. Updates the list. | 29 // the found_files list. Updates the list. |
30 void AddIfNew(const OutputFile& output_file, | 30 void AddIfNew(const OutputFile& output_file, |
31 const Target* source, | 31 const Target* source, |
32 RuntimeDepsVector* deps, | 32 RuntimeDepsVector* deps, |
33 std::set<OutputFile>* found_file) { | 33 std::set<OutputFile>* found_file) { |
34 if (found_file->find(output_file) != found_file->end()) | 34 if (found_file->find(output_file) != found_file->end()) |
35 return; // Already there. | 35 return; // Already there. |
36 deps->push_back(std::make_pair(output_file, source)); | 36 deps->push_back(std::make_pair(output_file, source)); |
37 } | 37 } |
38 | 38 |
39 // Automatically converts a SourceFile to an OutputFile. | 39 // Automatically converts a string that looks like a source to an OutputFile. |
40 void AddIfNew(const SourceFile& source_file, | 40 void AddIfNew(const std::string& str, |
41 const Target* source, | 41 const Target* source, |
42 RuntimeDepsVector* deps, | 42 RuntimeDepsVector* deps, |
43 std::set<OutputFile>* found_file) { | 43 std::set<OutputFile>* found_file) { |
44 AddIfNew(OutputFile(source->settings()->build_settings(), source_file), | 44 OutputFile output_file(RebasePath( |
45 source, deps, found_file); | 45 str, |
| 46 source->settings()->build_settings()->build_dir(), |
| 47 source->settings()->build_settings()->root_path_utf8())); |
| 48 AddIfNew(output_file, source, deps, found_file); |
46 } | 49 } |
47 | 50 |
48 // Returns the output file that the runtime deps considers for the given | 51 // Returns the output file that the runtime deps considers for the given |
49 // targets. This is weird only for shared libraries. | 52 // targets. This is weird only for shared libraries. |
50 const OutputFile& GetMainOutput(const Target* target) { | 53 const OutputFile& GetMainOutput(const Target* target) { |
51 if (target->output_type() == Target::SHARED_LIBRARY) | 54 if (target->output_type() == Target::SHARED_LIBRARY) |
52 return target->link_output_file(); | 55 return target->link_output_file(); |
53 return target->dependency_output_file(); | 56 return target->dependency_output_file(); |
54 } | 57 } |
55 | 58 |
(...skipping 19 matching lines...) Expand all Loading... |
75 AddIfNew(file, target, deps, found_files); | 78 AddIfNew(file, target, deps, found_files); |
76 | 79 |
77 // Actions/copy have all outputs considered when the're a data dep. | 80 // Actions/copy have all outputs considered when the're a data dep. |
78 if (is_target_data_dep && | 81 if (is_target_data_dep && |
79 (target->output_type() == Target::ACTION || | 82 (target->output_type() == Target::ACTION || |
80 target->output_type() == Target::ACTION_FOREACH || | 83 target->output_type() == Target::ACTION_FOREACH || |
81 target->output_type() == Target::COPY_FILES)) { | 84 target->output_type() == Target::COPY_FILES)) { |
82 std::vector<SourceFile> outputs; | 85 std::vector<SourceFile> outputs; |
83 target->action_values().GetOutputsAsSourceFiles(target, &outputs); | 86 target->action_values().GetOutputsAsSourceFiles(target, &outputs); |
84 for (const auto& output_file : outputs) | 87 for (const auto& output_file : outputs) |
85 AddIfNew(output_file, target, deps, found_files); | 88 AddIfNew(output_file.value(), target, deps, found_files); |
86 } | 89 } |
87 | 90 |
88 // Non-data dependencies (both public and private). | 91 // Non-data dependencies (both public and private). |
89 for (const auto& dep_pair : target->GetDeps(Target::DEPS_LINKED)) { | 92 for (const auto& dep_pair : target->GetDeps(Target::DEPS_LINKED)) { |
90 if (dep_pair.ptr->output_type() == Target::EXECUTABLE) | 93 if (dep_pair.ptr->output_type() == Target::EXECUTABLE) |
91 continue; // Skip executables that aren't data deps. | 94 continue; // Skip executables that aren't data deps. |
92 RecursiveCollectRuntimeDeps(dep_pair.ptr, false, | 95 RecursiveCollectRuntimeDeps(dep_pair.ptr, false, |
93 deps, seen_targets, found_files); | 96 deps, seen_targets, found_files); |
94 } | 97 } |
95 | 98 |
(...skipping 29 matching lines...) Expand all Loading... |
125 | 128 |
126 const char kRuntimeDeps_Help[] = | 129 const char kRuntimeDeps_Help[] = |
127 "Runtime dependencies\n" | 130 "Runtime dependencies\n" |
128 "\n" | 131 "\n" |
129 " Runtime dependencies of a target are exposed via the \"runtime_deps\"\n" | 132 " Runtime dependencies of a target are exposed via the \"runtime_deps\"\n" |
130 " category of \"gn desc\" (see \"gn help desc\") or they can be written\n" | 133 " category of \"gn desc\" (see \"gn help desc\") or they can be written\n" |
131 " at build generation time via \"--runtime-deps-list-file\"\n" | 134 " at build generation time via \"--runtime-deps-list-file\"\n" |
132 " (see \"gn help --runtime-deps-list-file\").\n" | 135 " (see \"gn help --runtime-deps-list-file\").\n" |
133 "\n" | 136 "\n" |
134 " To a first approximation, the runtime dependencies of a target are\n" | 137 " To a first approximation, the runtime dependencies of a target are\n" |
135 " the set of \"data\" files and the shared libraries from all transitive\n" | 138 " the set of \"data\" files, data directories, and the shared libraries\n" |
136 " dependencies. Executables and shared libraries are considered runtime\n" | 139 " from all transitive dependencies. Executables and shared libraries are\n" |
137 " dependencies of themselves.\n" | 140 " considered runtime dependencies of themselves.\n" |
138 "\n" | 141 "\n" |
139 "Details\n" | 142 "Details\n" |
140 "\n" | 143 "\n" |
141 " Executable targets and those executable targets' transitive\n" | 144 " Executable targets and those executable targets' transitive\n" |
142 " dependencies are not considered unless that executable is listed in\n" | 145 " dependencies are not considered unless that executable is listed in\n" |
143 " \"data_deps\". Otherwise, GN assumes that the executable (and\n" | 146 " \"data_deps\". Otherwise, GN assumes that the executable (and\n" |
144 " everything it requires) is a build-time dependency only.\n" | 147 " everything it requires) is a build-time dependency only.\n" |
145 "\n" | 148 "\n" |
146 " Action and copy targets that are listed as \"data_deps\" will have all\n" | 149 " Action and copy targets that are listed as \"data_deps\" will have all\n" |
147 " of their outputs and data files considered as runtime dependencies.\n" | 150 " of their outputs and data files considered as runtime dependencies.\n" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return false; | 221 return false; |
219 } | 222 } |
220 | 223 |
221 // Currently this writes all runtime deps files sequentially. We generally | 224 // Currently this writes all runtime deps files sequentially. We generally |
222 // expect few of these. We can run this on the worker pool if it looks | 225 // expect few of these. We can run this on the worker pool if it looks |
223 // like it's talking a long time. | 226 // like it's talking a long time. |
224 WriteRuntimeDepsFile(target); | 227 WriteRuntimeDepsFile(target); |
225 } | 228 } |
226 return true; | 229 return true; |
227 } | 230 } |
OLD | NEW |