Home | History | Annotate | Download | only in build
      1 # Copyright 2014 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 # This file is meant to be included into a target to provide a rule to build
      6 # a JAR file for use on a host in a consistent manner.
      7 #
      8 # To use this, create a gyp target with the following form:
      9 # {
     10 #   'target_name': 'my_jar',
     11 #   'type': 'none',
     12 #   'variables': {
     13 #     'src_paths': [
     14 #       'path/to/directory',
     15 #       'path/to/other/directory',
     16 #       'path/to/individual_file.java',
     17 #       ...
     18 #     ],
     19 #   },
     20 #   'includes': [ 'path/to/this/gypi/file' ],
     21 # }
     22 #
     23 # Required variables:
     24 #   src_paths - A list of all paths containing java files that should be
     25 #     included in the jar. Paths can be either directories or files.
     26 # Optional/automatic variables:
     27 #   excluded_src_paths - A list of all paths that should be excluded from
     28 #     the jar.
     29 #   generated_src_dirs - Directories containing additional .java files
     30 #     generated at build time.
     31 #   input_jars_paths - A list of paths to the jars that should be included
     32 #     in the classpath.
     33 #   main_class - The class containing the main() function that should be called
     34 #     when running the jar file.
     35 #   jar_excluded_classes - A list of .class files that should be excluded
     36 #     from the jar.
     37 
     38 {
     39   'dependencies': [
     40     '<(DEPTH)/build/android/setup.gyp:build_output_dirs',
     41   ],
     42   'variables': {
     43     'classes_dir': '<(intermediate_dir)/classes',
     44     'excluded_src_paths': [],
     45     'generated_src_dirs': [],
     46     'input_jars_paths': [],
     47     'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)',
     48     'jar_dir': '<(PRODUCT_DIR)/lib.java',
     49     'jar_excluded_classes': [],
     50     'jar_name': '<(_target_name).jar',
     51     'jar_path': '<(jar_dir)/<(jar_name)',
     52     'main_class%': '',
     53     'stamp': '<(intermediate_dir)/jar.stamp',
     54   },
     55   'all_dependent_settings': {
     56     'variables': {
     57       'input_jars_paths': ['<(jar_path)']
     58     },
     59   },
     60   'actions': [
     61     {
     62       'action_name': 'javac_<(_target_name)',
     63       'message': 'Compiling <(_target_name) java sources',
     64       'variables': {
     65         'extra_options': [],
     66         'java_sources': [ '<!@(find <@(src_paths) -name "*.java")' ],
     67         'conditions': [
     68           ['"<(excluded_src_paths)" != ""', {
     69             'java_sources!': ['<!@(find <@(excluded_src_paths) -name "*.java")']
     70           }],
     71           ['"<(jar_excluded_classes)" != ""', {
     72             'extra_options': ['--excluded-classes=<(jar_excluded_classes)']
     73           }],
     74           ['">(main_class)" != ""', {
     75             'extra_options': ['--main-class=>(main_class)']
     76           }]
     77         ],
     78       },
     79       'inputs': [
     80         '<(DEPTH)/build/android/gyp/util/build_utils.py',
     81         '<(DEPTH)/build/android/gyp/javac.py',
     82         '^@(java_sources)',
     83         '>@(input_jars_paths)',
     84       ],
     85       'outputs': [
     86         '<(jar_path)',
     87         '<(stamp)',
     88       ],
     89       'action': [
     90         'python', '<(DEPTH)/build/android/gyp/javac.py',
     91         '--classpath=>(input_jars_paths)',
     92         '--src-gendirs=>(generated_src_dirs)',
     93         '--chromium-code=<(chromium_code)',
     94         '--stamp=<(stamp)',
     95         '--jar-path=<(jar_path)',
     96         '<@(extra_options)',
     97         '^@(java_sources)',
     98       ],
     99     },
    100   ]
    101 }
    102 
    103