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

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

Issue 140503007: Scripts to generate Android.mk for framework Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: VarsDict = namedtuple of OrderedSets Created 6 years, 10 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
(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 Functions for creating an Android.mk from already created dictionaries.
10 """
11
12 # TODO (scroggo): I'm assuming I need to import this because I use it, but
13 # I never state that's the class I'm using.
14 from vars_dict_lib import VarsDict
15 import variables
16
17 def write_group(f, name, items, append):
18 """
19 Helper function to list all names passed to a variable.
20 @param f File open for writing (Android.mk)
21 @param name Name of the makefile variable (e.g. LOCAL_CFLAGS)
22 @param items list of strings to be passed to the variable.
23 @param append Whether to append to the variable or overwrite it.
24 """
25 if not items:
26 return
27
28 # Copy the list so we can prepend it with its name.
29 items_to_write = list(items)
30
31 if append:
32 items_to_write.insert(0, '%s +=' % name)
33 else:
34 items_to_write.insert(0, '%s :=' % name)
35
36 f.write(' \\\n\t'.join(items_to_write))
37
38 f.write('\n\n')
39
40
41 def write_local_vars(f, var_dict, append):
42 """
43 Helper function to write all the members of var_dict to the makefile.
44 @param f File open for writing (Android.mk)
45 @param var_dict VarsDict holding the unique values for one configuration.
46 @param append Whether to append to each makefile variable or overwrite it.
47 """
48 for field in var_dict._fields:
49 if field == 'LOCAL_CFLAGS':
50 # Always append LOCAL_CFLAGS. This allows us to define some early on in th e
51 # makefile and not overwrite them.
52 _append = True
53 elif field == 'KNOWN_TARGETS':
54 # KNOWN_TARGETS are not needed in the final make file.
55 continue
56 else:
57 _append = append
58 write_group(f, field, eval('var_dict.%s' % field), _append)
scroggo 2014/01/31 22:16:24 This is the only drawback (in my mind) of switchin
scroggo 2014/02/01 16:24:01 Figured this out. Next patch will address this.
59
60
61 AUTOGEN_WARNING = (
62 """
63 ###############################################################################
64 #
65 # THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT.
66 #
67 ###############################################################################
68
69 """
70 )
71
72
73 DEBUGGING_HELP = (
74 """
75 ###############################################################################
76 #
77 # PROBLEMS WITH SKIA DEBUGGING?? READ THIS...
78 #
79 # The debug build results in changes to the Skia headers. This means that those
80 # using libskia must also be built with the debug version of the Skia headers.
81 # There are a few scenarios where this comes into play:
82 #
83 # (1) You're building debug code that depends on libskia.
84 # (a) If libskia is built in release, then define SK_RELEASE when building
85 # your sources.
86 # (b) If libskia is built with debugging (see step 2), then no changes are
87 # needed since your sources and libskia have been built with SK_DEBUG.
88 # (2) You're building libskia in debug mode.
89 # (a) RECOMMENDED: You can build the entire system in debug mode. Do this by
90 # updating your build/config.mk to include -DSK_DEBUG on the line that
91 # defines COMMON_GLOBAL_CFLAGS
92 # (b) You can update all the users of libskia to define SK_DEBUG when they are
93 # building their sources.
94 #
95 # NOTE: If neither SK_DEBUG or SK_RELEASE are defined then Skia checks NDEBUG to
96 # determine which build type to use.
97 ###############################################################################
98
99 """
100 )
101
102
103 def write_android_mk(target_dir, common, arm, armNeon, x86, default):
104 """
105 Given all the variables, write the final make file.
106 @param target_dir The full path to the directory to write Android.mk, or None
107 to use the current working directory.
108 @param common VarsDict holding variables definitions common to all
109 configurations.
110 @param arm VarsDict holding variable definitions unique to arm. Will be
111 written to the makefile inside an 'ifeq ($(TARGET_ARCH), arm)'
112 block.
113 @param armNeon VarsDict holding variable definitions unique to arm with neon.
114 Will be written inside an 'ifeq ($(ARCH_ARM_HAVE_NEON),true)'
115 block nested inside an 'ifeq ($(TARGET_ARCH), arm)' block.
116 @param x86 VarsDict holding variable definitions unique to x86. Will be
117 written inside an 'ifeq ($(TARGET_ARCH),x86)' block.
118 @param default VarsDict holding variable definitions for an architecture
119 without custom optimizations.
120 TODO: Add mips.
121 """
122 target_file = 'Android.mk'
123 if target_dir:
124 target_file = os.path.join(target_dir, target_file)
125 with open(target_file, 'w') as f:
126 f.write(AUTOGEN_WARNING)
127 f.write('BASE_PATH := $(call my-dir)\n')
128 f.write('LOCAL_PATH:= $(call my-dir)\n')
129
130 f.write(DEBUGGING_HELP)
131
132 f.write('include $(CLEAR_VARS)\n')
133
134 f.write('LOCAL_ARM_MODE := thumb\n')
135
136 # need a flag to tell the C side when we're on devices with large memory
137 # budgets (i.e. larger than the low-end devices that initially shipped)
138 f.write('ifeq ($(ARCH_ARM_HAVE_VFP),true)\n')
139 f.write('\tLOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE\n')
140 f.write('endif\n\n')
141
142 f.write('ifeq ($(TARGET_ARCH),x86)\n')
143 f.write('\tLOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE\n')
144 f.write('endif\n\n')
145
146 f.write('# used for testing\n')
147 f.write('#LOCAL_CFLAGS += -g -O0\n\n')
148
149 f.write('ifeq ($(NO_FALLBACK_FONT),true)\n')
150 f.write('\tLOCAL_CFLAGS += -DNO_FALLBACK_FONT\n')
151 f.write('endif\n\n')
152
153 write_local_vars(f, common, False)
154
155 f.write('ifeq ($(TARGET_ARCH),arm)\n')
156 f.write('ifeq ($(ARCH_ARM_HAVE_NEON),true)\n')
157 write_local_vars(f, armNeon, True)
158 f.write('endif\n\n')
159 write_local_vars(f, arm, True)
160
161 if variables.INCLUDE_X86_OPTS:
162 f.write('else ifeq ($(TARGET_ARCH),x86)\n')
163 write_local_vars(f, x86, True)
164
165 f.write('else\n')
166 write_local_vars(f, default, True)
167 f.write('endif\n\n')
168
169 f.write('include external/stlport/libstlport.mk\n')
170 f.write('LOCAL_MODULE:= libskia\n')
171 f.write('include $(BUILD_SHARED_LIBRARY)\n')
172
173
174
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698