BUILD.gn 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. # Copyright 2014 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. import("//build/config/compiler/compiler.gni")
  5. import("//testing/test.gni")
  6. static_library("courgette_lib") {
  7. sources = [
  8. "adjustment_method.cc",
  9. "adjustment_method.h",
  10. "adjustment_method_2.cc",
  11. "assembly_program.cc",
  12. "assembly_program.h",
  13. "consecutive_range_visitor.h",
  14. "courgette.h",
  15. "courgette_flow.cc",
  16. "courgette_flow.h",
  17. "difference_estimator.cc",
  18. "difference_estimator.h",
  19. "disassembler.cc",
  20. "disassembler.h",
  21. "disassembler_elf_32.cc",
  22. "disassembler_elf_32.h",
  23. "disassembler_elf_32_x86.cc",
  24. "disassembler_elf_32_x86.h",
  25. "disassembler_win32.cc",
  26. "disassembler_win32.h",
  27. "disassembler_win32_x64.cc",
  28. "disassembler_win32_x64.h",
  29. "disassembler_win32_x86.cc",
  30. "disassembler_win32_x86.h",
  31. "encoded_program.cc",
  32. "encoded_program.h",
  33. "ensemble.cc",
  34. "ensemble.h",
  35. "ensemble_apply.cc",
  36. "ensemble_create.cc",
  37. "image_utils.h",
  38. "instruction_utils.h",
  39. "label_manager.cc",
  40. "label_manager.h",
  41. "patch_generator_x86_32.h",
  42. "patcher_x86_32.h",
  43. "program_detector.cc",
  44. "program_detector.h",
  45. "rel32_finder.cc",
  46. "rel32_finder.h",
  47. "rel32_finder_x64.cc",
  48. "rel32_finder_x64.h",
  49. "rel32_finder_x86.cc",
  50. "rel32_finder_x86.h",
  51. "simple_delta.cc",
  52. "simple_delta.h",
  53. "types_elf.h",
  54. "types_win_pe.h",
  55. ]
  56. deps = [
  57. "//base",
  58. "//third_party/lzma_sdk",
  59. ]
  60. public_deps = [
  61. ":bsdiff",
  62. ":courgette_common",
  63. ]
  64. }
  65. source_set("courgette_common") {
  66. sources = [
  67. "crc.cc",
  68. "crc.h",
  69. "memory_allocator.cc",
  70. "memory_allocator.h",
  71. "region.h",
  72. "streams.cc",
  73. "streams.h",
  74. ]
  75. deps = [
  76. "//base",
  77. "//third_party/lzma_sdk",
  78. ]
  79. }
  80. source_set("paged_array") {
  81. sources = [ "third_party/bsdiff/paged_array.h" ]
  82. deps = [ "//base" ]
  83. }
  84. source_set("bsdiff") {
  85. sources = [
  86. "third_party/bsdiff/bsdiff.h",
  87. "third_party/bsdiff/bsdiff_apply.cc",
  88. "third_party/bsdiff/bsdiff_create.cc",
  89. "third_party/bsdiff/bsdiff_search.h",
  90. ]
  91. deps = [
  92. ":courgette_common",
  93. "//base",
  94. ]
  95. public_deps = [
  96. ":divsufsort",
  97. ":paged_array",
  98. ]
  99. }
  100. source_set("divsufsort") {
  101. sources = [
  102. "third_party/divsufsort/divsufsort.cc",
  103. "third_party/divsufsort/divsufsort.h",
  104. "third_party/divsufsort/divsufsort_private.h",
  105. "third_party/divsufsort/sssort.cc",
  106. "third_party/divsufsort/trsort.cc",
  107. ]
  108. deps = [
  109. ":courgette_common",
  110. ":paged_array",
  111. "//base",
  112. ]
  113. }
  114. if (!is_ios) {
  115. executable("courgette") {
  116. if (is_win && current_cpu == "x64") {
  117. # The build infrastructure needs courgette to be named courgette64.
  118. output_name = "courgette64"
  119. }
  120. sources = [ "courgette_tool.cc" ]
  121. if (is_win) {
  122. ldflags = [ "/LARGEADDRESSAWARE" ]
  123. }
  124. deps = [
  125. ":courgette_lib",
  126. "//base",
  127. "//build/win:default_exe_manifest",
  128. ]
  129. }
  130. executable("courgette_minimal_tool") {
  131. sources = [ "courgette_minimal_tool.cc" ]
  132. deps = [
  133. ":courgette_lib",
  134. "//base",
  135. "//build/win:default_exe_manifest",
  136. ]
  137. }
  138. if (is_win) {
  139. if (current_cpu == "x64") {
  140. # TODO(sebmarchand): The official build scripts expect courgette.exe to be
  141. # in the official build archives, remove this once they have been updated.
  142. # https://crbug.com/629243
  143. copy("copy_courgette_binaries") {
  144. sources = [ "$root_out_dir/courgette64.exe" ]
  145. outputs = [ "$root_out_dir/courgette.exe" ]
  146. deps = [ ":courgette" ]
  147. }
  148. } else {
  149. # Make sure that we have a copy of courgette64.exe(.pdb) in the root out
  150. # directory.
  151. if (is_clang) {
  152. courgette64_toolchain = "//build/toolchain/win:win_clang_x64"
  153. } else {
  154. courgette64_toolchain = "//build/toolchain/win:x64"
  155. }
  156. courgette64_label = ":courgette($courgette64_toolchain)"
  157. courgette64_out_dir = get_label_info(courgette64_label, "root_out_dir")
  158. if (symbol_level > 0) {
  159. copy("copy_courgette_pdb") {
  160. visibility = [ ":copy_courgette_binaries" ]
  161. sources = [ "$courgette64_out_dir/courgette64.exe.pdb" ]
  162. outputs = [ "$root_out_dir/{{source_file_part}}" ]
  163. deps = [ courgette64_label ]
  164. }
  165. }
  166. copy("copy_courgette_binaries") {
  167. sources = [ "$courgette64_out_dir/courgette64.exe" ]
  168. outputs = [ "$root_out_dir/{{source_file_part}}" ]
  169. deps = [ courgette64_label ]
  170. if (symbol_level > 0) {
  171. deps += [ ":copy_courgette_pdb" ]
  172. }
  173. }
  174. }
  175. }
  176. }
  177. test("courgette_unittests") {
  178. sources = [
  179. "adjustment_method_unittest.cc",
  180. "base_test_unittest.cc",
  181. "base_test_unittest.h",
  182. "bsdiff_memory_unittest.cc",
  183. "consecutive_range_visitor_unittest.cc",
  184. "difference_estimator_unittest.cc",
  185. "disassembler_elf_32_x86_unittest.cc",
  186. "disassembler_win32_x64_unittest.cc",
  187. "disassembler_win32_x86_unittest.cc",
  188. "encode_decode_unittest.cc",
  189. "encoded_program_unittest.cc",
  190. "ensemble_unittest.cc",
  191. "image_utils_unittest.cc",
  192. "label_manager_unittest.cc",
  193. "memory_allocator_unittest.cc",
  194. "program_detector_unittest.cc",
  195. "rel32_finder_unittest.cc",
  196. "streams_unittest.cc",
  197. "third_party/bsdiff/bsdiff_search_unittest.cc",
  198. "third_party/bsdiff/paged_array_unittest.cc",
  199. "third_party/divsufsort/divsufsort_unittest.cc",
  200. "typedrva_unittest.cc",
  201. "versioning_unittest.cc",
  202. ]
  203. deps = [
  204. ":courgette_lib",
  205. "//base",
  206. "//base:i18n",
  207. "//base/test:run_all_unittests",
  208. "//base/test:test_support",
  209. "//testing/gtest",
  210. ]
  211. data = [ "testdata/" ]
  212. }
  213. test("courgette_fuzz") {
  214. sources = [
  215. "base_test_unittest.cc",
  216. "base_test_unittest.h",
  217. "encoded_program_fuzz_unittest.cc",
  218. ]
  219. deps = [
  220. ":courgette_lib",
  221. "//base",
  222. "//base:i18n",
  223. "//base/test:test_support",
  224. "//testing/gtest",
  225. ]
  226. }