示例#1
0
  def build_raw(self, extra_opts, is_debug):
    """Builds the files in |self.include| using the given extra Closure options.

    Args:
      extra_opts: An array of extra options to give to Closure.
      is_debug: True to compile for debugging, false for release.

    Returns:
      True on success; False on failure.
    """
    jar = os.path.join(shakaBuildHelpers.get_source_base(),
                       'third_party', 'closure', 'compiler.jar')
    jar = shakaBuildHelpers.cygwin_safe_path(jar)
    files = [shakaBuildHelpers.cygwin_safe_path(f) for f in self.include]
    files.sort()

    try:
      if is_debug:
        closure_opts = common_closure_opts + debug_closure_opts
      else:
        closure_opts = common_closure_opts + release_closure_opts

      cmd_line = ['java', '-jar', jar] + closure_opts + extra_opts + files
      shakaBuildHelpers.print_cmd_line(cmd_line)
      subprocess.check_call(cmd_line)
      return True
    except subprocess.CalledProcessError:
      print >> sys.stderr, 'Build failed'
      return False
示例#2
0
    def generate_externs(self, name):
        """Generates externs for the files in |self.include|.

    Args:
      name: The name of the build.

    Returns:
      True on success; False on failure.
    """
        # Update node modules if needed.
        if not shakaBuildHelpers.update_node_modules():
            return False

        files = [shakaBuildHelpers.cygwin_safe_path(f) for f in self.include]

        extern_generator = shakaBuildHelpers.cygwin_safe_path(
            os.path.join(shakaBuildHelpers.get_source_base(), 'build',
                         'generateExterns.js'))

        output = shakaBuildHelpers.cygwin_safe_path(
            os.path.join(shakaBuildHelpers.get_source_base(), 'dist',
                         'shaka-player.' + name + '.externs.js'))

        # TODO: support Windows builds
        cmd_line = ['node', extern_generator, '--output', output] + files
        try:
            shakaBuildHelpers.print_cmd_line(cmd_line)
            subprocess.check_call(cmd_line)
            return True
        except subprocess.CalledProcessError:
            print >> sys.stderr, 'Externs generation failed'
            return False
示例#3
0
def run_tests(args):
    """Runs all the karma tests."""
    # Update node modules if needed.
    if not shakaBuildHelpers.update_node_modules():
        return 1

    # Generate dependencies and compile library.
    # This is required for the tests.
    if gendeps.gen_deps([]) != 0:
        return 1

    build_args = []
    if "--force" in args:
        build_args.append("--force")
        args.remove("--force")

    if "--no-build" in args:
        args.remove("--no-build")
    else:
        if build.main(build_args) != 0:
            return 1

    karma_command_name = "karma"
    if shakaBuildHelpers.is_windows():
        # Windows karma program has a different name
        karma_command_name = "karma.cmd"

    karma_path = shakaBuildHelpers.get_node_binary_path(karma_command_name)
    cmd = [karma_path, "start"]

    # Get the browsers supported on the local system.
    browsers = _get_browsers()
    if not browsers:
        print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
        return 1

    print "Starting tests..."
    if not args:
        # Run tests in all available browsers.
        print "Running with platform default:", "--browsers", browsers
        cmd_line = cmd + ["--browsers", browsers]
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
    else:
        # Run with command-line arguments from the user.
        if "--browsers" not in args:
            print "No --browsers specified."
            print "In this mode, browsers must be manually connected to karma."
        cmd_line = cmd + args
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
示例#4
0
def run_tests(args):
    """Runs all the karma tests."""
    # Update node modules if needed.
    if not shakaBuildHelpers.update_node_modules():
        return 1

    # Generate dependencies and compile library.
    # This is required for the tests.
    if gendeps.gen_deps([]) != 0:
        return 1

    build_args = []
    if '--force' in args:
        build_args.append('--force')
        args.remove('--force')

    if '--no-build' in args:
        args.remove('--no-build')
    else:
        if build.main(build_args) != 0:
            return 1

    karma_command_name = 'karma'
    if shakaBuildHelpers.is_windows():
        # Windows karma program has a different name
        karma_command_name = 'karma.cmd'

    karma_path = shakaBuildHelpers.get_node_binary_path(karma_command_name)
    cmd = [karma_path, 'start']

    # Get the browsers supported on the local system.
    browsers = _get_browsers()
    if not browsers:
        print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
        return 1

    print 'Starting tests...'
    if not args:
        # Run tests in all available browsers.
        print 'Running with platform default:', '--browsers', browsers
        cmd_line = cmd + ['--browsers', browsers]
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
    else:
        # Run with command-line arguments from the user.
        if '--browsers' not in args:
            print 'No --browsers specified.'
            print 'In this mode, browsers must be manually connected to karma.'
        cmd_line = cmd + args
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
示例#5
0
def check_lint():
  """Runs the linter over the library files."""
  print 'Running Closure linter...'

  jsdoc3_tags = ','.join([
      'static', 'summary', 'namespace', 'event', 'description', 'property',
      'fires', 'listens', 'example', 'exportDoc'])
  args = ['--nobeep', '--custom_jsdoc_tags', jsdoc3_tags, '--strict']
  base = shakaBuildHelpers.get_source_base()
  cmd = os.path.join(base, 'third_party', 'gjslint', 'gjslint')

  # Even though this is python, don't import and execute since gjslint expects
  # command-line arguments using argv.  Have to explicitly execute python so
  # it works on Windows.
  cmd_line = ['python', cmd] + args + get_lint_files()
  shakaBuildHelpers.print_cmd_line(cmd_line)
  return subprocess.call(cmd_line) == 0
