blob: 1e9c1b95bccd2b6ca4340e36163df762641277f7 [file] [log] [blame]
Dmitriy Ivanov87a06172015-02-06 10:56:28 -08001# 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{
6 'variables': {
7 'target_define%': 'TARGET_UNSUPPORTED',
8 'conditions': [
9 [ 'target_arch == "arm"', {
10 'target_define': 'TARGET_ARM',
11 }],
12 [ 'target_arch == "arm64"', {
13 'target_define': 'TARGET_ARM64',
14 }],
15 ],
16 },
17 'targets': [
18 {
19 # GN: //tools/relocation_packer:lib_relocation_packer
20 'target_name': 'lib_relocation_packer',
21 'toolsets': ['host'],
22 'type': 'static_library',
23 'defines': [
24 '<(target_define)',
25 ],
26 'dependencies': [
27 '../../third_party/elfutils/elfutils.gyp:libelf',
28 ],
29 'sources': [
30 'src/debug.cc',
31 'src/delta_encoder.cc',
32 'src/elf_file.cc',
33 'src/leb128.cc',
34 'src/packer.cc',
35 'src/sleb128.cc',
36 'src/run_length_encoder.cc',
37 ],
38 },
39 {
40 # GN: //tools/relocation_packer:relocation_packer
41 'target_name': 'relocation_packer',
42 'toolsets': ['host'],
43 'type': 'executable',
44 'defines': [
45 '<(target_define)',
46 ],
47 'dependencies': [
48 '../../third_party/elfutils/elfutils.gyp:libelf',
49 'lib_relocation_packer',
50 ],
51 'sources': [
52 'src/main.cc',
53 ],
54 },
55 {
56 # GN: //tools/relocation_packer:relocation_packer_unittests
57 'target_name': 'relocation_packer_unittests',
58 'toolsets': ['host'],
59 'type': 'executable',
60 'defines': [
61 '<(target_define)',
62 ],
63 'cflags': [
64 '-DINTERMEDIATE_DIR="<(INTERMEDIATE_DIR)"',
65 ],
66 'dependencies': [
67 '../../testing/gtest.gyp:gtest',
68 'lib_relocation_packer',
69 ],
70 'include_dirs': [
71 '../..',
72 ],
73 'sources': [
74 'src/debug_unittest.cc',
75 'src/delta_encoder_unittest.cc',
76 'src/elf_file_unittest.cc',
77 'src/leb128_unittest.cc',
78 'src/packer_unittest.cc',
79 'src/sleb128_unittest.cc',
80 'src/run_length_encoder_unittest.cc',
81 'src/run_all_unittests.cc',
82 ],
83 'copies': [
84 {
85 'destination': '<(INTERMEDIATE_DIR)',
86 'files': [
87 'test_data/elf_file_unittest_relocs_arm32.so',
88 'test_data/elf_file_unittest_relocs_arm32_packed.so',
89 'test_data/elf_file_unittest_relocs_arm64.so',
90 'test_data/elf_file_unittest_relocs_arm64_packed.so',
91 ],
92 },
93 ],
94 },
95
96 # Targets to build test data. These participate only in building test
97 # data for use with elf_file_unittest.cc, and are not part of the main
98 # relocation packer build. Unit test data files are checked in to the
99 # source tree as 'golden' data, and are not generated 'on the fly' by
100 # the build.
101 #
102 # See test_data/generate_elf_file_unittest_relocs.sh for instructions.
103 {
104 # GN: //tools/relocation_packer:relocation_packer_test_data
105 'target_name': 'relocation_packer_test_data',
106 'toolsets': ['target'],
107 'type': 'shared_library',
108 'cflags': [
109 '-O0',
110 '-g0',
111 ],
112 'sources': [
113 'test_data/elf_file_unittest_relocs.cc',
114 ],
115 },
116 {
117 # GN: //tools/relocation_packer:relocation_packer_unittests_test_data
118 'target_name': 'relocation_packer_unittests_test_data',
119 'toolsets': ['target'],
120 'type': 'none',
121 'actions': [
122 {
123 'variables': {
124 'test_file': '<(SHARED_LIB_DIR)/librelocation_packer_test_data.so',
125 'conditions': [
126 [ 'target_arch == "arm"', {
127 'added_section': '.android.rel.dyn',
128 'unpacked_output': 'elf_file_unittest_relocs_arm32.so',
129 'packed_output': 'elf_file_unittest_relocs_arm32_packed.so',
130 }],
131 [ 'target_arch == "arm64"', {
132 'added_section': '.android.rela.dyn',
133 'unpacked_output': 'elf_file_unittest_relocs_arm64.so',
134 'packed_output': 'elf_file_unittest_relocs_arm64_packed.so',
135 }],
136 ],
137 },
138 'action_name': 'generate_relocation_packer_test_data',
139 'inputs': [
140 'test_data/generate_elf_file_unittest_relocs.py',
141 '<(PRODUCT_DIR)/relocation_packer',
142 '<(test_file)',
143 ],
144 'outputs': [
145 '<(INTERMEDIATE_DIR)/<(unpacked_output)',
146 '<(INTERMEDIATE_DIR)/<(packed_output)',
147 ],
148 'action': [
149 'python', 'test_data/generate_elf_file_unittest_relocs.py',
150 '--android-pack-relocations=<(PRODUCT_DIR)/relocation_packer',
151 '--android-objcopy=<(android_objcopy)',
152 '--added-section=<(added_section)',
153 '--test-file=<(test_file)',
154 '--unpacked-output=<(INTERMEDIATE_DIR)/<(unpacked_output)',
155 '--packed-output=<(INTERMEDIATE_DIR)/<(packed_output)',
156 ],
157 },
158 ],
159 },
160 ],
161}