Add --empty_ninja_file for test usecases

In cases that we want to run Kati in many configurations to verify all
of the generation logic works without errors, but don't care about
running the final ninja file, writing it out only wastes time. So add a
--empty_ninja_file option that skips writing out build rules and
defaults information, leading to a very small ninja file.

Our specific use case (Soong's build_test / multiproduct_kati) runs Kati
several hundred times for different configurations, and the ninja files
are around 750MB. Even when we truncate them immediately after writing,
that still leads to hundreds of gigabytes of writes to disk.

Change-Id: Ie4e7800ccfaeb653e89ed5d5ea3010b0c8ff314a
3 files changed
tree: 0c4a7b7081a2b351e5dc17a6cbc3a00433eee3b7
  1. cmd/
  2. make-c/
  3. testcase/
  4. .clang-format
  5. .gitignore
  6. .travis.yml
  7. affinity.cc
  8. affinity.h
  9. Android.bp
  10. ast.go
  11. AUTHORS
  12. bootstrap.go
  13. buf.go
  14. buf_test.go
  15. command.cc
  16. command.h
  17. CONTRIBUTING.md
  18. CONTRIBUTORS
  19. dep.cc
  20. dep.go
  21. dep.h
  22. depgraph.go
  23. doc.go
  24. eval.cc
  25. eval.go
  26. eval.h
  27. evalcmd.go
  28. exec.cc
  29. exec.go
  30. exec.h
  31. expr.cc
  32. expr.go
  33. expr.h
  34. expr_test.go
  35. file.cc
  36. file.h
  37. file_cache.cc
  38. file_cache.h
  39. fileutil.cc
  40. fileutil.go
  41. fileutil.h
  42. fileutil_bench.cc
  43. find.cc
  44. find.h
  45. find_test.cc
  46. flags.cc
  47. flags.go
  48. flags.h
  49. func.cc
  50. func.go
  51. func.h
  52. func_test.go
  53. INTERNALS.md
  54. io.cc
  55. io.h
  56. LICENSE
  57. loc.h
  58. log.cc
  59. log.go
  60. log.h
  61. m2n
  62. main.cc
  63. make-c.sh
  64. Makefile
  65. Makefile.ckati
  66. Makefile.kati
  67. ninja.cc
  68. ninja.go
  69. ninja.h
  70. ninja_test.cc
  71. ninja_test.go
  72. pack.sh
  73. parser.cc
  74. parser.go
  75. parser.h
  76. pathutil.go
  77. pathutil_test.go
  78. query.go
  79. README.md
  80. regen.cc
  81. regen.h
  82. regen_dump.cc
  83. rule.cc
  84. rule.h
  85. rule_parser.go
  86. rule_parser_test.go
  87. runtest.rb
  88. serialize.go
  89. shellutil.go
  90. shellutil_test.go
  91. stats.cc
  92. stats.go
  93. stats.h
  94. stmt.cc
  95. stmt.h
  96. string_piece.cc
  97. string_piece.h
  98. string_piece_test.cc
  99. stringprintf.cc
  100. stringprintf.h
  101. strutil.cc
  102. strutil.go
  103. strutil.h
  104. strutil_bench.cc
  105. strutil_test.cc
  106. strutil_test.go
  107. symtab.cc
  108. symtab.go
  109. symtab.h
  110. testutil.h
  111. thread_local.h
  112. thread_pool.cc
  113. thread_pool.h
  114. timeutil.cc
  115. timeutil.h
  116. var.cc
  117. var.go
  118. var.h
  119. version.go
  120. version.h
  121. version_unknown.cc
  122. worker.go
README.md

kati

Build Status

kati is an experimental GNU make clone. The main goal of this tool is to speed-up incremental build of Android.

Currently, kati does not offer a faster build by itself. It instead converts your Makefile to a ninja file.

How to use for Android

For Android-N+, ckati and ninja is used automatically. There is a prebuilt checked in under prebuilts/build-tools that is used.

All Android's build commands (m, mmm, mmma, etc.) should just work.

How to use for Android (deprecated -- only for Android M or earlier)

Set up kati:

% cd ~/src
% git clone https://github.com/google/kati
% cd kati
% make

Build Android:

% cd <android-directory>
% source build/envsetup.sh
% lunch <your-choice>
% ~/src/kati/m2n --kati_stats
% ./ninja.sh

You need ninja in your $PATH.

More usage examples (deprecated way)

"make clean"

% ./ninja.sh -t clean

Note ./ninja.sh passes all parameters to ninja.

Build a specific target

For example, the following is equivalent to "make cts":

% ./ninja.sh cts

Or, if you know the path you want, you can do:

% ./ninja.sh out/host/linux-x86/bin/adb