예제 #1
0
def GenerateJavadoc(options, src_dir, output_dir):
    working_dir = os.path.join(options.input_dir, 'android', 'api')
    overview_file = os.path.abspath(options.overview_file)

    android_sdk_jar = os.path.abspath(options.android_sdk_jar)
    if not android_sdk_jar:
        android_sdk_jar = os.path.join(SDK_DIR, 'platforms', 'android-27',
                                       'android.jar')

    build_utils.DeleteDirectory(output_dir)
    build_utils.MakeDirectory(output_dir)
    javadoc_cmd = [
        'javadoc',
        '-d',
        output_dir,
        '-overview',
        overview_file,
        '-doclet',
        'com.google.doclava.Doclava',
        '-docletpath',
        '%s:%s' % (os.path.join(DOCLAVA_DIR, 'jsilver.jar'),
                   os.path.join(DOCLAVA_DIR, 'doclava.jar')),
        '-title',
        'Cronet API',
        '-federate',
        'Android',
        'https://developer.android.com/',
        '-federationapi',
        'Android',
        os.path.join(DOCLAVA_DIR, 'current.txt'),
        '-bootclasspath',
        '%s:%s' %
        (android_sdk_jar,
         os.path.join(SDK_DIR, 'extras', 'android', 'support', 'annotations',
                      'android-support-annotations.jar')),
    ]
    for subdir, _, files in os.walk(src_dir):
        for filename in files:
            if filename.endswith(".java"):
                javadoc_cmd += [os.path.join(subdir, filename)]
    try:
        build_utils.CheckOutput(javadoc_cmd,
                                cwd=working_dir,
                                fail_func=lambda ret, stderr:
                                (ret != 0 or not stderr is ''))
    except build_utils.CalledProcessError:
        build_utils.DeleteDirectory(output_dir)
        raise

    # Create an index.html file at the root as this is the accepted format.
    # Do this by copying reference/index.html and adjusting the path.
    with open(os.path.join(output_dir, 'reference', 'index.html'), 'r') as \
        old_index, open(os.path.join(output_dir, 'index.html'), 'w') as new_index:
        for line in old_index:
            new_index.write(
                line.replace('classes.html',
                             os.path.join('reference', 'classes.html')))
예제 #2
0
 def _CreateTestResourceFile(output_dir, locale, string_map, namespaces):
     values_dir = os.path.join(output_dir, 'values-' + locale)
     build_utils.MakeDirectory(values_dir)
     file_path = os.path.join(values_dir, 'strings.xml')
     with open(file_path, 'w') as f:
         file_data = resource_utils.GenerateAndroidResourceStringsXml(
             string_map, namespaces)
         f.write(file_data)
     return file_path
예제 #3
0
def GenerateJavadoc(options):
  output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
  working_dir = os.path.join(options.input_dir, 'android/java')
  overview_file = os.path.abspath(options.overview_file)

  build_utils.DeleteDirectory(output_dir)
  build_utils.MakeDirectory(output_dir)
  javadoc_cmd = ['ant', '-Dsource.dir=src', '-Ddoc.dir=' + output_dir,
             '-Doverview=' + overview_file, 'doc']
  build_utils.CheckOutput(javadoc_cmd, cwd=working_dir)
예제 #4
0
def ExtractJars(options):
    # The paths of the files in the jar will be the same as they are passed in to
    # the command. Because of this, the command should be run in
    # options.classes_dir so the .class file paths in the jar are correct.
    jar_cwd = options.classes_dir
    build_utils.DeleteDirectory(jar_cwd)
    build_utils.MakeDirectory(jar_cwd)
    for jar in build_utils.ParseGnList(options.jars):
        jar_path = os.path.abspath(jar)
        jar_cmd = ['jar', 'xf', jar_path]
        build_utils.CheckOutput(jar_cmd, cwd=jar_cwd)
