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

Commit 2265a16

Browse files
Raphael Kubo da CostaOlli Syrjälä
authored andcommitted
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
1 parent 315fcf9 commit 2265a16

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

.DEPS.git

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,5 +797,17 @@ hooks = [
797797
'src/tools/.*\\.py',
798798
'name':
799799
'remove_stale_pyc_files'
800-
}
800+
},
801+
802+
# Custom Crosswalk hooks.
803+
{
804+
'action': [
805+
'python',
806+
'src/build/empty_google_play_services_lib.py'
807+
],
808+
'pattern':
809+
'.',
810+
'name':
811+
'empty_google_play_services_lib'
812+
}
801813
]

DEPS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,18 @@ hooks = [
723723
'src/tools/.*\\.py',
724724
'name':
725725
'remove_stale_pyc_files'
726+
},
727+
728+
# Custom Crosswalk hooks.
729+
{
730+
'action': [
731+
'python',
732+
'src/build/empty_google_play_services_lib.py'
733+
],
734+
'pattern':
735+
'.',
736+
'name':
737+
'empty_google_play_services_lib'
726738
}
727739
]
728740

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright (c) 2015 Intel Corporation. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
"""
8+
Create an empty google-play-services.jar inside src/third_party/android_tools.
9+
10+
https://chromium-review.googlesource.com/#/c/247861 has introduced a check in
11+
android_tools.gyp that makes the gyp configuration process fail if a certain
12+
file that is part of the Google Play Services library is not found.
13+
14+
Since installing that library involves manually accepting an EULA and it is not
15+
used in Crosswalk, we create an empty file with the name android_tools.gyp
16+
checks for so that the build configuration proceeds. If the user chooses to
17+
manually install the library, the empty file is just overwritten and nothing
18+
breaks. Additionally, we also create res/ and src/ so that src/build/java.gypi
19+
can call find(1) in those directories without failing.
20+
"""
21+
22+
import errno
23+
import os
24+
import sys
25+
26+
sys.path.append(os.path.join(os.path.dirname(__file__), 'android'))
27+
28+
from pylib.constants import ANDROID_SDK_ROOT
29+
30+
31+
def CreateDirectory(path):
32+
"""
33+
Creates |path| and all missing parent directories. Passing a directory that
34+
already exists does not cause an error.
35+
"""
36+
try:
37+
os.makedirs(path)
38+
except OSError, e:
39+
if e.errno == errno.EEXIST:
40+
pass
41+
42+
43+
def CreateFileIfMissing(path):
44+
"""
45+
Creates an empty file called |path| if it does not already exist.
46+
"""
47+
if os.path.isfile(path):
48+
return
49+
open(path, 'w').close()
50+
51+
52+
if __name__ == '__main__':
53+
# If ANDROID_SDK_ROOT does not exist, we can assume the android_tools
54+
# repository has not been checked out. Consequently, this is not an Android
55+
# build and we do not need to worry about the issue this script works around.
56+
if not os.path.isdir(ANDROID_SDK_ROOT):
57+
sys.exit(0)
58+
59+
google_play_lib_root = os.path.join(
60+
ANDROID_SDK_ROOT, 'extras', 'google', 'google_play_services', 'libproject',
61+
'google-play-services_lib')
62+
63+
CreateDirectory(os.path.join(google_play_lib_root, 'libs'))
64+
CreateDirectory(os.path.join(google_play_lib_root, 'res'))
65+
CreateDirectory(os.path.join(google_play_lib_root, 'src'))
66+
CreateFileIfMissing(os.path.join(google_play_lib_root, 'libs',
67+
'google-play-services.jar'))

0 commit comments

Comments
 (0)