示例#6
0
def check_lint():
  """Runs the linter over the library files."""
  print 'Running Closure linter...'

  jsdoc3_tags = ','.join([
      'static', 'summary', 'namespace', 'event', 'description', 'property',
      'fires', 'listens', 'example', 'exportDoc'])
  args = ['--nobeep', '--custom_jsdoc_tags', jsdoc3_tags, '--strict']
  base = shakaBuildHelpers.get_source_base()
  cmd = os.path.join(base, 'third_party', 'gjslint', 'gjslint')

  # Even though this is python, don't import and execute since gjslint expects
  # command-line arguments using argv.  Have to explicitly execute python so
  # it works on Windows.
  cmd_line = [sys.executable or 'python', cmd] + args + get_lint_files()
  shakaBuildHelpers.print_cmd_line(cmd_line)
  return subprocess.call(cmd_line) == 0
示例#7
0
def run_tests(args):
  """Runs all the karma tests."""
  # Update node modules if needed.
  if not shakaBuildHelpers.update_node_modules():
    return 1

  # Generate dependencies and compile library.
  # This is required for the tests.
  if gendeps.gen_deps([]) != 0:
    return 1

  build_args = []
  if '--force' in args:
    build_args.append('--force')
    args.remove('--force')

  if '--no-build' in args:
    args.remove('--no-build')
  else:
    if build.main(build_args) != 0:
      return 1

  karma_path = shakaBuildHelpers.get_node_binary_path('karma')
  cmd = [karma_path, 'start']

  # Get the browsers supported on the local system.
  browsers = _get_browsers()
  if not browsers:
    print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
    return 1

  print 'Starting tests...'
  if not args:
    # Run tests in all available browsers.
    print 'Running with platform default:', '--browsers', browsers
    cmd_line = cmd + ['--browsers', browsers]
    shakaBuildHelpers.print_cmd_line(cmd_line)
    return subprocess.call(cmd_line)
  else:
    # Run with command-line arguments from the user.
    if '--browsers' not in args:
      print 'No --browsers specified.'
      print 'In this mode, browsers must be manually connected to karma.'
    cmd_line = cmd + args
    shakaBuildHelpers.print_cmd_line(cmd_line)
    return subprocess.call(cmd_line)
示例#8
0
def build_docs(_):
  """Builds the source code documentation."""
  print 'Building the docs...'

  base = shakaBuildHelpers.get_source_base()
  shutil.rmtree(os.path.join(base, 'docs', 'api'), ignore_errors=True)
  os.chdir(base)

  if shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
    # Windows has a different command name.  The Unix version does not seem to
    # work on Cygwin, but the windows one does.
    jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc.cmd')
  else:
    jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc')

  cmd_line = [jsdoc, '-c', 'docs/jsdoc.conf.json', '-R', 'docs/api-mainpage.md']
  shakaBuildHelpers.print_cmd_line(cmd_line)
  return subprocess.call(cmd_line)
