skia2/platform_tools/android/gyp_gen/makefile_writer.py

234 lines
7.0 KiB
Python
Raw Normal View History

#!/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.
"""
Functions for creating an Android.mk from already created dictionaries.
"""
import os
def write_group(f, name, items, append):
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
"""Helper function to list all names passed to a variable.
Args:
f: File open for writing (Android.mk)
name: Name of the makefile variable (e.g. LOCAL_CFLAGS)
items: list of strings to be passed to the variable.
append: Whether to append to the variable or overwrite it.
"""
if not items:
return
# Copy the list so we can prepend it with its name.
items_to_write = list(items)
if append:
items_to_write.insert(0, '%s +=' % name)
else:
items_to_write.insert(0, '%s :=' % name)
f.write(' \\\n\t'.join(items_to_write))
f.write('\n\n')
def write_local_vars(f, var_dict, append, name):
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
"""Helper function to write all the members of var_dict to the makefile.
Args:
f: File open for writing (Android.mk)
var_dict: VarsDict holding the unique values for one configuration.
append: Whether to append to each makefile variable or overwrite it.
name: If not None, a string to be appended to each key.
"""
for key in var_dict.keys():
Updates to Android.mk generation. Generate SkUserConfig. Include arm64 as another build flavor. Add tests. gyp/common_conditions.gypi: Add conditions for Android framework. These will get written into the generated SkUserConfig. include/core/SkUserConfig.h: Generated version that will ultimately be checked into Android (but not here). platform_tools/android/bin/gyp_to_android.py: Generate SkUserConfig. Add arm64 (note that arm64 is not currently respected by our gyp files, so it results in use _none.cpp for the various opts). Reset the common defines, which are now passed to the generated SkUserConfig. platform_tools/android/gyp_gen/generate_user_config.py: New script to generate SkUserConfig.h. platform_tools/android/gyp_gen/gypd_parser.py: Fix a lint error (unused import). platform_tools/android/gyp_gen/makefile_writer.py: Append any remaining DEFINES to LOCAL_CFLAGS (previously this was done during parsing). Add a warning for arm64 (corresponds to downstream Android.mk). platform_tools/android/gyp_gen/vars_dict_lib.py: Add OrderedSet.reset(). Add DEFINES to VarsDict. platform_tools/android/tests/expectations/: Add and update expectations files. platform_tools/android/tests/generate_user_config_tests.py: New test for generate_user_config.py platform_tools/android/tests/inputs/SkUserConfig.h: Input to the new test, so we don't have to update the expectations each time the real SkUserConfig.h changes. platform_tools/android/tests/makefile_writer_tests.py: Add a way to rebaseline test_write_local_vars, which has changed. Refactor EXPECTATIONS_DIR and compare_files into a separate file for sharing with generate_user_config_tests.py. platform_tools/android/tests/utils.py: Common code for tests. platform_tools/android/tests/var_dict_tests.py: Use a for loop to test the new key (DEFINES) and future proof this test to test any new keys in the future. BUG=skia:1975 R=djsollen@google.com, halcanary@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/198063002 git-svn-id: http://skia.googlecode.com/svn/trunk@13975 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-03-28 15:59:04 +00:00
_key = key
_items = var_dict[key]
if key == 'LOCAL_CFLAGS':
# Always append LOCAL_CFLAGS. This allows us to define some early on in
# the makefile and not overwrite them.
_append = True
Updates to Android.mk generation. Generate SkUserConfig. Include arm64 as another build flavor. Add tests. gyp/common_conditions.gypi: Add conditions for Android framework. These will get written into the generated SkUserConfig. include/core/SkUserConfig.h: Generated version that will ultimately be checked into Android (but not here). platform_tools/android/bin/gyp_to_android.py: Generate SkUserConfig. Add arm64 (note that arm64 is not currently respected by our gyp files, so it results in use _none.cpp for the various opts). Reset the common defines, which are now passed to the generated SkUserConfig. platform_tools/android/gyp_gen/generate_user_config.py: New script to generate SkUserConfig.h. platform_tools/android/gyp_gen/gypd_parser.py: Fix a lint error (unused import). platform_tools/android/gyp_gen/makefile_writer.py: Append any remaining DEFINES to LOCAL_CFLAGS (previously this was done during parsing). Add a warning for arm64 (corresponds to downstream Android.mk). platform_tools/android/gyp_gen/vars_dict_lib.py: Add OrderedSet.reset(). Add DEFINES to VarsDict. platform_tools/android/tests/expectations/: Add and update expectations files. platform_tools/android/tests/generate_user_config_tests.py: New test for generate_user_config.py platform_tools/android/tests/inputs/SkUserConfig.h: Input to the new test, so we don't have to update the expectations each time the real SkUserConfig.h changes. platform_tools/android/tests/makefile_writer_tests.py: Add a way to rebaseline test_write_local_vars, which has changed. Refactor EXPECTATIONS_DIR and compare_files into a separate file for sharing with generate_user_config_tests.py. platform_tools/android/tests/utils.py: Common code for tests. platform_tools/android/tests/var_dict_tests.py: Use a for loop to test the new key (DEFINES) and future proof this test to test any new keys in the future. BUG=skia:1975 R=djsollen@google.com, halcanary@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/198063002 git-svn-id: http://skia.googlecode.com/svn/trunk@13975 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-03-28 15:59:04 +00:00
elif key == 'DEFINES':
# For DEFINES, we want to append to LOCAL_CFLAGS.
_append = True
_key = 'LOCAL_CFLAGS'
_items_with_D = []
for define in _items:
_items_with_D.append('-D' + define)
_items = _items_with_D
elif key == 'KNOWN_TARGETS':
# KNOWN_TARGETS are not needed in the final make file.
continue
else:
_append = append
if name:
_key += '_' + name
Updates to Android.mk generation. Generate SkUserConfig. Include arm64 as another build flavor. Add tests. gyp/common_conditions.gypi: Add conditions for Android framework. These will get written into the generated SkUserConfig. include/core/SkUserConfig.h: Generated version that will ultimately be checked into Android (but not here). platform_tools/android/bin/gyp_to_android.py: Generate SkUserConfig. Add arm64 (note that arm64 is not currently respected by our gyp files, so it results in use _none.cpp for the various opts). Reset the common defines, which are now passed to the generated SkUserConfig. platform_tools/android/gyp_gen/generate_user_config.py: New script to generate SkUserConfig.h. platform_tools/android/gyp_gen/gypd_parser.py: Fix a lint error (unused import). platform_tools/android/gyp_gen/makefile_writer.py: Append any remaining DEFINES to LOCAL_CFLAGS (previously this was done during parsing). Add a warning for arm64 (corresponds to downstream Android.mk). platform_tools/android/gyp_gen/vars_dict_lib.py: Add OrderedSet.reset(). Add DEFINES to VarsDict. platform_tools/android/tests/expectations/: Add and update expectations files. platform_tools/android/tests/generate_user_config_tests.py: New test for generate_user_config.py platform_tools/android/tests/inputs/SkUserConfig.h: Input to the new test, so we don't have to update the expectations each time the real SkUserConfig.h changes. platform_tools/android/tests/makefile_writer_tests.py: Add a way to rebaseline test_write_local_vars, which has changed. Refactor EXPECTATIONS_DIR and compare_files into a separate file for sharing with generate_user_config_tests.py. platform_tools/android/tests/utils.py: Common code for tests. platform_tools/android/tests/var_dict_tests.py: Use a for loop to test the new key (DEFINES) and future proof this test to test any new keys in the future. BUG=skia:1975 R=djsollen@google.com, halcanary@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/198063002 git-svn-id: http://skia.googlecode.com/svn/trunk@13975 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-03-28 15:59:04 +00:00
write_group(f, _key, _items, _append)
AUTOGEN_WARNING = (
"""
###############################################################################
#
# THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT.
#
###############################################################################
"""
)
DEBUGGING_HELP = (
"""
###############################################################################
#
# PROBLEMS WITH SKIA DEBUGGING?? READ THIS...
#
# The debug build results in changes to the Skia headers. This means that those
# using libskia must also be built with the debug version of the Skia headers.
# There are a few scenarios where this comes into play:
#
# (1) You're building debug code that depends on libskia.
# (a) If libskia is built in release, then define SK_RELEASE when building
# your sources.
# (b) If libskia is built with debugging (see step 2), then no changes are
# needed since your sources and libskia have been built with SK_DEBUG.
# (2) You're building libskia in debug mode.
# (a) RECOMMENDED: You can build the entire system in debug mode. Do this by
# updating your build/core/config.mk to include -DSK_DEBUG on the line
# that defines COMMON_GLOBAL_CFLAGS
# (b) You can update all the users of libskia to define SK_DEBUG when they are
# building their sources.
#
# NOTE: If neither SK_DEBUG or SK_RELEASE are defined then Skia checks NDEBUG to
# determine which build type to use.
###############################################################################
"""
)
SKIA_TOOLS = (
"""
#############################################################
# Build the skia tools
#
# benchmark (timings)
Generate bench/Android.mk from gyp. For now, remove json functionality and do not depend on json. This allows us to build and run until solving skbug.com/2448. bench/DeferredSurfaceCopyBench.cpp: Include GrRenderTarget last, so SK_SUPPORT_GPU will be set properly. bench/ResultsWriter.h: bench/benchmain.cpp: Remove JSONResultsWriter when SK_BUILD_JSON_WRITER is not defined, which is the case for the Android framework build. gyp/bench.gyp: Depend on skia and cutils (for android_atomic_inc etc). gyp/common_conditions.gypi: Define SK_BUILD_JSON_WRITER when skia_build_json_writer is set. gyp/common_variables.gypi: Add a flag for skia_build_json_writer, and set it only when skia_android_framework is not set. gyp/jsoncpp.gyp: Do not build jsoncpp when skia_build_json_writer is not defined. include/utils/SkJSONCPP.h: Do not include json headers when SK_BUILD_JSON_WRITER is not defined. platform_tools/android/bin/gyp_to_android.py: Generate bench/Android.mk. platform_tools/android/gyp_gen/gypd_parser.py: Skip dest_dir when checking for include_dirs. platform_tools/android/gyp_gen/makefile_writer.py: Build bench/Android.mk when building external/skia. platform_tools/android/gyp_gen/tool_makefile_writer.py: Add a parameter for putting the binary into /data/local/tmp. BUG=skia:2447 BUG=skia:2448 R=halcanary@google.com, reed@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/282053002 git-svn-id: http://skia.googlecode.com/svn/trunk@14760 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-05-16 13:15:41 +00:00
include $(BASE_PATH)/bench/Android.mk
# golden-master (fidelity / regression test)
include $(BASE_PATH)/gm/Android.mk
# unit-tests
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
include $(BASE_PATH)/tests/Android.mk
# diamond-master (one test to rule them all)
include $(BASE_PATH)/dm/Android.mk
"""
)
class VarsDictData(object):
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
"""Helper class to keep a VarsDict along with a name and optional condition.
"""
def __init__(self, vars_dict, name, condition=None):
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
"""Create a new VarsDictData.
Args:
vars_dict: A VarsDict. Can be accessed via self.vars_dict.
name: Name associated with the VarsDict. Can be accessed via
self.name.
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
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
def write_local_path(f):
"""Add the LOCAL_PATH line to the makefile.
Args:
f: File open for writing.
"""
f.write('LOCAL_PATH:= $(call my-dir)\n')
def write_clear_vars(f):
"""Add the CLEAR_VARS line to the makefile.
Args:
f: File open for writing.
"""
f.write('include $(CLEAR_VARS)\n')
def write_include_stlport(f):
"""Add a line to include stlport.
Args:
f: File open for writing.
"""
f.write('include external/stlport/libstlport.mk\n')
def write_android_mk(target_dir, common, deviations_from_common):
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
"""Given all the variables, write the final make file.
Args:
target_dir: The full path to the directory to write Android.mk, or None
to use the current working directory.
common: VarsDict holding variables definitions common to all
configurations.
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:
target_file = os.path.join(target_dir, target_file)
with open(target_file, 'w') as f:
f.write(AUTOGEN_WARNING)
f.write('BASE_PATH := $(call my-dir)\n')
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
write_local_path(f)
f.write(DEBUGGING_HELP)
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
write_clear_vars(f)
f.write('LOCAL_ARM_MODE := thumb\n')
# 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)
# 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')
f.write('# used for testing\n')
f.write('#LOCAL_CFLAGS += -g -O0\n\n')
f.write('ifeq ($(NO_FALLBACK_FONT),true)\n')
f.write('\tLOCAL_CFLAGS += -DNO_FALLBACK_FONT\n')
f.write('endif\n\n')
write_local_vars(f, common, False, None)
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')
Generate tests/Android.mk from gyp gyp/apptype_console.gypi: Don't include console app dependencies when building for Android framework. gyp/tests.gyp: Add/remove libraries for framework build. platform_tools/android/bin/android_framework_gyp.py: Moved to gyp_gen. clean_up_gypd_files moved to this script. platform_tools/android/bin/gyp_to_android.py: Call new function for generating tool makefile. Set LOCAL_MODULE. platform_tools/android/gyp_gen/gypd_parser.py: Support relative paths. platform_tools/android/gyp_gen/makefile_writer.py: Factor out helper functions to be used by tool writer. LOCAL_MODULE is set elsewhere. platform_tools/android/gyp_gen/tool_makefile_writer.py: Multipurpose file for writing makefiles for tools. Should be able to use it mostly unchanged for bench, gm, etc. platform_tools/android/gyp_gen/vars_dict_lib.py: Make the comments follow the style guide. Add set(). Rename __li to __ordered_set More/update tests: platform_tools/android/tests/android_framework_gyp_tests.py platform_tools/android/tests/expectations/Android.mk platform_tools/android/tests/expectations/tool/Android.mk platform_tools/android/tests/expectations/write_local_vars_append_arm platform_tools/android/tests/expectations/write_local_vars_append_foo platform_tools/android/tests/expectations/write_local_vars_append_no_name platform_tools/android/tests/expectations/write_local_vars_no_append_arm platform_tools/android/tests/expectations/write_local_vars_no_append_foo platform_tools/android/tests/expectations/write_local_vars_no_append_no_name platform_tools/android/tests/gyp_to_android_tests.py platform_tools/android/tests/makefile_writer_tests.py platform_tools/android/tests/ordered_set_tests.py platform_tools/android/tests/test_variables.py BUG=skia:2447 May require an update to the bot to remove pyc files. R=halcanary@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/235883015 git-svn-id: http://skia.googlecode.com/svn/trunk@14408 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-28 16:00:30 +00:00
write_include_stlport(f)
f.write('include $(BUILD_SHARED_LIBRARY)\n')
f.write(SKIA_TOOLS)