| 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.abspath(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/gyp_gen). | 19 # (specifically, it is in platform_tools/android/gyp_gen). |
| 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 'gyp' in DIR_CONTENTS | 23 assert '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 if 'third_party' in DIR_CONTENTS: | 26 gyp_source_dir = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') |
| 27 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') | 27 if not os.path.exists(gyp_source_dir): |
| 28 else: | |
| 29 # In an Android tree, there is no third_party/externals/gyp, which would | 28 # In an Android tree, there is no third_party/externals/gyp, which would |
| 30 # require running gclient sync. Use chromium's instead. | 29 # require running gclient sync. Use chromium's instead. |
| 31 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, os.pardir, 'chromium_org', 'tools', | 30 gyp_source_dir = os.path.join(SKIA_DIR, os.pardir, 'chromium_org', 'tools', |
| 32 'gyp') | 31 'gyp') |
| 33 | 32 |
| 34 assert os.path.exists(GYP_SOURCE_DIR) | 33 assert os.path.exists(gyp_source_dir) |
| 35 | 34 |
| 36 # Ensure we import our current gyp source's module, not any version | 35 # Ensure we import our current gyp source's module, not any version |
| 37 # pre-installed in your PYTHONPATH. | 36 # pre-installed in your PYTHONPATH. |
| 38 sys.path.insert(0, os.path.join(GYP_SOURCE_DIR, 'pylib')) | 37 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) |
| 39 | 38 |
| 40 import gyp | 39 import gyp |
| 41 | 40 |
| 42 def main(target_dir, target_file, skia_arch_type, have_neon): | 41 def main(target_dir, target_file, skia_arch_type, have_neon): |
| 43 """Create gypd files based on target_file. | 42 """Create gypd files based on target_file. |
| 44 | 43 |
| 45 Args: | 44 Args: |
| 46 target_dir: Directory containing all gyp files, including common.gypi | 45 target_dir: Directory containing all gyp files, including common.gypi |
| 47 target_file: Gyp file to start on. Other files within target_dir will | 46 target_file: Gyp file to start on. Other files within target_dir will |
| 48 be read if target_file depends on them. | 47 be read if target_file depends on them. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 """Remove the gypd files generated by main(). | 93 """Remove the gypd files generated by main(). |
| 95 | 94 |
| 96 Args: | 95 Args: |
| 97 folder: Folder in which to delete all files ending with 'gypd'. | 96 folder: Folder in which to delete all files ending with 'gypd'. |
| 98 """ | 97 """ |
| 99 assert os.path.isdir(folder) | 98 assert os.path.isdir(folder) |
| 100 files = os.listdir(folder) | 99 files = os.listdir(folder) |
| 101 for f in files: | 100 for f in files: |
| 102 if f.endswith('gypd'): | 101 if f.endswith('gypd'): |
| 103 os.remove(os.path.join(folder, f)) | 102 os.remove(os.path.join(folder, f)) |
| OLD | NEW |