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

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

Issue 1696483002: Update Android framework makefile to build static and shared libs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: new test Created 4 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
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 Functions for creating an Android.mk from already created dictionaries. 9 Functions for creating an Android.mk from already created dictionaries.
10 """ 10 """
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 # (2) You're building libskia in debug mode. 101 # (2) You're building libskia in debug mode.
102 # (a) RECOMMENDED: You can build the entire system in debug mode. Do this by 102 # (a) RECOMMENDED: You can build the entire system in debug mode. Do this by
103 # updating your build/core/config.mk to include -DSK_DEBUG on the line 103 # updating your build/core/config.mk to include -DSK_DEBUG on the line
104 # that defines COMMON_GLOBAL_CFLAGS 104 # that defines COMMON_GLOBAL_CFLAGS
105 # (b) You can update all the users of libskia to define SK_DEBUG when they are 105 # (b) You can update all the users of libskia to define SK_DEBUG when they are
106 # building their sources. 106 # building their sources.
107 # 107 #
108 # NOTE: If neither SK_DEBUG or SK_RELEASE are defined then Skia checks NDEBUG to 108 # NOTE: If neither SK_DEBUG or SK_RELEASE are defined then Skia checks NDEBUG to
109 # determine which build type to use. 109 # determine which build type to use.
110 ############################################################################### 110 ###############################################################################
111
112 """ 111 """
113 ) 112 )
114 113
115 SKIA_TOOLS = ( 114 SKIA_TOOLS = (
116 """ 115 """
117 ############################################################# 116 #############################################################
118 # Build the skia tools 117 # Build the skia tools
119 # 118 #
120 119
121 # benchmark (timings) 120 # benchmark (timings)
122 include $(BASE_PATH)/bench/Android.mk 121 include $(BASE_PATH)/bench/Android.mk
123 122
124 # diamond-master (one test to rule them all) 123 # diamond-master (one test to rule them all)
125 include $(BASE_PATH)/dm/Android.mk 124 include $(BASE_PATH)/dm/Android.mk
126 """ 125 """
127 ) 126 )
128 127
128 STATIC_HEADER = (
129 """
130 ###############################################################################
131 # STATIC LIBRARY
132 #
133 # This target is only to be used internally for only one of two purposes...
134 # (1) statically linking into testing frameworks
135 # (2) as an inclusion target for the libskia.so shared library
136 ###############################################################################
137
138 """
139 )
140
141 SHARED_HEADER = (
142 """
143 ###############################################################################
144 # SHARED LIBRARY
145 ###############################################################################
146
147 """
148 )
149
150 STATIC_DEPS_INFO = (
151 """
152 ###############################################################################
153 #
154 # This file contains the shared and static dependencies needed by any target
155 # that attempts to statically link Skia (i.e. libskia_static build target).
156 #
157 # This is a workaround for the fact that the build system does not add these
158 # transitive dependencies when it attempts to link libskia_static into another
159 # library.
160 #
161 ###############################################################################
162 """
163 )
164
165 CLEAR_VARS = ("""include $(CLEAR_VARS)\n""")
166 LOCAL_PATH = ("""LOCAL_PATH:= $(call my-dir)\n""")
129 167
130 class VarsDictData(object): 168 class VarsDictData(object):
131 """Helper class to keep a VarsDict along with a name and optional condition. 169 """Helper class to keep a VarsDict along with a name and optional condition.
132 """ 170 """
133 def __init__(self, vars_dict, name, condition=None): 171 def __init__(self, vars_dict, name, condition=None):
134 """Create a new VarsDictData. 172 """Create a new VarsDictData.
135 173
136 Args: 174 Args:
137 vars_dict: A VarsDict. Can be accessed via self.vars_dict. 175 vars_dict: A VarsDict. Can be accessed via self.vars_dict.
138 name: Name associated with the VarsDict. Can be accessed via 176 name: Name associated with the VarsDict. Can be accessed via
139 self.name. 177 self.name.
140 condition: Optional string representing a condition. If not None, 178 condition: Optional string representing a condition. If not None,
141 used to create a conditional inside the makefile. 179 used to create a conditional inside the makefile.
142 """ 180 """
143 self.vars_dict = vars_dict 181 self.vars_dict = vars_dict
144 self.condition = condition 182 self.condition = condition
145 self.name = name 183 self.name = name
146 184
147 def write_local_path(f): 185 def write_static_deps_mk(target_dir, common, deviations_from_common):
148 """Add the LOCAL_PATH line to the makefile. 186 """Given all the variables, write the final make file.
149 187
150 Args: 188 Args:
151 f: File open for writing. 189 target_dir: The full path to the directory to write skia_static_includes.mk,
190 or None to use the current working directory.
191 common: VarsDict holding variables definitions common to all
192 configurations.
193 deviations_from_common: List of VarsDictData, one for each possible
194 configuration. VarsDictData.name will be appended to each key before
195 writing it to the makefile. VarsDictData.condition, if not None, will be
196 written to the makefile as a condition to determine whether to include
197 VarsDictData.vars_dict.
152 """ 198 """
153 f.write('LOCAL_PATH:= $(call my-dir)\n') 199 target_file = 'skia_static_deps.mk'
200 if target_dir:
201 target_file = os.path.join(target_dir, target_file)
202 with open(target_file, 'w') as f:
203 f.write(AUTOGEN_WARNING)
204 f.write(STATIC_DEPS_INFO)
154 205
155 def write_clear_vars(f): 206 for data in deviations_from_common:
156 """Add the CLEAR_VARS line to the makefile. 207 var_dict_shared = data.vars_dict['LOCAL_SHARED_LIBRARIES']
208 var_dict_static = data.vars_dict['LOCAL_STATIC_LIBRARIES']
209 if data.condition and (var_dict_shared or var_dict_static):
210 f.write('ifeq ($(%s), true)\n' % data.condition)
211 write_group(f, 'LOCAL_SHARED_LIBRARIES', var_dict_shared, True)
212 write_group(f, 'LOCAL_STATIC_LIBRARIES', var_dict_static, True)
213 if data.condition and (var_dict_shared or var_dict_static):
214 f.write('endif\n\n')
157 215
158 Args: 216 write_group(f, 'LOCAL_SHARED_LIBRARIES', common['LOCAL_SHARED_LIBRARIES'],
159 f: File open for writing. 217 True)
160 """ 218 write_group(f, 'LOCAL_STATIC_LIBRARIES', common['LOCAL_STATIC_LIBRARIES'],
161 f.write('include $(CLEAR_VARS)\n') 219 True)
220
162 221
163 def write_android_mk(target_dir, common, deviations_from_common): 222 def write_android_mk(target_dir, common, deviations_from_common):
164 """Given all the variables, write the final make file. 223 """Given all the variables, write the final make file.
165 224
166 Args: 225 Args:
167 target_dir: The full path to the directory to write Android.mk, or None 226 target_dir: The full path to the directory to write Android.mk, or None
168 to use the current working directory. 227 to use the current working directory.
169 common: VarsDict holding variables definitions common to all 228 common: VarsDict holding variables definitions common to all
170 configurations. 229 configurations.
171 deviations_from_common: List of VarsDictData, one for each possible 230 deviations_from_common: List of VarsDictData, one for each possible
172 configuration. VarsDictData.name will be appended to each key before 231 configuration. VarsDictData.name will be appended to each key before
173 writing it to the makefile. VarsDictData.condition, if not None, will be 232 writing it to the makefile. VarsDictData.condition, if not None, will be
174 written to the makefile as a condition to determine whether to include 233 written to the makefile as a condition to determine whether to include
175 VarsDictData.vars_dict. 234 VarsDictData.vars_dict.
176 """ 235 """
177 target_file = 'Android.mk' 236 target_file = 'Android.mk'
178 if target_dir: 237 if target_dir:
179 target_file = os.path.join(target_dir, target_file) 238 target_file = os.path.join(target_dir, target_file)
180 with open(target_file, 'w') as f: 239 with open(target_file, 'w') as f:
181 f.write(AUTOGEN_WARNING) 240 f.write(AUTOGEN_WARNING)
182 f.write('BASE_PATH := $(call my-dir)\n') 241 f.write('BASE_PATH := $(call my-dir)\n')
183 write_local_path(f) 242 f.write(LOCAL_PATH)
184 243
185 f.write(DEBUGGING_HELP) 244 f.write(DEBUGGING_HELP)
186 245
187 write_clear_vars(f) 246 f.write(STATIC_HEADER)
247 f.write(CLEAR_VARS)
188 248
189 # need flags to enable feedback driven optimization (FDO) when requested 249 # need flags to enable feedback driven optimization (FDO) when requested
190 # by the build system. 250 # by the build system.
191 f.write('LOCAL_FDO_SUPPORT := true\n') 251 f.write('LOCAL_FDO_SUPPORT := true\n')
192 f.write('ifneq ($(strip $(TARGET_FDO_CFLAGS)),)\n') 252 f.write('ifneq ($(strip $(TARGET_FDO_CFLAGS)),)\n')
193 f.write('\t# This should be the last -Oxxx specified in LOCAL_CFLAGS\n') 253 f.write('\t# This should be the last -Oxxx specified in LOCAL_CFLAGS\n')
194 f.write('\tLOCAL_CFLAGS += -O2\n') 254 f.write('\tLOCAL_CFLAGS += -O2\n')
195 f.write('endif\n\n') 255 f.write('endif\n\n')
196 256
197 f.write('LOCAL_ARM_MODE := thumb\n') 257 f.write('LOCAL_ARM_MODE := thumb\n')
198 258
199 f.write('# used for testing\n') 259 f.write('# used for testing\n')
200 f.write('#LOCAL_CFLAGS += -g -O0\n\n') 260 f.write('#LOCAL_CFLAGS += -g -O0\n\n')
201 261
202 f.write('ifeq ($(NO_FALLBACK_FONT),true)\n') 262 # update the provided LOCAL_MODULE with a _static suffix
203 f.write('\tLOCAL_CFLAGS += -DNO_FALLBACK_FONT\n') 263 local_module = common['LOCAL_MODULE'][0]
204 f.write('endif\n\n') 264 static_local_module = local_module + '_static'
265 common['LOCAL_MODULE'].reset()
266 common['LOCAL_MODULE'].add(static_local_module)
205 267
206 write_local_vars(f, common, False, None) 268 write_local_vars(f, common, False, None)
207 269
208 for data in deviations_from_common: 270 for data in deviations_from_common:
209 if data.condition: 271 if data.condition:
210 f.write('ifeq ($(%s), true)\n' % data.condition) 272 f.write('ifeq ($(%s), true)\n' % data.condition)
211 write_local_vars(f, data.vars_dict, True, data.name) 273 write_local_vars(f, data.vars_dict, True, data.name)
212 if data.condition: 274 if data.condition:
213 f.write('endif\n\n') 275 f.write('endif\n\n')
214 276
277 f.write('LOCAL_MODULE_CLASS := STATIC_LIBRARIES\n')
278 f.write('include $(BUILD_STATIC_LIBRARY)\n\n')
279
280 f.write(SHARED_HEADER)
281 f.write(CLEAR_VARS)
282 f.write('LOCAL_MODULE_CLASS := SHARED_LIBRARIES\n')
283 f.write('LOCAL_MODULE := %s\n' % local_module)
284 f.write('LOCAL_WHOLE_STATIC_LIBRARIES := %s\n' % static_local_module)
285 write_group(f, 'LOCAL_EXPORT_C_INCLUDE_DIRS',
286 common['LOCAL_EXPORT_C_INCLUDE_DIRS'], False)
287 f.write('include $(BASE_PATH)/skia_static_deps.mk\n')
215 f.write('include $(BUILD_SHARED_LIBRARY)\n') 288 f.write('include $(BUILD_SHARED_LIBRARY)\n')
289
216 f.write(SKIA_TOOLS) 290 f.write(SKIA_TOOLS)
217 291
OLDNEW
« no previous file with comments | « platform_tools/android/bin/gyp_to_android.py ('k') | platform_tools/android/gyp_gen/tool_makefile_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698