示例#9
0
def check_html_lint():
  """Runs the HTML linter over the HTML files.

  Skipped if htmlhint is not available.

  Returns:
    True on success, False on failure.
  """
  htmlhint_path = shakaBuildHelpers.get_node_binary_path('htmlhint')
  if not os.path.exists(htmlhint_path):
    return True
  print 'Running htmlhint...'

  base = shakaBuildHelpers.get_source_base()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  cmd_line = [htmlhint_path] + file_paths
  shakaBuildHelpers.print_cmd_line(cmd_line)
  return subprocess.call(cmd_line) == 0
示例#10
0
def check_html_lint():
    """Runs the HTML linter over the HTML files.

  Skipped if htmlhint is not available.

  Returns:
    True on success, False on failure.
  """
    htmlhint_path = shakaBuildHelpers.get_node_binary_path('htmlhint')
    if not os.path.exists(htmlhint_path):
        return True
    print 'Running htmlhint...'

    base = shakaBuildHelpers.get_source_base()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    cmd_line = [htmlhint_path] + file_paths
    shakaBuildHelpers.print_cmd_line(cmd_line)
    return subprocess.call(cmd_line) == 0
示例#11
0
def build_docs(_):
    """Builds the source code documentation."""
    print 'Building the docs...'

    base = shakaBuildHelpers.get_source_base()
    shutil.rmtree(os.path.join(base, 'docs', 'api'), ignore_errors=True)
    os.chdir(base)

    if shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
        # Windows has a different command name.  The Unix version does not seem to
        # work on Cygwin, but the windows one does.
        jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc.cmd')
    else:
        jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc')

    cmd_line = [
        jsdoc, '-c', 'docs/jsdoc.conf.json', '-R', 'docs/api-mainpage.md'
    ]
    shakaBuildHelpers.print_cmd_line(cmd_line)
    return subprocess.call(cmd_line)
示例#12
0
def gen_deps(_):
  """Generates the uncompiled dependencies files."""
  print 'Generating Closure dependencies...'

  # Make the dist/ folder, ignore errors.
  base = shakaBuildHelpers.get_source_base()
  try:
    os.mkdir(os.path.join(base, 'dist'))
  except OSError:
    pass
  os.chdir(base)
  deps_writer = os.path.join('third_party', 'closure', 'deps', 'depswriter.py')

  try:
    cmd_line = ['python', deps_writer] + deps_args
    shakaBuildHelpers.print_cmd_line(cmd_line)
    deps = subprocess.check_output(cmd_line)
    with open(os.path.join(base, 'dist', 'deps.js'), 'w') as f:
      f.write(deps)
    return 0
  except subprocess.CalledProcessError as e:
    return e.returncode
示例#13
0
    def build_raw(self, extra_opts):
        """Builds the files in |self.include| using the given extra Closure options.

    Args:
      extra_opts: An array of extra options to give to Closure.

    Returns:
      True on success; False on failure.
    """
        jar = os.path.join(shakaBuildHelpers.get_source_base(), "third_party", "closure", "compiler.jar")
        jar = shakaBuildHelpers.cygwin_safe_path(jar)
        files = [shakaBuildHelpers.cygwin_safe_path(f) for f in self.include]
        files.sort()

        try:
            cmd_line = ["java", "-jar", jar] + closure_opts + extra_opts + files
            shakaBuildHelpers.print_cmd_line(cmd_line)
            subprocess.check_call(cmd_line)
            return True
        except subprocess.CalledProcessError:
            print >> sys.stderr, "Build failed"
            return False
示例#14
0
def gen_deps(_):
    """Generates the uncompiled dependencies files."""
    print 'Generating Closure dependencies...'

    # Make the dist/ folder, ignore errors.
    base = shakaBuildHelpers.get_source_base()
    try:
        os.mkdir(os.path.join(base, 'dist'))
    except OSError:
        pass
    os.chdir(base)
    deps_writer = os.path.join('third_party', 'closure', 'deps',
                               'depswriter.py')

    try:
        cmd_line = [sys.executable or 'python', deps_writer] + deps_args
        shakaBuildHelpers.print_cmd_line(cmd_line)
        deps = subprocess.check_output(cmd_line)
        with open(os.path.join(base, 'dist', 'deps.js'), 'w') as f:
            f.write(deps)
        return 0
    except subprocess.CalledProcessError as e:
        return e.returncode