From 2265a16b1735d436baafecd27e1ef33a185ac423 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 20 Apr 2015 16:25:43 +0300 Subject: [PATCH] Add script to create Google Play Services's directory structure. This script was originally in the Crosswalk repository, but keeping it there means our Content Shell bots cannot access it and consequently break with M43. From the original Crosswalk commit (f4f6b75): Ever since M42, building Chromium (and consequently Crosswalk) for Android has required installing the Google Play Services library via the `android` tool first. However, doing so involves manually accepting an End User License Agreement (EULA), which makes things very difficult to automate and also breaks our checkout and configuration process for users who are building Crosswalk for the first time. Since that library is actually needed only by Chromium but not Crosswalk, we have been working around this requirement. When Crosswalk started tracking Chromium M42, we added a few changes to chormium-crosswalk. One of them was making gyp not fail if some directories created by the Google Play Services library were not present. This solution needs to be rethought for the upcoming M43, as there is now a build system check in the android_tools repository to fail if a certain file installed by that library is not found. The script being added by this change is the answer to this, and is being landed before M43 itself because it also works independently of it. If the android_tools repository is checked out, it tries to create the Google Play Services directories gyp looks for as well as an empty file with the name that the android_tools build system checks. This way, we get rid of the corresponding change in chromium-crosswalk and prepare for the upcoming change in android_tools. BUG=XWALK-3955 --- .DEPS.git | 14 +++++- DEPS | 12 +++++ build/empty_google_play_services_lib.py | 67 +++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 build/empty_google_play_services_lib.py diff --git a/.DEPS.git b/.DEPS.git index 89ce8b42762ae..da9068d84b18a 100644 --- a/.DEPS.git +++ b/.DEPS.git @@ -797,5 +797,17 @@ hooks = [ 'src/tools/.*\\.py', 'name': 'remove_stale_pyc_files' -} +}, + + # Custom Crosswalk hooks. + { + 'action': [ + 'python', + 'src/build/empty_google_play_services_lib.py' + ], + 'pattern': + '.', + 'name': + 'empty_google_play_services_lib' + } ] diff --git a/DEPS b/DEPS index 3735478bf5b85..cd66db64a5636 100644 --- a/DEPS +++ b/DEPS @@ -723,6 +723,18 @@ hooks = [ 'src/tools/.*\\.py', 'name': 'remove_stale_pyc_files' + }, + + # Custom Crosswalk hooks. + { + 'action': [ + 'python', + 'src/build/empty_google_play_services_lib.py' + ], + 'pattern': + '.', + 'name': + 'empty_google_play_services_lib' } ] diff --git a/build/empty_google_play_services_lib.py b/build/empty_google_play_services_lib.py new file mode 100755 index 0000000000000..bdbb239d63da9 --- /dev/null +++ b/build/empty_google_play_services_lib.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Copyright (c) 2015 Intel Corporation. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Create an empty google-play-services.jar inside src/third_party/android_tools. + +https://chromium-review.googlesource.com/#/c/247861 has introduced a check in +android_tools.gyp that makes the gyp configuration process fail if a certain +file that is part of the Google Play Services library is not found. + +Since installing that library involves manually accepting an EULA and it is not +used in Crosswalk, we create an empty file with the name android_tools.gyp +checks for so that the build configuration proceeds. If the user chooses to +manually install the library, the empty file is just overwritten and nothing +breaks. Additionally, we also create res/ and src/ so that src/build/java.gypi +can call find(1) in those directories without failing. +""" + +import errno +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), 'android')) + +from pylib.constants import ANDROID_SDK_ROOT + + +def CreateDirectory(path): + """ + Creates |path| and all missing parent directories. Passing a directory that + already exists does not cause an error. + """ + try: + os.makedirs(path) + except OSError, e: + if e.errno == errno.EEXIST: + pass + + +def CreateFileIfMissing(path): + """ + Creates an empty file called |path| if it does not already exist. + """ + if os.path.isfile(path): + return + open(path, 'w').close() + + +if __name__ == '__main__': + # If ANDROID_SDK_ROOT does not exist, we can assume the android_tools + # repository has not been checked out. Consequently, this is not an Android + # build and we do not need to worry about the issue this script works around. + if not os.path.isdir(ANDROID_SDK_ROOT): + sys.exit(0) + + google_play_lib_root = os.path.join( + ANDROID_SDK_ROOT, 'extras', 'google', 'google_play_services', 'libproject', + 'google-play-services_lib') + + CreateDirectory(os.path.join(google_play_lib_root, 'libs')) + CreateDirectory(os.path.join(google_play_lib_root, 'res')) + CreateDirectory(os.path.join(google_play_lib_root, 'src')) + CreateFileIfMissing(os.path.join(google_play_lib_root, 'libs', + 'google-play-services.jar'))