1#!/usr/bin/env python 2# 3# Copyright 2014 The Chromium Authors. 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 7import fnmatch 8import optparse 9import os 10import sys 11 12REPOSITORY_ROOT = os.path.abspath(os.path.join( 13 os.path.dirname(__file__), '..', '..', '..')) 14 15sys.path.append(os.path.join(REPOSITORY_ROOT, 'build/android/gyp/util')) 16import build_utils 17 18 19def JarSources(src_dir, jar_path): 20 # The paths of the files in the jar will be the same as they are passed in to 21 # the command. Because of this, the command should be run in 22 # options.src_dir so the .java file paths in the jar are correct. 23 jar_cwd = src_dir 24 jar_path = os.path.abspath(jar_path) 25 jar_cmd = ['jar', 'cf', jar_path, '.'] 26 build_utils.CheckOutput(jar_cmd, cwd=jar_cwd) 27 28 29def main(): 30 parser = optparse.OptionParser() 31 parser.add_option('--src-dir', help='Directory containing .java files.') 32 parser.add_option('--jar-path', help='Jar output path.') 33 parser.add_option('--stamp', help='Path to touch on success.') 34 35 options, _ = parser.parse_args() 36 37 JarSources(options.src_dir, options.jar_path) 38 39 if options.stamp: 40 build_utils.Touch(options.stamp) 41 42 43if __name__ == '__main__': 44 sys.exit(main()) 45 46