Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: tools/gn/scheduler.h

Issue 1126193005: Check for inputs not generated by deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/function_write_file_unittest.cc ('k') | tools/gn/scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef TOOLS_GN_SCHEDULER_H_ 5 #ifndef TOOLS_GN_SCHEDULER_H_
6 #define TOOLS_GN_SCHEDULER_H_ 6 #define TOOLS_GN_SCHEDULER_H_
7 7
8 #include <map>
9
8 #include "base/atomic_ref_count.h" 10 #include "base/atomic_ref_count.h"
9 #include "base/basictypes.h" 11 #include "base/basictypes.h"
10 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 14 #include "base/run_loop.h"
13 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
14 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
15 #include "tools/gn/input_file_manager.h" 17 #include "tools/gn/input_file_manager.h"
16 18
17 class Target; 19 class Target;
(...skipping 22 matching lines...) Expand all
40 42
41 void ScheduleWork(const base::Closure& work); 43 void ScheduleWork(const base::Closure& work);
42 44
43 void Shutdown(); 45 void Shutdown();
44 46
45 // Declares that the given file was read and affected the build output. 47 // Declares that the given file was read and affected the build output.
46 // 48 //
47 // TODO(brettw) this is global rather than per-BuildSettings. If we 49 // TODO(brettw) this is global rather than per-BuildSettings. If we
48 // start using >1 build settings, then we probably want this to take a 50 // start using >1 build settings, then we probably want this to take a
49 // BuildSettings object so we know the depdency on a per-build basis. 51 // BuildSettings object so we know the depdency on a per-build basis.
52 // If moved, most of the Add/Get functions below should move as well.
50 void AddGenDependency(const base::FilePath& file); 53 void AddGenDependency(const base::FilePath& file);
51 std::vector<base::FilePath> GetGenDependencies() const; 54 std::vector<base::FilePath> GetGenDependencies() const;
52 55
56 // Tracks calls to write_file for resolving with the unknown generated
57 // inputs (see AddUnknownGeneratedInput below).
58 void AddWrittenFile(const SourceFile& file);
59
60 // Unknown generated inputs are files that a target declares as an input
61 // in the output directory, but which aren't generated by any dependency.
62 //
63 // Some of these files will be files written by write_file and will be
64 // GenDependencies (see AddWrittenFile above). There are OK and include
65 // things like response files for scripts. Others cases will be ones where
66 // the file is generated by a target that's not a dependency.
67 //
68 // In order to distinguish these two cases, the checking for these input
69 // files needs to be done after all targets are complete. This also has the
70 // nice side effect that if a target generates the file we can find it and
71 // tell the user which dependency is missing.
72 //
73 // The result returned by GetUnknownGeneratedInputs will not count any files
74 // that were written by write_file during execution.
75 void AddUnknownGeneratedInput(const Target* target, const SourceFile& file);
76 std::multimap<SourceFile, const Target*> GetUnknownGeneratedInputs() const;
77 void ClearUnknownGeneratedInputsAndWrittenFiles(); // For testing.
78
53 // We maintain a count of the things we need to do that works like a 79 // We maintain a count of the things we need to do that works like a
54 // refcount. When this reaches 0, the program exits. 80 // refcount. When this reaches 0, the program exits.
55 void IncrementWorkCount(); 81 void IncrementWorkCount();
56 void DecrementWorkCount(); 82 void DecrementWorkCount();
57 83
58 private: 84 private:
59 void LogOnMainThread(const std::string& verb, const std::string& msg); 85 void LogOnMainThread(const std::string& verb, const std::string& msg);
60 void FailWithErrorOnMainThread(const Err& err); 86 void FailWithErrorOnMainThread(const Err& err);
61 87
62 void DoTargetFileWrite(const Target* target); 88 void DoTargetFileWrite(const Target* target);
(...skipping 14 matching lines...) Expand all
77 base::AtomicRefCount work_count_; 103 base::AtomicRefCount work_count_;
78 104
79 mutable base::Lock lock_; 105 mutable base::Lock lock_;
80 bool is_failed_; 106 bool is_failed_;
81 107
82 // Used to track whether the worker pool has been shutdown. This is necessary 108 // Used to track whether the worker pool has been shutdown. This is necessary
83 // to clean up after tests that make a scheduler but don't run the message 109 // to clean up after tests that make a scheduler but don't run the message
84 // loop. 110 // loop.
85 bool has_been_shutdown_; 111 bool has_been_shutdown_;
86 112
87 // Additional input dependencies. Protected by the lock. 113 // Protected by the lock. See the corresponding Add/Get functions above.
88 std::vector<base::FilePath> gen_dependencies_; 114 std::vector<base::FilePath> gen_dependencies_;
115 std::vector<SourceFile> written_files_;
116 std::multimap<SourceFile, const Target*> unknown_generated_inputs_;
89 117
90 DISALLOW_COPY_AND_ASSIGN(Scheduler); 118 DISALLOW_COPY_AND_ASSIGN(Scheduler);
91 }; 119 };
92 120
93 extern Scheduler* g_scheduler; 121 extern Scheduler* g_scheduler;
94 122
95 #endif // TOOLS_GN_SCHEDULER_H_ 123 #endif // TOOLS_GN_SCHEDULER_H_
96 124
OLDNEW
« no previous file with comments | « tools/gn/function_write_file_unittest.cc ('k') | tools/gn/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698