aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-28 17:24:32 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-28 17:24:32 +0000
commit069c2a46ba2dc419dcd7dbcb9bf3b83c49b45b41 (patch)
tree5765658035cebf9811ba8d918c8cfc26b58f33cc
parent6c50cd31ede8833b30117fc0c56a0c5cc31ca2ea (diff)
Updates to the Android.mk writer.
Keeping up with changes made to the Android.mk file that is currently checked in. R=djsollen@google.com, epoger@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/183953002 git-svn-id: http://skia.googlecode.com/svn/trunk@13626 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--platform_tools/android/bin/gyp_to_android.py36
-rw-r--r--platform_tools/android/gyp_gen/makefile_writer.py87
-rw-r--r--platform_tools/android/gyp_gen/variables.py11
3 files changed, 70 insertions, 64 deletions
diff --git a/platform_tools/android/bin/gyp_to_android.py b/platform_tools/android/bin/gyp_to_android.py
index 7990ae9d8b..191d0390fe 100644
--- a/platform_tools/android/bin/gyp_to_android.py
+++ b/platform_tools/android/bin/gyp_to_android.py
@@ -27,12 +27,13 @@ sys.path.append(GYP_GEN_DIR)
import gypd_parser
import makefile_writer
-import variables
import vars_dict_lib
# Folder containing all gyp files and generated gypd files.
GYP_FOLDER = 'gyp'
+# TODO(scroggo): Update the docstrings to match the style guide:
+# http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments
def clean_gypd_files(folder):
"""
Remove the gypd files generated by android_framework_gyp.main().
@@ -101,17 +102,15 @@ def main(target_dir=None):
arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False)
arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm',
True)
- if variables.INCLUDE_X86_OPTS:
- x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False)
- else:
- x86_var_dict = None
+ x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False)
+
+ mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False)
# Compute the intersection of all targets. All the files in the intersection
# should be part of the makefile always. Each dict will now contain trimmed
# lists containing only variable definitions specific to that configuration.
- var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict]
- if variables.INCLUDE_X86_OPTS:
- var_dict_list.append(x86_var_dict)
+ var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict,
+ x86_var_dict, mips_var_dict]
common = vars_dict_lib.intersect(var_dict_list)
# Further trim arm_neon_var_dict with arm_var_dict. After this call,
@@ -120,12 +119,23 @@ def main(target_dir=None):
# those specific to arm + neon.
arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict])
+ # Now create a list of VarsDictData holding everything but common.
+ deviations_from_common = []
+ deviations_from_common.append(makefile_writer.VarsDictData(
+ arm_var_dict, 'arm'))
+ deviations_from_common.append(makefile_writer.VarsDictData(
+ arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON'))
+ deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict,
+ 'x86'))
+ # Currently, x86_64 is identical to x86
+ deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict,
+ 'x86_64'))
+
+ deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict,
+ 'mips'))
+
makefile_writer.write_android_mk(target_dir=target_dir,
- common=common,
- arm=arm_var_dict,
- arm_neon=arm_neon_var_dict,
- x86=x86_var_dict,
- default=default_var_dict)
+ common=common, deviations_from_common=deviations_from_common)
finally:
shutil.rmtree(tmp_folder)
diff --git a/platform_tools/android/gyp_gen/makefile_writer.py b/platform_tools/android/gyp_gen/makefile_writer.py
index ea3a27ff1e..6057ccee30 100644
--- a/platform_tools/android/gyp_gen/makefile_writer.py
+++ b/platform_tools/android/gyp_gen/makefile_writer.py
@@ -10,8 +10,8 @@ Functions for creating an Android.mk from already created dictionaries.
"""
import os
-import variables
+# TODO(scroggo): Add unit tests for this file.
def write_group(f, name, items, append):
"""
Helper function to list all names passed to a variable.
@@ -36,12 +36,13 @@ def write_group(f, name, items, append):
f.write('\n\n')
-def write_local_vars(f, var_dict, append):
+def write_local_vars(f, var_dict, append, name):
"""
Helper function to write all the members of var_dict to the makefile.
@param f File open for writing (Android.mk)
@param var_dict VarsDict holding the unique values for one configuration.
@param append Whether to append to each makefile variable or overwrite it.
+ @param name If not None, a string to be appended to each key.
"""
for key in var_dict.keys():
if key == 'LOCAL_CFLAGS':
@@ -53,7 +54,10 @@ def write_local_vars(f, var_dict, append):
continue
else:
_append = append
- write_group(f, key, var_dict[key], _append)
+ _key = key
+ if name:
+ _key += '_' + name
+ write_group(f, _key, var_dict[key], _append)
AUTOGEN_WARNING = (
@@ -97,28 +101,38 @@ DEBUGGING_HELP = (
"""
)
-
-# TODO (scroggo): Currently write_android_mk has intimate knowledge about its
-# parameters: e.g. arm_neon keeps track of differences from arm, whereas the
-# others keep track of differences from common. Consider reworking this.
-def write_android_mk(target_dir, common, arm, arm_neon, x86, default):
+class VarsDictData(object):
+ """
+ Helper class for keeping a VarsDict along with a name and an optional
+ condition.
+ """
+ def __init__(self, vars_dict, name, condition=None):
+ """
+ Create a new VarsDictData.
+ @param vars_dict A VarsDict. Can be accessed via self.vars_dict.
+ @param name Name associated with the VarsDict. Can be accessed via
+ self.name.
+ @param condition Optional string representing a condition. If not None,
+ used to create a conditional inside the makefile.
+ """
+ self.vars_dict = vars_dict
+ self.condition = condition
+ self.name = name
+
+def write_android_mk(target_dir, common, deviations_from_common):
"""
Given all the variables, write the final make file.
@param target_dir The full path to the directory to write Android.mk, or None
to use the current working directory.
@param common VarsDict holding variables definitions common to all
configurations.
- @param arm VarsDict holding variable definitions unique to arm. Will be
- written to the makefile inside an 'ifeq ($(TARGET_ARCH), arm)'
- block.
- @param arm_neon VarsDict holding variable definitions unique to arm with neon.
- Will be written inside an 'ifeq ($(ARCH_ARM_HAVE_NEON),true)'
- block nested inside an 'ifeq ($(TARGET_ARCH), arm)' block.
- @param x86 VarsDict holding variable definitions unique to x86. Will be
- written inside an 'ifeq ($(TARGET_ARCH),x86)' block.
- @param default VarsDict holding variable definitions for an architecture
- without custom optimizations.
- TODO: Add mips.
+ @param deviations_from_common List of VarsDictData, one for each possible
+ configuration. VarsDictData.name will be
+ appended to each key before writing it to the
+ makefile. VarsDictData.condition, if not None,
+ will be written to the makefile as a condition
+ to determine whether to include
+ VarsDictData.vars_dict.
"""
target_file = 'Android.mk'
if target_dir:
@@ -136,11 +150,13 @@ def write_android_mk(target_dir, common, arm, arm_neon, x86, default):
# need a flag to tell the C side when we're on devices with large memory
# budgets (i.e. larger than the low-end devices that initially shipped)
- f.write('ifeq ($(ARCH_ARM_HAVE_VFP),true)\n')
- f.write('\tLOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE\n')
- f.write('endif\n\n')
-
- f.write('ifeq ($(TARGET_ARCH),x86)\n')
+ # On arm, only define the flag if it has VFP. For all other architectures,
+ # always define the flag.
+ f.write('ifeq ($(TARGET_ARCH),arm)\n')
+ f.write('\tifeq ($(ARCH_ARM_HAVE_VFP),true)\n')
+ f.write('\t\tLOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE\n')
+ f.write('\tendif\n')
+ f.write('else\n')
f.write('\tLOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE\n')
f.write('endif\n\n')
@@ -151,25 +167,16 @@ def write_android_mk(target_dir, common, arm, arm_neon, x86, default):
f.write('\tLOCAL_CFLAGS += -DNO_FALLBACK_FONT\n')
f.write('endif\n\n')
- write_local_vars(f, common, False)
+ write_local_vars(f, common, False, None)
- f.write('ifeq ($(TARGET_ARCH),arm)\n')
- f.write('ifeq ($(ARCH_ARM_HAVE_NEON),true)\n')
- write_local_vars(f, arm_neon, True)
- f.write('endif\n\n')
- write_local_vars(f, arm, True)
-
- if variables.INCLUDE_X86_OPTS:
- f.write('else ifeq ($(TARGET_ARCH),x86)\n')
- write_local_vars(f, x86, True)
-
- f.write('else\n')
- write_local_vars(f, default, True)
- f.write('endif\n\n')
+ for data in deviations_from_common:
+ if data.condition:
+ f.write('ifeq ($(%s), true)\n' % data.condition)
+ write_local_vars(f, data.vars_dict, True, data.name)
+ if data.condition:
+ f.write('endif\n\n')
f.write('include external/stlport/libstlport.mk\n')
f.write('LOCAL_MODULE:= libskia\n')
f.write('include $(BUILD_SHARED_LIBRARY)\n')
-
-
diff --git a/platform_tools/android/gyp_gen/variables.py b/platform_tools/android/gyp_gen/variables.py
deleted file mode 100644
index 326254a86e..0000000000
--- a/platform_tools/android/gyp_gen/variables.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-
-# Copyright 2014 Google Inc.
-#
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# TODO (scroggo): Currently the x86 specific files are not included. Include
-# them.
-INCLUDE_X86_OPTS = False
-