Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
3addac54
Commit
3addac54
authored
Feb 07, 2017
by
Michael Goderbauer
Committed by
GitHub
Feb 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Windows support for Android Tools (#7906)
Required to run tests on Windows bots.
parent
c32fa70d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
201 additions
and
4 deletions
+201
-4
README.md
dev/bots/README.md
+43
-0
VERSION_WIN_SDK
dev/bots/VERSION_WIN_SDK
+1
-0
download_android_tools.py
dev/bots/download_android_tools.py
+26
-4
upload_android_tools.py
dev/bots/upload_android_tools.py
+131
-0
No files found.
dev/bots/README.md
View file @
3addac54
...
...
@@ -87,3 +87,46 @@ Support for [cross-repository
recipes](https://github.com/luci/recipes-py/blob/master/doc/cross_repo.md) is
in-progress. If you view the git log of this directory, you'll see we initially
tried, but it's not quite ready.
# Android Tools
Instructions to update the Android Tools version that the bots download by executing
`download_android_tools.py`
.
## How to update Android SDK on Google Cloud Storage
1.
Run Android SDK Manager and update packages
`$ dev/bots/android_tools/sdk/tools/android update sdk`
Use
`android.bat`
on Windows.
2.
Choose/Update packages
The following packages are currently installed:
*
Android SDK Tools
*
Android SDK platform-tools
*
Android SDK Build-tools 23.0.1
*
Android 6.0 (API 23)
*
SDK Platform 23
*
Extras
*
Android Support Repository
*
Google Play services
3.
Run upload_android_tools.py -t sdk
`$ dev/bots/upload_android_tools.py -t sdk`
## How to update Android NDK on Google Cloud Storage
1.
Download a new NDK binary (e.g. android-ndk-r10e-linux-x86_64.bin)
2.
cd dev/bots/android_tools
`$ cd dev/bots/android_tools`
3.
Remove the old ndk directory
`$ rm -rf ndk`
4.
Run the new NDK binary file
`$ ./android-ndk-r10e-linux-x86_64.bin`
5.
Rename the extracted directory to ndk
`$ mv android-ndk-r10e ndk`
6.
Run upload_android_tools.py -t ndk
`$ cd ../..`
`$ dev/bots/upload_android_tools.py -t ndk`
dev/bots/VERSION_WIN_SDK
0 → 100644
View file @
3addac54
6177b9564dde9457e5dc93d0a818a66f228d3c09
dev/bots/download_android_tools.py
View file @
3addac54
...
...
@@ -14,6 +14,7 @@ import shutil
import
subprocess
import
sys
import
tarfile
import
optparse
# Path constants. (All of these should be absolute paths.)
THIS_DIR
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
...
...
@@ -45,6 +46,8 @@ def VersionStampName(tools_name):
return
'VERSION_LINUX_'
+
tools_name
.
upper
()
elif
sys
.
platform
==
'darwin'
:
return
'VERSION_MACOSX_'
+
tools_name
.
upper
()
elif
sys
.
platform
.
startswith
((
'cygwin'
,
'win'
)):
return
'VERSION_WIN_'
+
tools_name
.
upper
()
else
:
raise
Exception
(
'Unsupported platform: '
+
sys
.
platform
)
...
...
@@ -89,9 +92,28 @@ def UpdateTools(tools_name):
with
open
(
os
.
path
.
join
(
INSTALL_DIR
,
version_stamp
),
'w+'
)
as
f
:
f
.
write
(
'
%
s
\n
'
%
version
)
def
main
():
UpdateTools
(
'sdk'
)
UpdateTools
(
'ndk'
)
def
main
(
argv
):
option_parser
=
optparse
.
OptionParser
()
option_parser
.
add_option
(
'-t'
,
'--type'
,
help
=
'type of the tools: sdk, ndk, or both'
,
type
=
'string'
,
default
=
'both'
)
(
options
,
args
)
=
option_parser
.
parse_args
(
argv
)
if
len
(
args
)
>
1
:
print
'Unknown argument: '
,
args
[
1
:]
option_parser
.
print_help
()
sys
.
exit
(
1
)
if
not
options
.
type
in
(
'sdk'
,
'ndk'
,
'both'
):
option_parser
.
print_help
()
sys
.
exit
(
1
)
if
options
.
type
in
(
'sdk'
,
'both'
):
UpdateTools
(
'sdk'
)
if
options
.
type
in
(
'ndk'
,
'both'
):
UpdateTools
(
'ndk'
)
if
__name__
==
'__main__'
:
sys
.
exit
(
main
())
sys
.
exit
(
main
(
sys
.
argv
))
dev/bots/upload_android_tools.py
0 → 100644
View file @
3addac54
#!/usr/bin/python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
This script takes an Android Tools tree, creates a tar.gz archive and
uploads it to Google Cloud Storage at gs://mojo/android/tool. It also produces
the VERSION stamp files with the sha1 code of the uploaded archive.
This script operates in the INSTALL_DIR directory, so it automatically updates
your current installation of the android tools binaries on success. On failure
it invalidates your current installation; to fix it, run
run download_android_tools.py.
"""
import
hashlib
import
os
import
shutil
import
subprocess
import
sys
import
tarfile
import
optparse
# Path constants. (All of these should be absolute paths.)
THIS_DIR
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
INSTALL_DIR
=
os
.
path
.
join
(
THIS_DIR
,
'android_tools'
)
import
find_depot_tools
DEPOT_PATH
=
find_depot_tools
.
add_depot_tools_to_path
()
GSUTIL_PATH
=
os
.
path
.
join
(
DEPOT_PATH
,
'gsutil.py'
)
def
RunCommand
(
command
,
env
=
None
):
"""Run command and return success (True) or failure."""
print
'Running
%
s'
%
(
str
(
command
))
if
subprocess
.
call
(
command
,
shell
=
False
,
env
=
env
)
==
0
:
return
True
print
'Failed.'
return
False
def
VersionStampName
(
tools_name
):
if
sys
.
platform
.
startswith
(
'linux'
):
return
'VERSION_LINUX_'
+
tools_name
.
upper
()
elif
sys
.
platform
==
'darwin'
:
return
'VERSION_MACOSX_'
+
tools_name
.
upper
()
elif
sys
.
platform
.
startswith
((
'cygwin'
,
'win'
)):
return
'VERSION_WIN_'
+
tools_name
.
upper
()
else
:
raise
Exception
(
'Unsupported platform: '
+
sys
.
platform
)
def
CheckInstallDir
(
tools_name
):
"""Check if the tools directory exists."""
tools_dir
=
os
.
path
.
join
(
INSTALL_DIR
,
tools_name
)
if
not
os
.
path
.
exists
(
tools_dir
):
print
tools_dir
+
' does not exists'
sys
.
exit
(
1
)
# Remove the existing version stamp.
version_stamp
=
VersionStampName
(
tools_name
)
stamp_file
=
os
.
path
.
join
(
INSTALL_DIR
,
version_stamp
)
if
os
.
path
.
exists
(
stamp_file
):
os
.
remove
(
stamp_file
)
def
Compress
(
tools_name
):
"""Compresses the tools into tar.gz and generates sha1 code, renames the
archive to sha1.tar.gz and returns the sha1 code."""
print
"Compressing tools, this may take several minutes."
os
.
chdir
(
INSTALL_DIR
)
archive_name
=
tools_name
+
'.tar.gz'
with
tarfile
.
open
(
os
.
path
.
join
(
archive_name
),
'w|gz'
)
as
tools
:
tools
.
add
(
tools_name
)
sha1
=
''
with
open
(
os
.
path
.
join
(
INSTALL_DIR
,
archive_name
))
as
f
:
sha1
=
hashlib
.
sha1
(
f
.
read
())
.
hexdigest
()
os
.
rename
(
os
.
path
.
join
(
INSTALL_DIR
,
archive_name
),
os
.
path
.
join
(
INSTALL_DIR
,
'
%
s.tar.gz'
%
sha1
))
return
sha1
def
Upload
(
tools_name
,
sha1
):
"""Uploads INSTALL_DIR/sha1.tar.gz to Google Cloud Storage under
gs://mojo/android/tool and writes sha1 to THIS_DIR/VERSION_*."""
file_name
=
'
%
s.tar.gz'
%
sha1
upload_cmd
=
[
'python'
,
GSUTIL_PATH
,
'cp'
,
'-n'
,
# Do not upload if the file already exists.
os
.
path
.
join
(
INSTALL_DIR
,
file_name
),
'gs://mojo/android/tool/
%
s'
%
file_name
]
print
"Uploading ' + tools_name + ' tools to GCS."
if
not
RunCommand
(
upload_cmd
):
print
"Failed to upload android tool to GCS."
sys
.
exit
(
1
)
os
.
remove
(
os
.
path
.
join
(
INSTALL_DIR
,
file_name
))
# Write versions as the last step.
version_stamp
=
VersionStampName
(
tools_name
)
stamp_file
=
os
.
path
.
join
(
THIS_DIR
,
version_stamp
)
with
open
(
stamp_file
,
'w+'
)
as
stamp
:
stamp
.
write
(
'
%
s
\n
'
%
sha1
)
stamp_file
=
os
.
path
.
join
(
INSTALL_DIR
,
version_stamp
)
with
open
(
stamp_file
,
'w+'
)
as
stamp
:
stamp
.
write
(
'
%
s
\n
'
%
sha1
)
def
main
(
argv
):
option_parser
=
optparse
.
OptionParser
()
option_parser
.
add_option
(
'-t'
,
'--type'
,
help
=
'type of the tools: sdk or ndk'
,
type
=
'string'
)
(
options
,
args
)
=
option_parser
.
parse_args
(
argv
)
if
len
(
args
)
>
1
:
print
'Unknown argument: '
,
args
[
1
:]
option_parser
.
print_help
()
sys
.
exit
(
1
)
if
not
options
.
type
in
{
'sdk'
,
'ndk'
}:
option_parser
.
print_help
()
sys
.
exit
(
1
)
CheckInstallDir
(
options
.
type
)
sha1
=
Compress
(
options
.
type
)
Upload
(
options
.
type
,
sha1
)
print
"Done."
if
__name__
==
'__main__'
:
sys
.
exit
(
main
(
sys
.
argv
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment