| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 | |
| 3 # Copyright 2014 Google Inc. | |
| 4 # | |
| 5 # Use of this source code is governed by a BSD-style license that can be | |
| 6 # found in the LICENSE file. | |
| 7 | |
| 8 """ | |
| 9 Modified version of gyp_skia, used by gyp_to_android.py to generate Android.mk | |
| 10 """ | |
| 11 | |
| 12 import os | |
| 13 import sys | |
| 14 | |
| 15 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) | |
| 16 | |
| 17 # Unlike gyp_skia, this file is nested deep inside Skia. Find Skia's trunk dir. | |
| 18 # This line depends on the fact that the script is three levels deep | |
| 19 # (specifically, it is in platform_tools/android/bin). | |
| 20 SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, | |
| 21 os.pardir)) | |
| 22 DIR_CONTENTS = os.listdir(SKIA_DIR) | |
| 23 assert 'gyp' in DIR_CONTENTS | |
| 24 | |
| 25 # Directory within which we can find the gyp source. | |
| 26 if 'third_party' in DIR_CONTENTS: | |
| 27 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') | |
| 28 else: | |
| 29 # In an Android tree, there is no third_party/externals/gyp, which would | |
| 30 # require running gclient sync. Use chromium's instead. | |
| 31 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, os.pardir, 'chromium_org', 'tools', | |
| 32 'gyp') | |
| 33 | |
| 34 assert os.path.exists(GYP_SOURCE_DIR) | |
| 35 | |
| 36 # Ensure we import our current gyp source's module, not any version | |
| 37 # pre-installed in your PYTHONPATH. | |
| 38 sys.path.insert(0, os.path.join(GYP_SOURCE_DIR, 'pylib')) | |
| 39 | |
| 40 import gyp | |
| 41 | |
| 42 def main(target_dir, target_file, skia_arch_type, have_neon): | |
| 43 """ | |
| 44 Create gypd files based on target_file. | |
| 45 @param target_dir Directory containing all gyp files, including common.gypi | |
| 46 @param target_file Gyp file to start on. Other files within target_dir will | |
| 47 be read if target_file depends on them. | |
| 48 @param skia_arch_type Target architecture to pass to gyp. | |
| 49 @param have_neon Whether to generate files including neon optimizations. | |
| 50 Only meaningful if skia_arch_type is 'arm'. | |
| 51 @return path Path to root gypd file created by running gyp. | |
| 52 """ | |
| 53 # Set GYP_DEFINES for building for the android framework. | |
| 54 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' | |
| 55 % skia_arch_type) | |
| 56 if skia_arch_type == 'arm': | |
| 57 # Always use thumb and version 7 for arm | |
| 58 gyp_defines += 'arm_thumb=1 arm_version=7 ' | |
| 59 if have_neon: | |
| 60 gyp_defines += 'arm_neon=1 ' | |
| 61 else: | |
| 62 gyp_defines += 'arm_neon=0 ' | |
| 63 | |
| 64 os.environ['GYP_DEFINES'] = gyp_defines | |
| 65 | |
| 66 args = [] | |
| 67 args.extend(['--depth', '.']) | |
| 68 full_path = os.path.join(target_dir, target_file) | |
| 69 args.extend([full_path]) | |
| 70 # Common conditions | |
| 71 args.extend(['-I', os.path.join(target_dir, 'common.gypi')]) | |
| 72 # Use the debugging format. We'll use these to create one master make file. | |
| 73 args.extend(['-f', 'gypd']) | |
| 74 | |
| 75 # Off we go... | |
| 76 ret = gyp.main(args) | |
| 77 | |
| 78 if ret != 0: | |
| 79 raise Exception("gyp failed!") | |
| 80 | |
| 81 # Running gyp should have created a gypd file, with the same name as | |
| 82 # full_path but with a 'd' on the end. | |
| 83 gypd_file = full_path + 'd' | |
| 84 if not os.path.exists(gypd_file): | |
| 85 raise Exception("gyp failed to produce gypd file!") | |
| 86 | |
| 87 return gypd_file | |
| OLD | NEW |