aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/gyp_gen
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-21 14:45:01 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-21 14:45:01 +0000
commitec68ee9d569907672fb3e57333b23096e4185799 (patch)
treea139c06e8525cbde289f8e2c7789f4767faa39e9 /platform_tools/android/gyp_gen
parent1d0b68c495a8a18e5e51115dd1ef5392a93eec2a (diff)
Allow running gyp_to_android without SkUserConfig.
The old code requires that include/config/SkUserConfig.h exists, to ensure that it gets copied into Android's include/core/SkUserConfig.h when we do a merge. However, if a developer wants to make changes and rerun the script, they should not have to recreate include/config/SkUserConfig.h just to rerun the script. By default, allow the original to not exist and just skip the copy. Update tests to pass. Also add tests to support this use case. Make gyp_to_android.py executable. R=robertphillips@google.com, halcanary@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/242203008 git-svn-id: http://skia.googlecode.com/svn/trunk@14273 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'platform_tools/android/gyp_gen')
-rw-r--r--platform_tools/android/gyp_gen/generate_user_config.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/platform_tools/android/gyp_gen/generate_user_config.py b/platform_tools/android/gyp_gen/generate_user_config.py
index 1fafc1d979..957c363f02 100644
--- a/platform_tools/android/gyp_gen/generate_user_config.py
+++ b/platform_tools/android/gyp_gen/generate_user_config.py
@@ -8,6 +8,7 @@
"""Function for generating the SkUserConfig file, customized for Android."""
import os
+import shutil
AUTOGEN_WARNING = (
@@ -27,7 +28,8 @@ AUTOGEN_WARNING = (
BUILD_GUARD = 'SkUserConfig_Android_DEFINED'
-def generate_user_config(original_sk_user_config, target_dir, ordered_set):
+def generate_user_config(original_sk_user_config, require_sk_user_config,
+ target_dir, ordered_set):
"""Generate the SkUserConfig file specific to the Android framework.
Android needs its #defines in its skia/include/core directory, so that other
@@ -39,6 +41,9 @@ def generate_user_config(original_sk_user_config, target_dir, ordered_set):
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
@@ -50,7 +55,9 @@ def generate_user_config(original_sk_user_config, target_dir, ordered_set):
AssertionError: If original_sk_user_config does not exist.
"""
- assert os.path.exists(original_sk_user_config)
+ 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:
@@ -62,9 +69,9 @@ def generate_user_config(original_sk_user_config, target_dir, ordered_set):
# 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
- with open(original_sk_user_config, 'r') as original:
- for line in original:
- dst.write(line)
+ 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.