예제 #5
0
def GenerateJavadoc(options):
    source_dir = options.source_dir
    output_dir = options.output_dir
    working_dir = options.working_dir

    build_utils.DeleteDirectory(output_dir)
    build_utils.MakeDirectory(output_dir)
    javadoc_cmd = [
        'ant', '-Dsource.dir=' + source_dir,
        '-Ddoc.dir=' + os.path.abspath(output_dir), 'doc'
    ]
    build_utils.CheckOutput(javadoc_cmd, cwd=working_dir)
예제 #6
0
def GenerateJavadoc(options):
  output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
  working_dir = os.path.join(options.input_dir, 'android/api')
  overview_file = os.path.abspath(options.overview_file)

  build_utils.DeleteDirectory(output_dir)
  build_utils.MakeDirectory(output_dir)
  javadoc_cmd = ['ant', '-Dsource.dir=src', '-Ddoc.dir=' + output_dir,
             '-Doverview=' + overview_file, 'doc']
  stdout = build_utils.CheckOutput(javadoc_cmd, cwd=working_dir)
  if " error: " in stdout or "warning" in stdout:
    build_utils.DeleteDirectory(output_dir)
    raise build_utils.CalledProcessError(working_dir, javadoc_cmd, stdout)
예제 #7
0
def GenerateJavadoc(options, src_dir):
    output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
    working_dir = os.path.join(options.input_dir, 'android', 'api')
    overview_file = os.path.abspath(options.overview_file)

    android_sdk_jar = os.path.abspath(options.android_sdk_jar)
    if not android_sdk_jar:
        android_sdk_jar = os.path.join(SDK_DIR, 'platforms', 'android-27',
                                       'android.jar')

    build_utils.DeleteDirectory(output_dir)
    build_utils.MakeDirectory(output_dir)
    javadoc_cmd = [
        'javadoc',
        '-d',
        output_dir,
        '-overview',
        overview_file,
        '-doclet',
        'com.google.doclava.Doclava',
        '-docletpath',
        '%s:%s' % (os.path.join(DOCLAVA_DIR, 'jsilver.jar'),
                   os.path.join(DOCLAVA_DIR, 'doclava.jar')),
        '-title',
        'Cronet API',
        '-federate',
        'Android',
        'https://developer.android.com/',
        '-federationapi',
        'Android',
        os.path.join(DOCLAVA_DIR, 'current.txt'),
        '-bootclasspath',
        '%s:%s' %
        (android_sdk_jar,
         os.path.join(SDK_DIR, 'extras', 'android', 'support', 'annotations',
                      'android-support-annotations.jar')),
    ]
    for subdir, _, files in os.walk(src_dir):
        for filename in files:
            if filename.endswith(".java"):
                javadoc_cmd += [os.path.join(subdir, filename)]
    try:
        build_utils.CheckOutput(javadoc_cmd,
                                cwd=working_dir,
                                fail_func=lambda ret, stderr:
                                (ret != 0 or not stderr is ''))
    except build_utils.CalledProcessError:
        build_utils.DeleteDirectory(output_dir)
        raise
def GenerateJavadoc(options, src_dir):
    output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
    working_dir = os.path.join(options.input_dir, 'android/api')
    overview_file = os.path.abspath(options.overview_file)
    lib_java_dir = os.path.abspath(options.lib_java_dir)

    build_utils.DeleteDirectory(output_dir)
    build_utils.MakeDirectory(output_dir)
    javadoc_cmd = [
        'ant', '-Dsource.dir=' + src_dir, '-Ddoc.dir=' + output_dir,
        '-Dlib.java.dir=' + lib_java_dir, '-Doverview=' + overview_file, 'doc'
    ]
    stdout = build_utils.CheckOutput(javadoc_cmd, cwd=working_dir)
    for line in stdout.splitlines():
        if " error: " in line or "javadoc: error " in line:
            build_utils.DeleteDirectory(output_dir)
            raise build_utils.CalledProcessError(working_dir, javadoc_cmd,
                                                 stdout)
        # TODO(crbug.com/655666): remove compiler  suppression warning once fixed.
        if ("warning" in line and not line.endswith('warnings')
                and not "the highest major version" in line):
            build_utils.DeleteDirectory(output_dir)
            raise build_utils.CalledProcessError(working_dir, javadoc_cmd,
                                                 stdout)