prune resources in MemoryCache
[chromium-blink-merge.git] / tools / relocation_packer / BUILD.gn
blobcbbc6fdde59103d5a6d1b7838c4d218f783ce4fc
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.
5 import("config.gni")
7 assert(relocation_packing_supported)
9 if (target_arch == "arm") {
10   target_define = "TARGET_ARM"
11 } else if (target_arch == "arm64") {
12   target_define = "TARGET_ARM64"
15 if (current_toolchain == host_toolchain) {
16   # GYP: //tools/relocation_packer/relocation_packer.gyp:lib_relocation_packer
17   source_set("lib_relocation_packer") {
18     defines = [ target_define ]
19     deps = [
20       "//third_party/elfutils:libelf",
21     ]
22     configs -= [ "//build/config/compiler:chromium_code" ]
23     configs += [ "//build/config/compiler:no_chromium_code" ]
24     sources = [
25       "src/debug.cc",
26       "src/delta_encoder.cc",
27       "src/elf_file.cc",
28       "src/leb128.cc",
29       "src/packer.cc",
30       "src/sleb128.cc",
31       "src/run_length_encoder.cc",
32     ]
33   }
35   # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer
36   executable("relocation_packer") {
37     defines = [ target_define ]
38     deps = [
39       ":lib_relocation_packer",
40       "//third_party/elfutils:libelf",
41     ]
42     sources = [
43       "src/main.cc",
44     ]
45   }
47   # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_unittests
48   test("relocation_packer_unittests") {
49     sources = [
50       "src/debug_unittest.cc",
51       "src/delta_encoder_unittest.cc",
52       "src/elf_file_unittest.cc",
53       "src/leb128_unittest.cc",
54       "src/packer_unittest.cc",
55       "src/sleb128_unittest.cc",
56       "src/run_length_encoder_unittest.cc",
57       "src/run_all_unittests.cc",
58     ]
59     rebased_test_data = rebase_path("test_data", root_build_dir)
60     data = [
61       "test_data/elf_file_unittest_relocs_arm32.so",
62       "test_data/elf_file_unittest_relocs_arm32_packed.so",
63       "test_data/elf_file_unittest_relocs_arm64.so",
64       "test_data/elf_file_unittest_relocs_arm64_packed.so",
65     ]
66     defines = [
67       target_define,
68       "INTERMEDIATE_DIR=\"$rebased_test_data\"",
69     ]
70     include_dirs = [ "//" ]
71     deps = [
72       ":lib_relocation_packer",
73       ":relocation_packer_test_data",
74       "//testing:gtest",
75     ]
76   }
79 if (current_toolchain == default_toolchain &&
80     (target_arch == "arm" || target_arch == "arm64")) {
81   # Targets to build test data.  These participate only in building test
82   # data for use with elf_file_unittest.cc, and are not part of the main
83   # relocation packer build.  Unit test data files are checked in to the
84   # source tree as 'golden' data, and are not generated 'on the fly' by
85   # the build.
86   #
87   # See test_data/generate_elf_file_unittest_relocs.sh for instructions.
89   # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_test_data
90   shared_library("relocation_packer_test_data") {
91     cflags = [
92       "-O0",
93       "-g0",
94     ]
95     sources = [
96       "test_data/elf_file_unittest_relocs.cc",
97     ]
98   }
100   # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_unittests_test_data
101   action("relocation_packer_unittests_test_data") {
102     script = "test_data/generate_elf_file_unittest_relocs.py"
103     test_file = "$root_build_dir/librelocation_packer_test_data.so"
104     if (target_arch == "arm") {
105       added_section = ".android.rel.dyn"
106       packed_output = "elf_file_unittest_relocs_arm32_packed.so"
107       unpacked_output = "elf_file_unittest_relocs_arm32.so"
108     } else if (target_arch == "arm64") {
109       added_section = ".android.rela.dyn"
110       packed_output = "elf_file_unittest_relocs_arm64_packed.so"
111       unpacked_output = "elf_file_unittest_relocs_arm64.so"
112     } else {
113       assert(false, "Unsupported target arch for relocation packer")
114     }
116     packed_output = "$root_build_dir/$packed_output"
117     unpacked_output = "$root_build_dir/$unpacked_output"
119     inputs = [
120       test_file,
121     ]
123     deps = [
124       ":relocation_packer_test_data",
125       ":relocation_packer($host_toolchain)",
126     ]
128     outputs = [
129       packed_output,
130       unpacked_output,
131     ]
133     args = [
134       "--android-pack-relocations",
135       rebase_path(relocation_packer_exe, root_build_dir),
136       "--android-objcopy",
137       rebase_path(android_objcopy, root_build_dir),
138       "--added-section=$added_section",
139       "--test-file",
140       rebase_path(test_file, root_build_dir),
141       "--packed-output",
142       rebase_path(packed_output, root_build_dir),
143       "--unpacked-output",
144       rebase_path(unpacked_output, root_build_dir),
145     ]
146   }