Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Add script to create Google Play Services's directory structure.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rakuco authored and Olli Syrjälä committed Apr 27, 2015
1 parent 315fcf9 commit 2265a16
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .DEPS.git
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
12 changes: 12 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]

Expand Down
67 changes: 67 additions & 0 deletions build/empty_google_play_services_lib.py
Original file line number Diff line number Diff line change
@@ -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'))

0 comments on commit 2265a16

Please sign in to comment.