Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: platform_tools/android/gyp_gen/android_framework_gyp.py

Issue 235883015: Generate tests/Android.mk from gyp (Closed) Base URL: https://skia.googlesource.com/skia.git@generate
Patch Set: Remove Android.mk/SkUserConfig.h Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bin). 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 if 'third_party' in DIR_CONTENTS:
27 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')
28 else: 28 else:
29 # In an Android tree, there is no third_party/externals/gyp, which would 29 # In an Android tree, there is no third_party/externals/gyp, which would
30 # require running gclient sync. Use chromium's instead. 30 # require running gclient sync. Use chromium's instead.
31 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, os.pardir, 'chromium_org', 'tools', 31 GYP_SOURCE_DIR = os.path.join(SKIA_DIR, os.pardir, 'chromium_org', 'tools',
32 'gyp') 32 'gyp')
33 33
34 assert os.path.exists(GYP_SOURCE_DIR) 34 assert os.path.exists(GYP_SOURCE_DIR)
35 35
36 # Ensure we import our current gyp source's module, not any version 36 # Ensure we import our current gyp source's module, not any version
37 # pre-installed in your PYTHONPATH. 37 # pre-installed in your PYTHONPATH.
38 sys.path.insert(0, os.path.join(GYP_SOURCE_DIR, 'pylib')) 38 sys.path.insert(0, os.path.join(GYP_SOURCE_DIR, 'pylib'))
39 39
40 import gyp 40 import gyp
41 41
42 def main(target_dir, target_file, skia_arch_type, have_neon): 42 def main(target_dir, target_file, skia_arch_type, have_neon):
43 """ 43 """Create gypd files based on target_file.
44 Create gypd files based on target_file. 44
45 @param target_dir Directory containing all gyp files, including common.gypi 45 Args:
46 @param target_file Gyp file to start on. Other files within target_dir will 46 target_dir: Directory containing all gyp files, including common.gypi
47 be read if target_file depends on them. 47 target_file: Gyp file to start on. Other files within target_dir will
48 @param skia_arch_type Target architecture to pass to gyp. 48 be read if target_file depends on them.
49 @param have_neon Whether to generate files including neon optimizations. 49 skia_arch_type: Target architecture to pass to gyp.
50 Only meaningful if skia_arch_type is 'arm'. 50 have_neon: Whether to generate files including neon optimizations.
51 @return path Path to root gypd file created by running gyp. 51 Only meaningful if skia_arch_type is 'arm'.
52
53 Returns:
54 path: Path to root gypd file created by running gyp.
52 """ 55 """
53 # Set GYP_DEFINES for building for the android framework. 56 # Set GYP_DEFINES for building for the android framework.
54 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' 57 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s '
55 % skia_arch_type) 58 % skia_arch_type)
56 if skia_arch_type == 'arm': 59 if skia_arch_type == 'arm':
57 # Always use thumb and version 7 for arm 60 # Always use thumb and version 7 for arm
58 gyp_defines += 'arm_thumb=1 arm_version=7 ' 61 gyp_defines += 'arm_thumb=1 arm_version=7 '
59 if have_neon: 62 if have_neon:
60 gyp_defines += 'arm_neon=1 ' 63 gyp_defines += 'arm_neon=1 '
61 else: 64 else:
(...skipping 16 matching lines...) Expand all
78 if ret != 0: 81 if ret != 0:
79 raise Exception("gyp failed!") 82 raise Exception("gyp failed!")
80 83
81 # Running gyp should have created a gypd file, with the same name as 84 # Running gyp should have created a gypd file, with the same name as
82 # full_path but with a 'd' on the end. 85 # full_path but with a 'd' on the end.
83 gypd_file = full_path + 'd' 86 gypd_file = full_path + 'd'
84 if not os.path.exists(gypd_file): 87 if not os.path.exists(gypd_file):
85 raise Exception("gyp failed to produce gypd file!") 88 raise Exception("gyp failed to produce gypd file!")
86 89
87 return gypd_file 90 return gypd_file
91
92
93 def clean_gypd_files(folder):
94 """Remove the gypd files generated by main().
95
96 Args:
97 folder: Folder in which to delete all files ending with 'gypd'.
98 """
99 assert os.path.isdir(folder)
100 files = os.listdir(folder)
101 for f in files:
102 if f.endswith('gypd'):
103 os.remove(os.path.join(folder, f))
OLDNEW
« no previous file with comments | « platform_tools/android/bin/gyp_to_android.py ('k') | platform_tools/android/gyp_gen/gypd_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698