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