Exemplo n.º 1
0
def compile_demo(force, is_debug):
    """Compile the demo application.

  Args:
    force: True to rebuild, False to ignore if no changes are detected.
    is_debug: True to compile for debugging, false for release.

  Returns:
    True on success, False on failure.
  """
    logging.info('Compiling the demo app (%s)...',
                 'debug' if is_debug else 'release')

    base = shakaBuildHelpers.get_source_base()
    closure_base_js = shakaBuildHelpers.get_closure_base_js_path()
    get = shakaBuildHelpers.get_all_js_files
    cast_receiver = set(get('demo', 'cast_receiver'))
    files = set(
        get('demo') + get('externs') + get('ui', 'externs') +
        [closure_base_js]) - cast_receiver

    # Make sure we don't compile in load.js, which will be used to bootstrap
    # everything else.  If we build that into the output, we will get an
    # infinite loop of scripts adding themselves.
    files.remove(os.path.join(base, 'demo', 'load.js'))
    # Remove service_worker.js as well.  This executes in a different context.
    files.remove(os.path.join(base, 'demo', 'service_worker.js'))
    # Don't compile in the uncompiled require file.
    files.remove(os.path.join(base, 'demo', 'demo_uncompiled.js'))
    # Add lib/debug/asserts.js, which is required for goog.assert.
    files.add(os.path.join(base, 'lib', 'debug', 'asserts.js'))

    # Add in the generated externs, so that the demo compilation knows the
    # definitions of the library APIs.
    externs = ('shaka-player.ui.debug.externs.js'
               if is_debug else 'shaka-player.ui.externs.js')

    files.add(os.path.join(base, 'dist', externs))

    name = 'demo.compiled' + ('.debug' if is_debug else '')

    # TODO: Why do we always use debug_closure_opts?  Nobody remembers.
    closure_opts = build.common_closure_opts + build.debug_closure_opts
    closure_opts += [
        # Ignore missing goog.require since we assume the whole library is
        # already included.
        '--jscomp_off=missingRequire',
        '--jscomp_off=strictMissingRequire',
        '-D',
        'COMPILED=true',
    ]

    closure = compiler.ClosureCompiler(files, name)
    # The output wrapper is only designed for the library.  It can't be used
    # for apps.  TODO: Should we add a simple function wrapper for apps?
    closure.add_wrapper = False
    if not closure.compile(closure_opts, force):
        return False

    return True
Exemplo n.º 2
0
def compile_receiver(force, is_debug):
    """Compile the cast receiver application.

  Args:
    force: True to rebuild, False to ignore if no changes are detected.
    is_debug: True to compile for debugging, false for release.

  Returns:
    True on success, False on failure.
  """
    logging.info('Compiling the receiver app (%s)...',
                 'debug' if is_debug else 'release')

    base = shakaBuildHelpers.get_source_base()
    closure_base_js = shakaBuildHelpers.get_closure_base_js_path()
    get = shakaBuildHelpers.get_all_js_files
    files = set(
        get('demo', 'common') + get('demo', 'cast_receiver') + get('externs') +
        get('ui', 'externs') + [closure_base_js])

    # Add in the generated externs, so that the receiver compilation knows the
    # definitions of the library APIs.
    externs = ('shaka-player.ui.debug.externs.js'
               if is_debug else 'shaka-player.ui.externs.js')

    files.add(os.path.join(base, 'dist', externs))
    files.add(os.path.join(base, 'lib', 'debug', 'asserts.js'))

    name = 'receiver.compiled' + ('.debug' if is_debug else '')

    # TODO: Why do we always use debug_closure_opts?  Nobody remembers.
    closure_opts = build.common_closure_opts + build.debug_closure_opts
    closure_opts += [
        # Ignore missing goog.require since we assume the whole library is
        # already included.
        '--jscomp_off=missingRequire',
        '--jscomp_off=strictMissingRequire',
        '-D',
        'COMPILED=true',
    ]

    closure = compiler.ClosureCompiler(files, name)
    # The output wrapper is only designed for the library.  It can't be used
    # for apps.  TODO: Should we add a simple function wrapper for apps?
    closure.add_wrapper = False
    if not closure.compile(closure_opts, force):
        return False

    return True
Exemplo n.º 3
0
def check_tests(args):
  """Runs an extra compile pass over the test code to check for type errors.

  Returns:
    True on success, False on failure.
  """
  logging.info('Checking the tests for type errors...')

  complete_build = complete_build_files()
  if not complete_build:
    return False

  base = shakaBuildHelpers.get_source_base()
  closure_base_js = shakaBuildHelpers.get_closure_base_js_path()
  get = shakaBuildHelpers.get_all_js_files

  files = complete_build
  files.update(set(
      get('externs') +
      get('test') +
      [closure_base_js]))
  files.add(os.path.join(base, 'demo', 'common', 'asset.js'))
  files.add(os.path.join(base, 'demo', 'common', 'assets.js'))
  files.add(os.path.join(base, 'demo', 'common', 'message_ids.js'))

  localizations = compiler.GenerateLocalizations(None)
  localizations.generate(args.force)
  files.add(localizations.output)

  closure_opts = build.common_closure_opts + build.common_closure_defines
  closure_opts += build.debug_closure_opts + build.debug_closure_defines

  # Ignore missing goog.require since we assume the whole library is
  # already included.
  closure_opts += [
      '--jscomp_off=missingRequire',
      '--checks-only', '-O', 'SIMPLE',
  ]

  # Set up a build with the build name of "dummy".  With output_compiled_bundle
  # set to False, the build name is irrelevant, since we won't generate any
  # compiled output.
  closure = compiler.ClosureCompiler(files, 'dummy')
  closure.output_compiled_bundle = False
  # Instead of creating a compiled bundle, we will touch a timestamp file to
  # keep track of how recently we've run this check.
  closure.timestamp_file = os.path.join(base, 'dist', '.testcheckstamp')
  return closure.compile(closure_opts, args.force)
Exemplo n.º 4
0
 def add_closure(self):
     """Adds the closure library and externs."""
     # Add externs and closure dependencies.
     self.include |= set([shakaBuildHelpers.get_closure_base_js_path()] +
                         shakaBuildHelpers.get_all_js_files('externs'))