• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_NINJA_TOOLS_H_
6 #define TOOLS_GN_NINJA_TOOLS_H_
7 
8 #include <vector>
9 
10 #include "base/files/file_path.h"
11 #include "gn/err.h"
12 
13 // Invokes the ninja restat tool (ie, ninja -C build_dir -t restat). This tool
14 // tells ninja that it should check the mtime of the provided files and update
15 // the .ninja_log accordingly. This is useful when GN knows that an output file
16 // in the ninja graph has been updated without invoking ninja.
17 //
18 // The best example of this is after gn gen runs, we know that build.ninja has
19 // been potentially updated, but ninja will still use the mtime from the
20 // .ninja_log and could trigger another re-gen. By telling ninja to restat
21 // build.ninja, we can eliminate the extra re-gen.
22 //
23 // If files_to_restat is empty, ninja will restat all files that have an entry
24 // in the .ninja_log.
25 bool InvokeNinjaRestatTool(const base::FilePath& ninja_executable,
26                            const base::FilePath& build_dir,
27                            const std::vector<base::FilePath>& files_to_restat,
28                            Err* err);
29 
30 // Invokes the ninja cleandead tool (ie, ninja -C build_dir -t cleandead). This
31 // tool removes files produced by previous builds that are no longer in the
32 // build file.
33 bool InvokeNinjaCleanDeadTool(const base::FilePath& ninja_executable,
34                               const base::FilePath& build_dir,
35                               Err* err);
36 
37 // Invokes the ninja recompact tool (ie, ninja -C build_dir -t recompact). This
38 // tool prunes the .ninja_log and .ninja_deps entries that are no longer part of
39 // the build graph.
40 bool InvokeNinjaRecompactTool(const base::FilePath& ninja_executable,
41                               const base::FilePath& build_dir,
42                               Err* err);
43 
44 #endif // TOOLS_GN_NINJA_TOOLS_H_
45