Merge "simpleperf: update simpleperf prebuilts to build 3614643." am: c5775f1239 am: 8df3424b96 am: 4ab5f41bfa
am: 6c8ae66544
Change-Id: Ic65b867170ce7dfe77075ddc02e3f2ed085a9e07
diff --git a/simpleperf/scripts/bin/android/arm/simpleperf b/simpleperf/scripts/bin/android/arm/simpleperf
new file mode 100755
index 0000000..8e8a37f
--- /dev/null
+++ b/simpleperf/scripts/bin/android/arm/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/arm64/simpleperf b/simpleperf/scripts/bin/android/arm64/simpleperf
new file mode 100755
index 0000000..d34fa99
--- /dev/null
+++ b/simpleperf/scripts/bin/android/arm64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/x86/simpleperf b/simpleperf/scripts/bin/android/x86/simpleperf
new file mode 100755
index 0000000..01d3360
--- /dev/null
+++ b/simpleperf/scripts/bin/android/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/x86_64/simpleperf b/simpleperf/scripts/bin/android/x86_64/simpleperf
new file mode 100755
index 0000000..6f933ce
--- /dev/null
+++ b/simpleperf/scripts/bin/android/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib b/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib
new file mode 100755
index 0000000..dcb85da
--- /dev/null
+++ b/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86/simpleperf b/simpleperf/scripts/bin/darwin/x86/simpleperf
new file mode 100755
index 0000000..c0d6f52
--- /dev/null
+++ b/simpleperf/scripts/bin/darwin/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib b/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
new file mode 100755
index 0000000..ae8f2c2
--- /dev/null
+++ b/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86_64/simpleperf b/simpleperf/scripts/bin/darwin/x86_64/simpleperf
new file mode 100755
index 0000000..284bf81
--- /dev/null
+++ b/simpleperf/scripts/bin/darwin/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so b/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so
new file mode 100755
index 0000000..80d87bd
--- /dev/null
+++ b/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86/simpleperf b/simpleperf/scripts/bin/linux/x86/simpleperf
new file mode 100755
index 0000000..5ff8c9e
--- /dev/null
+++ b/simpleperf/scripts/bin/linux/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so b/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
new file mode 100755
index 0000000..d610a34
--- /dev/null
+++ b/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86_64/simpleperf b/simpleperf/scripts/bin/linux/x86_64/simpleperf
new file mode 100755
index 0000000..edd5795
--- /dev/null
+++ b/simpleperf/scripts/bin/linux/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll b/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
new file mode 100755
index 0000000..2f22204
--- /dev/null
+++ b/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/simpleperf.exe b/simpleperf/scripts/bin/windows/x86/simpleperf.exe
new file mode 100755
index 0000000..d6efa03
--- /dev/null
+++ b/simpleperf/scripts/bin/windows/x86/simpleperf.exe
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll b/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
new file mode 100755
index 0000000..2849ef1
--- /dev/null
+++ b/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe b/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
new file mode 100755
index 0000000..571837c
--- /dev/null
+++ b/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
Binary files differ
diff --git a/simpleperf/scripts/update.py b/simpleperf/scripts/update.py
new file mode 100644
index 0000000..7065ef0
--- /dev/null
+++ b/simpleperf/scripts/update.py
@@ -0,0 +1,178 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""Downloads simpleperf prebuilts from the build server."""
+import argparse
+import logging
+import os
+import shutil
+import stat
+import textwrap
+
+
+THIS_DIR = os.path.realpath(os.path.dirname(__file__))
+
+
+class InstallEntry(object):
+ def __init__(self, target, name, install_path, need_strip=False):
+ self.target = target
+ self.name = name
+ self.install_path = install_path
+ self.need_strip = need_strip
+
+
+install_list = [
+ # simpleperf on device
+ InstallEntry('sdk_arm64-sdk', 'simpleperf', 'android/arm64/simpleperf'),
+ InstallEntry('sdk_arm64-sdk', 'simpleperf32', 'android/arm/simpleperf'),
+ InstallEntry('sdk_x86_64-sdk', 'simpleperf', 'android/x86_64/simpleperf'),
+ InstallEntry('sdk_x86_64-sdk', 'simpleperf32', 'android/x86/simpleperf'),
+
+ # simpleperf on host
+ InstallEntry('sdk_arm64-sdk', 'simpleperf_host', 'linux/x86_64/simpleperf', True),
+ InstallEntry('sdk_arm64-sdk', 'simpleperf_host32', 'linux/x86/simpleperf', True),
+ InstallEntry('sdk_mac', 'simpleperf_host', 'darwin/x86_64/simpleperf'),
+ InstallEntry('sdk_mac', 'simpleperf_host32', 'darwin/x86/simpleperf'),
+ InstallEntry('sdk', 'simpleperf.exe', 'windows/x86_64/simpleperf.exe', True),
+ InstallEntry('sdk', 'simpleperf32.exe', 'windows/x86/simpleperf.exe', True),
+
+ # libsimpleperf_report.so on host
+ InstallEntry('sdk_arm64-sdk', 'libsimpleperf_report.so', 'linux/x86_64/libsimpleperf_report.so', True),
+ InstallEntry('sdk_arm64-sdk', 'libsimpleperf_report32.so', 'linux/x86/libsimpleperf_report.so', True),
+ InstallEntry('sdk_mac', 'libsimpleperf_report.dylib', 'darwin/x86_64/libsimpleperf_report.dylib'),
+ InstallEntry('sdk_mac', 'libsimpleperf_report32.so', 'darwin/x86/libsimpleperf_report.dylib'),
+ InstallEntry('sdk', 'libsimpleperf_report.dll', 'windows/x86_64/libsimpleperf_report.dll', True),
+ InstallEntry('sdk', 'libsimpleperf_report32.dll', 'windows/x86/libsimpleperf_report.dll', True),
+]
+
+
+def logger():
+ """Returns the main logger for this module."""
+ return logging.getLogger(__name__)
+
+
+def check_call(cmd):
+ """Proxy for subprocess.check_call with logging."""
+ import subprocess
+ logger().debug('check_call `%s`', ' '.join(cmd))
+ subprocess.check_call(cmd)
+
+
+def fetch_artifact(branch, build, target, pattern):
+ """Fetches and artifact from the build server."""
+ logger().info('Fetching %s from %s %s (artifacts matching %s)', build,
+ target, branch, pattern)
+ fetch_artifact_path = '/google/data/ro/projects/android/fetch_artifact'
+ cmd = [fetch_artifact_path, '--branch', branch, '--target', target,
+ '--bid', build, pattern]
+ check_call(cmd)
+
+
+def start_branch(build):
+ """Creates a new branch in the project."""
+ branch_name = 'update-' + (build or 'latest')
+ logger().info('Creating branch %s', branch_name)
+ check_call(['repo', 'start', branch_name, '.'])
+
+
+def commit(branch, build, add_paths):
+ """Commits the new prebuilts."""
+ logger().info('Making commit')
+ check_call(['git', 'add'] + add_paths)
+ message = textwrap.dedent("""\
+ simpleperf: update simpleperf prebuilts to build {build}.
+
+ Taken from branch {branch}.""").format(branch=branch, build=build)
+ check_call(['git', 'commit', '-m', message])
+
+
+def remove_old_release(install_dir):
+ """Removes the old prebuilts."""
+ if os.path.exists(install_dir):
+ logger().info('Removing old install directory "%s"', install_dir)
+ check_call(['git', 'rm', '-rf', '--ignore-unmatch', install_dir])
+
+ # Need to check again because git won't remove directories if they have
+ # non-git files in them.
+ if os.path.exists(install_dir):
+ shutil.rmtree(install_dir)
+
+
+def install_new_release(branch, build, install_dir):
+ """Installs the new release."""
+ for entry in install_list:
+ install_entry(branch, build, install_dir, entry)
+
+
+def install_entry(branch, build, install_dir, entry):
+ """Installs the device specific components of the release."""
+ target = entry.target
+ name = entry.name
+ install_path = os.path.join(install_dir, entry.install_path)
+ need_strip = entry.need_strip
+
+ fetch_artifact(branch, build, target, name)
+ exe_stat = os.stat(name)
+ os.chmod(name, exe_stat.st_mode | stat.S_IEXEC)
+ if need_strip:
+ check_call(['strip', name])
+ dir = os.path.dirname(install_path)
+ if not os.path.isdir(dir):
+ os.makedirs(dir)
+ shutil.move(name, install_path)
+
+
+def get_args():
+ """Parses and returns command line arguments."""
+ parser = argparse.ArgumentParser()
+
+ parser.add_argument(
+ '-b', '--branch', default='aosp-master',
+ help='Branch to pull build from.')
+ parser.add_argument('--build', required=True, help='Build number to pull.')
+ parser.add_argument(
+ '--use-current-branch', action='store_true',
+ help='Perform the update in the current branch. Do not repo start.')
+ parser.add_argument(
+ '-v', '--verbose', action='count', default=0,
+ help='Increase output verbosity.')
+
+ return parser.parse_args()
+
+
+def main():
+ """Program entry point."""
+ os.chdir(THIS_DIR)
+
+ args = get_args()
+ verbose_map = (logging.WARNING, logging.INFO, logging.DEBUG)
+ verbosity = args.verbose
+ if verbosity > 2:
+ verbosity = 2
+ logging.basicConfig(level=verbose_map[verbosity])
+
+ install_dir = 'bin'
+
+ if not args.use_current_branch:
+ start_branch(args.build)
+ remove_old_release(install_dir)
+ install_new_release(args.branch, args.build, install_dir)
+ artifacts = [install_dir]
+ commit(args.branch, args.build, artifacts)
+
+
+if __name__ == '__main__':
+ main()
\ No newline at end of file