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