1#!/usr/bin/env python3 2# Copyright 2018 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6"""Simple wrapper around the bundletool tool. 7 8Bundletool is distributed as a versioned jar file. This script abstracts the 9location and version of this jar file, as well as the JVM invokation.""" 10 11# Warning: Check if still being run as python2: https://crbug.com/1322618 12 13import logging 14import os 15import sys 16 17from util import build_utils 18 19# Assume this is stored under build/android/gyp/ 20BUNDLETOOL_DIR = os.path.abspath(os.path.join( 21 __file__, '..', '..', '..', '..', 'third_party', 'android_build_tools', 22 'bundletool')) 23 24BUNDLETOOL_JAR_PATH = os.path.join(BUNDLETOOL_DIR, 'bundletool.jar') 25 26 27def RunBundleTool(args, print_stdout=False): 28 # ASAN builds failed with the default of 1GB (crbug.com/1120202). 29 # Bug for bundletool: https://issuetracker.google.com/issues/165911616 30 cmd = build_utils.JavaCmd(xmx='4G') 31 cmd += ['-jar', BUNDLETOOL_JAR_PATH] 32 cmd += args 33 logging.debug(' '.join(cmd)) 34 return build_utils.CheckOutput( 35 cmd, 36 print_stdout=print_stdout, 37 print_stderr=True, 38 fail_on_output=False, 39 stderr_filter=build_utils.FilterReflectiveAccessJavaWarnings) 40 41 42if __name__ == '__main__': 43 RunBundleTool(sys.argv[1:], print_stdout=True) 44