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

Unified Diff: platform_tools/android/bin/gyp_to_android.py

Issue 140503007: Scripts to generate Android.mk for framework Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix lint errors. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: platform_tools/android/bin/gyp_to_android.py
diff --git a/platform_tools/android/bin/gyp_to_android.py b/platform_tools/android/bin/gyp_to_android.py
new file mode 100644
index 0000000000000000000000000000000000000000..86aea520f970e4f14a594f33bc396987940fba37
--- /dev/null
+++ b/platform_tools/android/bin/gyp_to_android.py
@@ -0,0 +1,127 @@
+#!/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 android_framework_gyp
+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.
+GYP_GEN_DIR = os.path.join(SKIA_DIR, 'platform_tools', 'android', 'gyp_gen')
+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'
+
+def clean_gypd_files(folder):
+ """
+ Remove the gypd files generated by android_framework_gyp.main().
+ @param 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))
+
+def main(target_dir=None):
+ """
+ Read gyp files and create Android.mk for the Android framework's
+ external/skia.
+ @param target_dir Directory in which to place 'Android.mk'. If None, the file
+ will be placed in skia's root directory.
+ """
+ # 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'
+ main_gypd_file = os.path.join(tmp_folder, main_gyp_file + 'd')
+
+ print 'Creating Android.mk',
+
+ # Call the script to generate gypd files, first using a non-existant
epoger 2014/02/03 17:26:32 If the following writeup is accurate, I think it m
scroggo 2014/02/03 23:22:31 Done.
+ # archtype.
+ android_framework_gyp.main(tmp_folder, main_gyp_file, 'other', False)
epoger 2014/02/03 17:26:32 If my writeup above is true, maybe you could reduc
scroggo 2014/02/03 23:22:31 Done.
+ # And store its variables in the default dict
+ default_var_dict = vars_dict_lib.VarsDict()
+ gypd_parser.parse_gypd(default_var_dict, main_gypd_file)
+ clean_gypd_files(tmp_folder)
+
+ print '.',
+
+ # Now do the same for Arm. arm_var_dict will contain all the variable
+ # definitions needed to build with arm (meaning that it will share most
+ # with default_var_dict).
+ android_framework_gyp.main(tmp_folder, main_gyp_file, 'arm', False)
+ arm_var_dict = vars_dict_lib.VarsDict()
+ gypd_parser.parse_gypd(arm_var_dict, main_gypd_file)
+ clean_gypd_files(tmp_folder)
+
+ print '.',
+
+ # Now do the same for Arm/Neon.
+ android_framework_gyp.main(tmp_folder, main_gyp_file, 'arm', True)
+ arm_neon_var_dict = vars_dict_lib.VarsDict()
+ gypd_parser.parse_gypd(arm_neon_var_dict, main_gypd_file)
+ clean_gypd_files(tmp_folder)
+
+ print '.'
+
+ # Now do the same for x86.
+ x86_var_dict = vars_dict_lib.VarsDict()
+ if variables.INCLUDE_X86_OPTS:
+ android_framework_gyp.main(tmp_folder, main_gyp_file, 'x86', False)
+ gypd_parser.parse_gypd(x86_var_dict, main_gypd_file)
+ clean_gypd_files(tmp_folder)
+
+ # 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)
+ common = vars_dict_lib.intersect(var_dict_list)
+
+ # 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])
epoger 2014/02/03 17:26:32 So, after this call, does arm_neon_var_dict someho
scroggo 2014/02/03 23:22:31 Leaving as is, and adding a TODO in makefile_write
+
+ makefile_writer.write_android_mk(target_dir, common, arm_var_dict,
epoger 2014/02/03 17:26:32 please use named parameters makefile_writer.write
scroggo 2014/02/03 23:22:31 Done.
+ arm_neon_var_dict, x86_var_dict,
+ default_var_dict)
+
+ finally:
+ shutil.rmtree(tmp_folder)
+
+if __name__ == '__main__':
+ main()

Powered by Google App Engine
This is Rietveld 408576698