| OLD | NEW | 
|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python | 
| 2 | 2 | 
| 3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. | 
| 4 # | 4 # | 
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be | 
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. | 
| 7 | 7 | 
| 8 """ | 8 """ | 
| 9 Modified version of gyp_skia, used by gyp_to_android.py to generate Android.mk | 9 Modified version of gyp_skia, used by gyp_to_android.py to generate Android.mk | 
| 10 """ | 10 """ | 
| 11 | 11 | 
| 12 import os | 12 import os | 
| 13 import sys | 13 import sys | 
| 14 | 14 | 
| 15 script_dir = os.path.dirname(__file__) | 15 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) | 
| 16 | 16 | 
| 17 # Unlike gyp_skia, this file is nested deep inside Skia. Find Skia's trunk dir. | 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 | 18 # This line depends on the fact that the script is three levels deep | 
| 19 # (specifically, it is in platform_tools/android/bin). | 19 # (specifically, it is in platform_tools/android/bin). | 
| 20 skia_dir = os.path.normpath(os.path.join(script_dir, os.pardir, os.pardir, | 20 SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, | 
| 21                                          os.pardir)) | 21                                          os.pardir)) | 
| 22 dir_contents = os.listdir(skia_dir) | 22 dir_contents = os.listdir(SKIA_DIR) | 
| 23 assert 'third_party' in dir_contents and 'gyp' in dir_contents | 23 assert 'third_party' in dir_contents and 'gyp' in dir_contents | 
| 24 | 24 | 
| 25 # Directory within which we can find the gyp source. | 25 # Directory within which we can find the gyp source. | 
| 26 gyp_source_dir = os.path.join(skia_dir, 'third_party', 'externals', 'gyp') | 26 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') | 
| 27 |  | 
| 28 # Directory within which we can find most of Skia's gyp configuration files. |  | 
| 29 gyp_config_dir = os.path.join(skia_dir, 'gyp') |  | 
| 30 | 27 | 
| 31 # Ensure we import our current gyp source's module, not any version | 28 # Ensure we import our current gyp source's module, not any version | 
| 32 # pre-installed in your PYTHONPATH. | 29 # pre-installed in your PYTHONPATH. | 
| 33 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) | 30 sys.path.insert(0, os.path.join(GYP_SOURCE_DIR, 'pylib')) | 
| 34 | 31 | 
| 35 import gyp | 32 import gyp | 
| 36 | 33 | 
| 37 def main(skia_arch_type, have_neon): | 34 def main(target_dir, target_file, skia_arch_type, have_neon): | 
|  | 35   """ | 
|  | 36   Create gypd files based on target_file. | 
|  | 37   @param target_dir Directory containing all gyp files, including common.gypi | 
|  | 38   @param target_file Gyp file to start on. Other files within target_dir will | 
|  | 39                      be read if target_file depends on them. | 
|  | 40   @param skia_arch_type Target architecture to pass to gyp. | 
|  | 41   @param have_neon Whether to generate files including neon optimizations. | 
|  | 42                    Only meaningful if skia_arch_type is 'arm'. | 
|  | 43   """ | 
| 38   # Set GYP_DEFINES for building for the android framework. | 44   # Set GYP_DEFINES for building for the android framework. | 
| 39   gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' | 45   gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' | 
| 40                  % skia_arch_type) | 46                  % skia_arch_type) | 
| 41   if skia_arch_type == 'arm': | 47   if skia_arch_type == 'arm': | 
| 42     # Always use thumb and version 7 for arm | 48     # Always use thumb and version 7 for arm | 
| 43     gyp_defines += 'arm_thumb=1 arm_version=7 ' | 49     gyp_defines += 'arm_thumb=1 arm_version=7 ' | 
| 44     if have_neon: | 50     if have_neon: | 
| 45       gyp_defines += 'arm_neon=1 ' | 51       gyp_defines += 'arm_neon=1 ' | 
| 46     else: | 52     else: | 
| 47       gyp_defines += 'arm_neon=0 ' | 53       gyp_defines += 'arm_neon=0 ' | 
| 48 | 54 | 
| 49   os.environ['GYP_DEFINES'] = gyp_defines | 55   os.environ['GYP_DEFINES'] = gyp_defines | 
| 50 | 56 | 
| 51   args = [] | 57   args = [] | 
| 52   args.extend(['--depth', '.']) | 58   args.extend(['--depth', '.']) | 
| 53   # Use the android_framework_lib file instead of skia.gyp | 59   args.extend([os.path.join(target_dir, target_file)]) | 
| 54   args.extend([os.path.join(gyp_config_dir, 'android_framework_lib.gyp')]) |  | 
| 55   # Common conditions | 60   # Common conditions | 
| 56   args.extend(['-I', 'gyp/common.gypi']) | 61   args.extend(['-I', os.path.join(target_dir, 'common.gypi')]) | 
| 57   # Use the debugging format. We'll use these to create one master make file. | 62   # Use the debugging format. We'll use these to create one master make file. | 
| 58   args.extend(['-f', 'gypd']) | 63   args.extend(['-f', 'gypd']) | 
| 59 | 64 | 
| 60   # Off we go... | 65   # Off we go... | 
| 61   return gyp.main(args) | 66   return gyp.main(args) | 
| OLD | NEW | 
|---|