aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-01-26 17:28:35 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 19:10:49 +0000
commitfe8225802d2ab0dbc6f0d40f9666ebca1b4e2a4a (patch)
treed54aa490da8283c5fbd3d873618624ebbbdf44d2 /platform_tools
parent428865794bd76937f4ad03d791ca07cda131f83e (diff)
Remove old generator code
We're generating Android.bp from BUILD.gn, so no need for the old version. Change-Id: Ie5bcec1d4f15d0e9a178feb9191e42c872bd8e08 Reviewed-on: https://skia-review.googlesource.com/7639 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'platform_tools')
-rwxr-xr-xplatform_tools/android/bin/gyp_to_android.py226
-rw-r--r--platform_tools/android/gyp_gen/__init__.py0
-rw-r--r--platform_tools/android/gyp_gen/android_framework_gyp.py117
-rw-r--r--platform_tools/android/gyp_gen/generate_user_config.py102
-rw-r--r--platform_tools/android/gyp_gen/gypd_parser.py153
-rw-r--r--platform_tools/android/gyp_gen/makefile_writer.py306
-rw-r--r--platform_tools/android/gyp_gen/tool_makefile_writer.py111
-rw-r--r--platform_tools/android/gyp_gen/vars_dict_lib.py166
8 files changed, 0 insertions, 1181 deletions
diff --git a/platform_tools/android/bin/gyp_to_android.py b/platform_tools/android/bin/gyp_to_android.py
deleted file mode 100755
index 72ec3c0550..0000000000
--- a/platform_tools/android/bin/gyp_to_android.py
+++ /dev/null
@@ -1,226 +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.
-
-"""
-Script for generating the Android framework's version of Skia from gyp
-files.
-"""
-
-import argparse
-import os
-import shutil
-import sys
-import tempfile
-
-# Find the top of trunk
-SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
-SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir,
- os.pardir))
-
-# Find the directory with our helper files, and add it to the path.
-ANDROID_TOOLS = os.path.join(SKIA_DIR, 'platform_tools', 'android')
-sys.path.append(ANDROID_TOOLS)
-
-import gyp_gen.android_framework_gyp as android_framework_gyp
-import gyp_gen.gypd_parser as gypd_parser
-import gyp_gen.generate_user_config as generate_user_config
-import gyp_gen.makefile_writer as makefile_writer
-import gyp_gen.tool_makefile_writer as tool_makefile_writer
-import gyp_gen.vars_dict_lib as vars_dict_lib
-
-# Folder containing all gyp files and generated gypd files.
-GYP_FOLDER = 'gyp'
-
-
-def generate_var_dict(target_dir, target_file, skia_arch_type, have_neon,
- have_mips_dspr2, have_mips_dspr1, gyp_source_dir):
- """Create a VarsDict for a particular arch type.
-
- Each paramater is passed directly to android_framework_gyp.main().
-
- Args:
- target_dir: Directory containing gyp files.
- target_file: Target gyp file.
- skia_arch_type: Target architecture.
- have_neon: Whether the target should build for neon.
- have_mips_dspr2: Whether the target should build for mips_dspr2.
- have_mips_dspr1: Whether the target should build for mips_dspr1.
- gyp_source_dir: Directory for gyp source.
- Returns:
- A VarsDict containing the variable definitions determined by gyp.
- """
- result_file = android_framework_gyp.main(target_dir, target_file,
- skia_arch_type, have_neon,
- have_mips_dspr2, have_mips_dspr1,
- gyp_source_dir)
- var_dict = vars_dict_lib.VarsDict()
- gypd_parser.parse_gypd(var_dict, result_file, '.')
- android_framework_gyp.clean_gypd_files(target_dir)
- print '.',
- return var_dict
-
-def main(target_dir=None, require_sk_user_config=False, gyp_source_dir=None):
- """Create Android.mk for the Android framework's external/skia.
-
- Builds Android.mk using Skia's gyp files.
-
- Args:
- target_dir: Directory in which to place 'Android.mk'. If None, the file
- will be placed in skia's root directory.
- require_sk_user_config: If True, raise an AssertionError if
- SkUserConfig.h does not exist.
- gyp_source_dir: Source directory for gyp.
- """
- # Create a temporary folder to hold gyp and gypd files. Create it in SKIA_DIR
- # so that it is a sibling of gyp/, so the relationships between gyp files and
- # other files (e.g. platform_tools/android/gyp/dependencies.gypi, referenced
- # by android_deps.gyp as a relative path) is unchanged.
- # Use mkdtemp to find an unused folder name, but then delete it so copytree
- # can be called with a non-existent directory.
- tmp_folder = tempfile.mkdtemp(dir=SKIA_DIR)
- os.rmdir(tmp_folder)
- shutil.copytree(os.path.join(SKIA_DIR, GYP_FOLDER), tmp_folder)
-
- try:
- main_gyp_file = 'android_framework_lib.gyp'
-
- print 'Creating Android.mk',
-
- # Generate a separate VarsDict for each architecture type. For each
- # archtype:
- # 1. call android_framework_gyp.main() to generate gypd files
- # 2. call parse_gypd to read those gypd files into the VarsDict
- # 3. delete the gypd files
- #
- # Once we have the VarsDict for each architecture type, we combine them all
- # into a single Android.mk file, which can build targets of any
- # architecture type.
-
- # The default uses a non-existant archtype, to find all the general
- # variable definitions.
- default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other',
- False, False, False, gyp_source_dir)
- arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False,
- False, False, gyp_source_dir)
- arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm',
- True, False, False, gyp_source_dir)
- x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False,
- False, False, gyp_source_dir)
- x86_64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86_64',
- False, False, False, gyp_source_dir)
-
- mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False,
- False, False, gyp_source_dir)
-
- mips_dspr2_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips',
- False, True, False, gyp_source_dir)
-
- mips_dspr1_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips',
- False, False, True, gyp_source_dir)
-
- mips64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips64',
- False, False, False, gyp_source_dir)
-
- arm64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm64',
- False, False, False, gyp_source_dir)
-
- # 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,
- x86_var_dict, x86_64_var_dict, mips_var_dict,
- mips_dspr1_var_dict, mips_dspr2_var_dict, mips64_var_dict,
- arm64_var_dict]
- common = vars_dict_lib.intersect(var_dict_list)
-
- common.LOCAL_MODULE.add('libskia')
-
- # Create SkUserConfig
- user_config = os.path.join(SKIA_DIR, 'include', 'config', 'SkUserConfig.h')
- if target_dir:
- dst_dir = target_dir
- else:
- dst_dir = os.path.join(SKIA_DIR, 'include', 'core')
-
- generate_user_config.generate_user_config(
- original_sk_user_config=user_config,
- require_sk_user_config=require_sk_user_config, target_dir=dst_dir,
- defines=common.DEFINES)
-
- tool_makefile_writer.generate_tool(gyp_dir=tmp_folder,
- target_file='bench.gyp',
- skia_trunk=target_dir,
- dest_dir='bench',
- skia_lib_var_dict=common,
- local_module_name='skia_nanobench',
- local_module_tags=['tests'],
- desired_targets=['nanobench'],
- gyp_source_dir=gyp_source_dir)
-
- tool_makefile_writer.generate_tool(gyp_dir=tmp_folder,
- target_file='dm.gyp',
- skia_trunk=target_dir,
- dest_dir='dm',
- skia_lib_var_dict=common,
- local_module_name='skia_dm',
- local_module_tags=['tests'],
- desired_targets=['dm'],
- gyp_source_dir=gyp_source_dir)
-
- # Now that the defines have been written to SkUserConfig and they've been
- # used to skip adding them to the tools makefiles, they are not needed in
- # Android.mk. Reset DEFINES.
- common.DEFINES.reset()
-
- # Further trim arm_neon_var_dict with arm_var_dict. After this call,
- # arm_var_dict (which will now be the intersection) includes all definitions
- # used by both arm and arm + neon, and arm_neon_var_dict will only contain
- # 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'))
- deviations_from_common.append(makefile_writer.VarsDictData(x86_64_var_dict,
- 'x86_64'))
-
- deviations_from_common.append(makefile_writer.VarsDictData(
- mips_dspr2_var_dict, 'mips', 'mips32r2dspr2-fp'))
-
- deviations_from_common.append(makefile_writer.VarsDictData(
- mips_dspr1_var_dict, 'mips', 'mips32r2dsp-fp'))
-
- deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict,
- 'mips'))
-
- deviations_from_common.append(makefile_writer.VarsDictData(mips64_var_dict,
- 'mips64'))
-
- deviations_from_common.append(makefile_writer.VarsDictData(arm64_var_dict,
- 'arm64'))
-
- makefile_writer.write_android_mk(target_dir=target_dir,
- common=common, deviations_from_common=deviations_from_common)
-
- makefile_writer.write_static_deps_mk(target_dir=target_dir,
- common=common, deviations_from_common=deviations_from_common)
-
- finally:
- shutil.rmtree(tmp_folder)
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('--gyp_source_dir', help='Source of gyp program. '
- 'e.g. <path_to_skia>/third_party/externals/gyp')
- args = parser.parse_args()
-
- main(gyp_source_dir=args.gyp_source_dir)
diff --git a/platform_tools/android/gyp_gen/__init__.py b/platform_tools/android/gyp_gen/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/platform_tools/android/gyp_gen/__init__.py
+++ /dev/null
diff --git a/platform_tools/android/gyp_gen/android_framework_gyp.py b/platform_tools/android/gyp_gen/android_framework_gyp.py
deleted file mode 100644
index 3d0536b8c2..0000000000
--- a/platform_tools/android/gyp_gen/android_framework_gyp.py
+++ /dev/null
@@ -1,117 +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.
-
-"""
-Modified version of gyp_skia, used by gyp_to_android.py to generate Android.mk
-"""
-
-import os
-import sys
-
-SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
-
-# Unlike gyp_skia, this file is nested deep inside Skia. Find Skia's trunk dir.
-# This line depends on the fact that the script is three levels deep
-# (specifically, it is in platform_tools/android/gyp_gen).
-SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir,
- os.pardir))
-DIR_CONTENTS = os.listdir(SKIA_DIR)
-assert 'gyp' in DIR_CONTENTS
-
-DEBUG_FAILURE = True
-
-def main(target_dir, target_file, skia_arch_type, have_neon,
- have_mips_dspr2, have_mips_dspr1, gyp_source_dir=None):
- """Create gypd files based on target_file.
-
- Args:
- target_dir: Directory containing all gyp files, including common.gypi
- target_file: Gyp file to start on. Other files within target_dir will
- be read if target_file depends on them.
- skia_arch_type: Target architecture to pass to gyp.
- have_neon: Whether to generate files including neon optimizations.
- Only meaningful if skia_arch_type is 'arm'.
- gyp_source_dir: Directory of the gyp source code. The default is in
- third_party/externals/gyp.
-
- Returns:
- path: Path to root gypd file created by running gyp.
- """
- # Ensure we import our current gyp source's module, not any version
- # pre-installed in your PYTHONPATH.
- if not gyp_source_dir:
- if DEBUG_FAILURE:
- print 'gyp_source_dir not provided. using the default!'
- gyp_source_dir = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp')
-
- if DEBUG_FAILURE:
- print 'gyp_source_dir is "%s"' % gyp_source_dir
- if not os.path.exists(gyp_source_dir):
- print 'and it does not exist!'
-
- assert os.path.exists(gyp_source_dir)
-
- sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib'))
-
- import gyp
-
- # Set GYP_DEFINES for building for the android framework.
- gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s '
- % skia_arch_type)
- if skia_arch_type == 'arm':
- # Always version 7 (which implies thumb) for arm
- gyp_defines += 'arm_version=7 '
- if have_neon:
- gyp_defines += 'arm_neon=1 '
- else:
- gyp_defines += 'arm_neon=0 '
-
- if skia_arch_type == 'mips':
- if have_mips_dspr2:
- gyp_defines += 'mips_arch_variant=mips32r2 '
- gyp_defines += 'mips_dsp=2 '
- elif have_mips_dspr1:
- gyp_defines += 'mips_arch_variant=mips32r2 '
- gyp_defines += 'mips_dsp=1 '
-
- os.environ['GYP_DEFINES'] = gyp_defines
-
- args = []
- args.extend(['--depth', '.'])
- full_path = os.path.join(target_dir, target_file)
- args.extend([full_path])
- # Common conditions
- args.extend(['-I', os.path.join(target_dir, 'common.gypi')])
- # Use the debugging format. We'll use these to create one master make file.
- args.extend(['-f', 'gypd'])
-
- # Off we go...
- ret = gyp.main(args)
-
- if ret != 0:
- raise Exception("gyp failed!")
-
- # Running gyp should have created a gypd file, with the same name as
- # full_path but with a 'd' on the end.
- gypd_file = full_path + 'd'
- if not os.path.exists(gypd_file):
- raise Exception("gyp failed to produce gypd file!")
-
- return gypd_file
-
-
-def clean_gypd_files(folder):
- """Remove the gypd files generated by main().
-
- Args:
- folder: Folder in which to delete all files ending with 'gypd'.
- """
- assert os.path.isdir(folder)
- files = os.listdir(folder)
- for f in files:
- if f.endswith('gypd'):
- os.remove(os.path.join(folder, f))
diff --git a/platform_tools/android/gyp_gen/generate_user_config.py b/platform_tools/android/gyp_gen/generate_user_config.py
deleted file mode 100644
index 6858d9372f..0000000000
--- a/platform_tools/android/gyp_gen/generate_user_config.py
+++ /dev/null
@@ -1,102 +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.
-
-"""Function for generating the SkUserConfig file, customized for Android."""
-
-import os
-import shutil
-
-
-AUTOGEN_WARNING = (
-"""
-///////////////////////////////////////////////////////////////////////////////
-//
-// THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT.
-//
-// This file contains Skia's upstream include/config/SkUserConfig.h as a
-// reference, followed by the actual defines set for Android.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-"""
-)
-
-BUILD_GUARD = 'SkUserConfig_Android_DEFINED'
-
-
-def generate_user_config(original_sk_user_config, require_sk_user_config,
- target_dir, defines):
- """Generate the SkUserConfig file specific to the Android framework.
-
- Android needs its #defines in its skia/include/core directory, so that other
- libraries which use Skia's headers get the right definitions. This function
- takes the existing sample version of SkUserConfig, checked into Skia, and
- appends the defines from ordered_set, which is expected to be a
- vars_dict_lib.OrderedSet containing the defines. The result is written to
- target_dir/SkUserConfig.h
-
- Args:
- original_sk_user_config: Path to original SkUserConfig.h
- require_sk_user_config: If True, raise an AssertionError if
- SkUserConfig.h does not exist. Either way, if it does exist, copy it
- into the new file.
- target_dir: Directory within which the modified SkUserConfig.h will be
- written. Its name will be the same basename as
- original_sk_user_config. If None, the new file will be written to the
- working directory.
- defines: Iterable of defines to be appended to SkUserConfig.
-
- Raises:
- AssertionError: If original_sk_user_config does not exist.
- """
-
- sk_user_config_exists = os.path.exists(original_sk_user_config)
- if require_sk_user_config:
- assert sk_user_config_exists
-
- dst_filename = os.path.basename(original_sk_user_config)
- if target_dir:
- dst_filename = os.path.join(target_dir, dst_filename)
-
- with open(dst_filename, 'w') as dst:
- dst.write(AUTOGEN_WARNING)
-
- # Copy the original exactly. This is merely for reference. Many of the
- # defines written to the file below, either manually or generated from the
- # gyp files, have explanations in the original SkUserConfig.h
- if sk_user_config_exists:
- with open(original_sk_user_config, 'r') as original:
- shutil.copyfileobj(original, dst)
-
- # Now add the defines specific to Android. Write a custom build guard to
- # ensure they don't get defined more than once.
- dst.write('\n// Android defines:\n')
- dst.write('#ifndef ' + BUILD_GUARD + '\n')
- dst.write('#define ' + BUILD_GUARD + '\n')
-
- # Add conditional defines manually:
-
- # do this build check for other tools that still read this header
- dst.write('#ifdef ANDROID\n')
- dst.write(' #include <utils/misc.h>\n')
- dst.write('#endif\n\n')
-
- dst.write('#if __BYTE_ORDER == __BIG_ENDIAN\n')
- dst.write(' #define SK_CPU_BENDIAN\n')
- dst.write(' #undef SK_CPU_LENDIAN\n')
- dst.write('#else\n')
- dst.write(' #define SK_CPU_LENDIAN\n')
- dst.write(' #undef SK_CPU_BENDIAN\n')
- dst.write('#endif\n\n')
-
- # Now add the defines from the gyp files.
- for item in sorted(defines):
- # Although our defines may have '=' in them, when written to the header
- # there should be a space between the macro and what it replaces.
- dst.write('#define ' + item.replace('=', ' ') + '\n')
-
- dst.write('\n#endif // ' + BUILD_GUARD + '\n')
diff --git a/platform_tools/android/gyp_gen/gypd_parser.py b/platform_tools/android/gyp_gen/gypd_parser.py
deleted file mode 100644
index 082d2645a4..0000000000
--- a/platform_tools/android/gyp_gen/gypd_parser.py
+++ /dev/null
@@ -1,153 +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.
-
-"""Functions for parsing the gypd output from gyp.
-"""
-
-
-import os
-
-
-def parse_dictionary(var_dict, d, current_target_name, dest_dir):
- """Helper function to get the meaningful entries in a dictionary.
-
- Parse dictionary d, and store unique relevant entries in var_dict.
- Recursively parses internal dictionaries and files that are referenced.
- When parsing the 'libraries' list from gyp, entries in the form
- '-l<name>' get assigned to var_dict.LOCAL_SHARED_LIBRARIES as 'lib<name>',
- and entries in the form '[lib]<name>.a' get assigned to
- var_dict.LOCAL_STATIC_LIBRARIES as 'lib<name>'.
-
- Args:
- var_dict: VarsDict object for storing the results of the parsing.
- d: Dictionary object to parse.
- current_target_name: The current target being parsed. If this dictionary
- is a target, this will be its entry 'target_name'. Otherwise, this will
- be the name of the target which contains this dictionary.
- dest_dir: Destination for the eventual Android.mk that will be created from
- this parse, relative to Skia trunk. Used to determine path for source
- files.
- """
- for source in d.get('sources', []):
- # Compare against a lowercase version, in case files are named .H or .GYPI
- lowercase_source = source.lower()
- if lowercase_source.endswith('.h'):
- # Android.mk does not need the header files.
- continue
- if lowercase_source.endswith('gypi'):
- # The gypi files are included in sources, but the sources they included
- # are also included. No need to parse them again.
- continue
- # The path is relative to the gyp folder, but Android wants the path
- # relative to dest_dir.
- rel_source = os.path.relpath(source, os.pardir)
- rel_source = os.path.relpath(rel_source, dest_dir)
- var_dict.LOCAL_SRC_FILES.add(rel_source)
-
- for lib in d.get('libraries', []):
- if lib.endswith('.a'):
- # Remove the '.a'
- lib = lib[:-2]
- # Add 'lib', if necessary
- if not lib.startswith('lib'):
- lib = 'lib' + lib
- var_dict.LOCAL_STATIC_LIBRARIES.add(lib)
- else:
- # lib will be in the form of '-l<name>'. Change it to 'lib<name>'
- lib = lib.replace('-l', 'lib', 1)
- var_dict.LOCAL_SHARED_LIBRARIES.add(lib)
-
- for dependency in d.get('dependencies', []):
- # Each dependency is listed as
- # <path_to_file>:<target>#target
- li = dependency.split(':')
- assert(len(li) <= 2 and len(li) >= 1)
- sub_targets = []
- if len(li) == 2 and li[1] != '*':
- sub_targets.append(li[1].split('#')[0])
- sub_path = li[0]
- assert(sub_path.endswith('.gyp'))
- # Although the original reference is to a .gyp, parse the corresponding
- # gypd file, which was constructed by gyp.
- sub_path = sub_path + 'd'
- parse_gypd(var_dict, sub_path, dest_dir, sub_targets)
-
- if 'default_configuration' in d:
- config_name = d['default_configuration']
- # default_configuration is meaningless without configurations
- assert('configurations' in d)
- config = d['configurations'][config_name]
- parse_dictionary(var_dict, config, current_target_name, dest_dir)
-
- for flag in d.get('cflags', []):
- var_dict.LOCAL_CFLAGS.add(flag)
- for flag in d.get('cflags_cc', []):
- var_dict.LOCAL_CPPFLAGS.add(flag)
-
- for include in d.get('include_dirs', []):
- if include.startswith('external') or include.startswith('frameworks'):
- # This path is relative to the Android root. Leave it alone.
- rel_include = include
- else:
- # As with source, the input path will be relative to gyp/, but Android
- # wants relative to dest_dir.
- rel_include = os.path.relpath(include, os.pardir)
- rel_include = os.path.relpath(rel_include, dest_dir)
- # No need to include the base directory.
- if rel_include is os.curdir:
- continue
- rel_include = os.path.join('$(LOCAL_PATH)', rel_include)
-
- # Remove a trailing slash, if present.
- if rel_include.endswith('/'):
- rel_include = rel_include[:-1]
- var_dict.LOCAL_C_INCLUDES.add(rel_include)
- # For the top level, libskia, include directories should be exported.
- # FIXME (scroggo): Do not hard code this.
- if current_target_name == 'libskia':
- var_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add(rel_include)
-
- for define in d.get('defines', []):
- var_dict.DEFINES.add(define)
-
-
-def parse_gypd(var_dict, path, dest_dir, desired_targets=None):
- """Parse a gypd file.
-
- Open a file that consists of python dictionaries representing build targets.
- Parse those dictionaries using parse_dictionary. Recursively parses
- referenced files.
-
- Args:
- var_dict: VarsDict object for storing the result of the parse.
- path: Path to gypd file.
- dest_dir: Destination for the eventual Android.mk that will be created from
- this parse, relative to Skia trunk. Used to determine path for source
- files and include directories.
- desired_targets: List of targets to be parsed from this file. If empty,
- parse all targets.
- """
- d = {}
- with open(path, 'r') as f:
- # Read the entire file as a dictionary
- d = eval(f.read())
-
- # The gypd file is structured such that the top level dictionary has an entry
- # named 'targets'
- for target in d['targets']:
- target_name = target['target_name']
- if target_name in var_dict.KNOWN_TARGETS:
- # Avoid circular dependencies
- continue
- if desired_targets and target_name not in desired_targets:
- # Our caller does not depend on this one
- continue
- # Add it to our known targets so we don't parse it again
- var_dict.KNOWN_TARGETS.add(target_name)
-
- parse_dictionary(var_dict, target, target_name, dest_dir)
-
diff --git a/platform_tools/android/gyp_gen/makefile_writer.py b/platform_tools/android/gyp_gen/makefile_writer.py
deleted file mode 100644
index e60ce5b044..0000000000
--- a/platform_tools/android/gyp_gen/makefile_writer.py
+++ /dev/null
@@ -1,306 +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.
-
-"""
-Functions for creating an Android.mk from already created dictionaries.
-"""
-
-import os
-
-def write_group(f, name, items, append):
- """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):
- """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():
- _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
- 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
- write_group(f, _key, _items, _append)
-
-
-AUTOGEN_WARNING = (
-"""
-###############################################################################
-#
-# THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT.
-#
-# For bugs, please contact scroggo@google.com or djsollen@google.com
-#
-###############################################################################
-
-"""
-)
-
-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 (except in the PDK build)
-#
-ifneq ($(TARGET_BUILD_PDK),true)
-
-# benchmark (timings)
-include $(BASE_PATH)/bench/Android.mk
-
-# diamond-master (one test to rule them all)
-include $(BASE_PATH)/dm/Android.mk
-
-endif # disable for PDK
-"""
-)
-
-STATIC_HEADER = (
-"""
-###############################################################################
-# STATIC LIBRARY
-#
-# This target is only to be used internally for only one of two purposes...
-# (1) statically linking into testing frameworks
-# (2) as an inclusion target for the libskia.so shared library
-###############################################################################
-
-"""
-)
-
-SHARED_HEADER = (
-"""
-###############################################################################
-# SHARED LIBRARY
-###############################################################################
-
-"""
-)
-
-STATIC_DEPS_INFO = (
-"""
-###############################################################################
-#
-# This file contains the shared and static dependencies needed by any target
-# that attempts to statically link Skia (i.e. libskia_static build target).
-#
-# This is a workaround for the fact that the build system does not add these
-# transitive dependencies when it attempts to link libskia_static into another
-# library.
-#
-###############################################################################
-"""
-)
-
-CLEAR_VARS = ("""include $(CLEAR_VARS)\n""")
-LOCAL_PATH = ("""LOCAL_PATH:= $(call my-dir)\n""")
-
-class VarsDictData(object):
- """Helper class to keep a VarsDict along with a name and optional condition.
- """
- def __init__(self, vars_dict, name, condition=None):
- """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
-
-def write_static_deps_mk(target_dir, common, deviations_from_common):
- """Given all the variables, write the final make file.
-
- Args:
- target_dir: The full path to the directory to write skia_static_includes.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 = 'skia_static_deps.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(STATIC_DEPS_INFO)
-
- for data in deviations_from_common:
- var_dict_shared = data.vars_dict['LOCAL_SHARED_LIBRARIES']
- var_dict_static = data.vars_dict['LOCAL_STATIC_LIBRARIES']
- if data.condition and (var_dict_shared or var_dict_static):
- f.write('ifeq ($(%s), true)\n' % data.condition)
- write_group(f, 'LOCAL_SHARED_LIBRARIES', var_dict_shared, True)
- write_group(f, 'LOCAL_STATIC_LIBRARIES', var_dict_static, True)
- if data.condition and (var_dict_shared or var_dict_static):
- f.write('endif\n\n')
-
- write_group(f, 'LOCAL_SHARED_LIBRARIES', common['LOCAL_SHARED_LIBRARIES'],
- True)
- write_group(f, 'LOCAL_STATIC_LIBRARIES', common['LOCAL_STATIC_LIBRARIES'],
- True)
-
-
-def write_android_mk(target_dir, common, deviations_from_common):
- """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')
- f.write(LOCAL_PATH)
-
- f.write(DEBUGGING_HELP)
-
- f.write(STATIC_HEADER)
- f.write(CLEAR_VARS)
-
- # need flags to enable feedback driven optimization (FDO) when requested
- # by the build system.
- f.write('LOCAL_FDO_SUPPORT := true\n')
- f.write('ifneq ($(strip $(TARGET_FDO_CFLAGS)),)\n')
- f.write('\t# This should be the last -Oxxx specified in LOCAL_CFLAGS\n')
- f.write('\tLOCAL_CFLAGS += -O2\n')
- f.write('endif\n\n')
-
- f.write('LOCAL_ARM_MODE := thumb\n')
-
- f.write('# used for testing\n')
- f.write('#LOCAL_CFLAGS += -g -O0\n\n')
-
- # update the provided LOCAL_MODULE with a _static suffix
- local_module = common['LOCAL_MODULE'][0]
- static_local_module = local_module + '_static'
- common['LOCAL_MODULE'].reset()
- common['LOCAL_MODULE'].add(static_local_module)
-
- write_local_vars(f, common, False, None)
-
- for data in deviations_from_common:
- if data.name == 'mips':
- if data.condition =='mips32r2dspr2-fp' :
- f.write('ifeq ($(TARGET_ARCH_VARIANT), %s)\n' % (data.condition))
- write_local_vars(f, data.vars_dict, True, data.name)
- elif data.condition =='mips32r2dsp-fp' :
- f.write('else ifeq ($(TARGET_ARCH_VARIANT), %s)\n' % (data.condition))
- write_local_vars(f, data.vars_dict, True, data.name)
- else :
- f.write('else\n')
- write_local_vars(f, data.vars_dict, True, data.name)
- f.write('endif\n\n')
- else :
- 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('LOCAL_MODULE_CLASS := STATIC_LIBRARIES\n')
- f.write('include $(BUILD_STATIC_LIBRARY)\n\n')
-
- f.write(SHARED_HEADER)
- f.write(CLEAR_VARS)
- f.write('LOCAL_MODULE_CLASS := SHARED_LIBRARIES\n')
- f.write('LOCAL_MODULE := %s\n' % local_module)
- f.write('LOCAL_WHOLE_STATIC_LIBRARIES := %s\n' % static_local_module)
- write_group(f, 'LOCAL_EXPORT_C_INCLUDE_DIRS',
- common['LOCAL_EXPORT_C_INCLUDE_DIRS'], False)
- f.write('include $(BASE_PATH)/skia_static_deps.mk\n')
- f.write('include $(BUILD_SHARED_LIBRARY)\n')
-
- f.write(SKIA_TOOLS)
-
diff --git a/platform_tools/android/gyp_gen/tool_makefile_writer.py b/platform_tools/android/gyp_gen/tool_makefile_writer.py
deleted file mode 100644
index a6f2aee9f8..0000000000
--- a/platform_tools/android/gyp_gen/tool_makefile_writer.py
+++ /dev/null
@@ -1,111 +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.
-
-"""Code for generating Android.mk for a tool."""
-
-
-import android_framework_gyp
-import gypd_parser
-import makefile_writer
-import os
-import vars_dict_lib
-
-SKIA_RESOURCES = (
-"""
-# Store skia's resources in the directory structure that the Android testing
-# infrastructure expects. This requires that Skia maintain a symlinked
-# subdirectory in the DATA folder that points to the top level skia resources...
-# i.e. external/skia/DATA/skia_resources --> ../resources
-LOCAL_PICKUP_FILES := $(LOCAL_PATH)/../DATA
-"""
-)
-
-def write_tool_android_mk(target_dir, var_dict):
- """Write Android.mk for a Skia tool.
-
- Args:
- target_dir: Destination for the makefile. Must not be None.
- var_dict: VarsDict containing variables for the makefile.
- """
- target_file = os.path.join(target_dir, 'Android.mk')
- with open(target_file, 'w') as f:
- f.write(makefile_writer.AUTOGEN_WARNING)
-
- f.write(makefile_writer.LOCAL_PATH)
- f.write(makefile_writer.CLEAR_VARS)
-
- makefile_writer.write_local_vars(f, var_dict, False, None)
-
- f.write(SKIA_RESOURCES)
- f.write('include $(LOCAL_PATH)/../skia_static_deps.mk\n')
- if 'libhwui_static' in var_dict['LOCAL_STATIC_LIBRARIES']:
- f.write('include frameworks/base/libs/hwui/hwui_static_deps.mk\n')
- f.write('include $(BUILD_NATIVE_TEST)\n')
-
-
-def generate_tool(gyp_dir, target_file, skia_trunk, dest_dir,
- skia_lib_var_dict, local_module_name, local_module_tags,
- desired_targets, gyp_source_dir=None):
- """Common steps for building one of the skia tools.
-
- Parse a gyp file and create an Android.mk for this tool.
-
- Args:
- gyp_dir: Directory containing gyp files.
- target_file: gyp file for the project to be built, contained in gyp_dir.
- skia_trunk: Trunk of Skia, used for determining the destination to write
- 'Android.mk'.
- dest_dir: Destination for 'Android.mk', relative to skia_trunk. Used for
- both writing relative paths in the makefile and for determining the
- destination to write the it.
- skia_lib_var_dict: VarsDict representing libskia. Used as a reference to
- ensure we do not duplicate anything in this Android.mk.
- local_module_name: Name for this tool, to set as LOCAL_MODULE.
- local_module_tags: Tags to pass to LOCAL_MODULE_TAG.
- desired_targets: List of targets to parse.
- gyp_source_dir: Source directory for gyp.
- """
- result_file = android_framework_gyp.main(target_dir=gyp_dir,
- target_file=target_file,
- skia_arch_type='other',
- have_neon=False,
- have_mips_dspr2=False,
- have_mips_dspr1=False,
- gyp_source_dir=gyp_source_dir)
-
- var_dict = vars_dict_lib.VarsDict()
-
- # Add known targets from skia_lib, so we do not reparse them.
- var_dict.KNOWN_TARGETS.set(skia_lib_var_dict.KNOWN_TARGETS)
-
- gypd_parser.parse_gypd(var_dict, result_file, dest_dir, desired_targets)
-
- android_framework_gyp.clean_gypd_files(gyp_dir)
-
- var_dict.LOCAL_MODULE.add(local_module_name)
- for tag in local_module_tags:
- var_dict.LOCAL_MODULE_TAGS.add(tag)
-
- # No need for defines that are already in skia_lib.
- for define in skia_lib_var_dict.DEFINES:
- try:
- var_dict.DEFINES.remove(define)
- except ValueError:
- # Okay if the define was not part of the parse for our tool.
- pass
-
- if skia_trunk:
- full_dest = os.path.join(skia_trunk, dest_dir)
- else:
- full_dest = dest_dir
-
- # If the path does not exist, create it. This will happen during testing,
- # where there is no subdirectory for each tool (just a temporary folder).
- if not os.path.exists(full_dest):
- os.mkdir(full_dest)
-
- write_tool_android_mk(target_dir=full_dest, var_dict=var_dict)
diff --git a/platform_tools/android/gyp_gen/vars_dict_lib.py b/platform_tools/android/gyp_gen/vars_dict_lib.py
deleted file mode 100644
index 6be2402a04..0000000000
--- a/platform_tools/android/gyp_gen/vars_dict_lib.py
+++ /dev/null
@@ -1,166 +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.
-
-import collections
-import types
-
-# The goal of this class is to store a set of unique items in the order in
-# which they are inserted. This is important for the final makefile, where
-# we want to make sure the image decoders are in a particular order. See
-# images.gyp for more information.
-class OrderedSet(object):
- """Ordered set of unique items that supports addition and removal.
-
- Retains the order in which items are inserted.
- """
-
- def __init__(self):
- self.__ordered_set = []
-
- def add(self, item):
- """Add item, if it is not already in the set.
-
- item is appended to the end if it is not already in the set.
-
- Args:
- item: The item to add.
- """
- if item not in self.__ordered_set:
- self.__ordered_set.append(item)
-
- def __contains__(self, item):
- """Whether the set contains item.
-
- Args:
- item: The item to search for in the set.
-
- Returns:
- bool: Whether the item is in the set.
- """
- return item in self.__ordered_set
-
- def __iter__(self):
- """Iterator for the set.
- """
- return self.__ordered_set.__iter__()
-
- def remove(self, item):
- """
- Remove item from the set.
-
- Args:
- item: Item to be removed.
-
- Raises:
- ValueError if item is not in the set.
- """
- self.__ordered_set.remove(item)
-
- def __len__(self):
- """Number of items in the set.
- """
- return len(self.__ordered_set)
-
- def __getitem__(self, index):
- """Return item at index.
- """
- return self.__ordered_set[index]
-
- def reset(self):
- """Reset to empty.
- """
- self.__ordered_set = []
-
- def set(self, other):
- """Replace this ordered set with another.
-
- Args:
- other: OrderedSet to replace this one. After this call, this OrderedSet
- will contain exactly the same elements as other.
- """
- self.__ordered_set = list(other.__ordered_set)
-
-VAR_NAMES = ['LOCAL_CFLAGS',
- 'LOCAL_CPPFLAGS',
- 'LOCAL_SRC_FILES',
- 'LOCAL_SHARED_LIBRARIES',
- 'LOCAL_STATIC_LIBRARIES',
- 'LOCAL_C_INCLUDES',
- 'LOCAL_EXPORT_C_INCLUDE_DIRS',
- 'DEFINES',
- 'KNOWN_TARGETS',
- # These are not parsed by gyp, but set manually.
- 'LOCAL_MODULE_TAGS',
- 'LOCAL_MODULE']
-
-class VarsDict(collections.namedtuple('VarsDict', VAR_NAMES)):
- """Custom class for storing the arguments to Android.mk variables.
-
- Can also be treated as a dictionary with fixed keys.
- """
-
- __slots__ = ()
-
- def __new__(cls):
- lists = []
- # TODO (scroggo): Is there a better way add N items?
- for __unused__ in range(len(VAR_NAMES)):
- lists.append(OrderedSet())
- return tuple.__new__(cls, lists)
-
- def keys(self):
- """Return the field names as strings.
- """
- return self._fields
-
- def __getitem__(self, index):
- """Return an item, indexed by a number or a string.
- """
- if type(index) == types.IntType:
- # Treat the index as an array index into a tuple.
- return tuple.__getitem__(self, index)
- if type(index) == types.StringType:
- # Treat the index as a key into a dictionary.
- return eval('self.%s' % index)
- return None
-
-
-def intersect(var_dict_list):
- """Compute intersection of VarsDicts.
-
- Find the intersection of a list of VarsDicts and trim each input to its
- unique entries.
-
- Args:
- var_dict_list: list of VarsDicts. WARNING: each VarsDict will be
- modified in place, to remove the common elements!
- Returns:
- VarsDict containing list entries common to all VarsDicts in
- var_dict_list
- """
- intersection = VarsDict()
- # First VarsDict
- var_dict_a = var_dict_list[0]
- # The rest.
- other_var_dicts = var_dict_list[1:]
-
- for key in var_dict_a.keys():
- # Copy A's list, so we can continue iterating after modifying the original.
- a_list = list(var_dict_a[key])
- for item in a_list:
- # If item is in all lists, add to intersection, and remove from all.
- in_all_lists = True
- for var_dict in other_var_dicts:
- if not item in var_dict[key]:
- in_all_lists = False
- break
- if in_all_lists:
- intersection[key].add(item)
- for var_dict in var_dict_list:
- var_dict[key].remove(item)
- return intersection
-