示例#1
0
    def RunCommand(self, karma_conf):
        """Build a command and send it to Karma for execution.

       Uses |self.parsed_args| and |self.karma_config| to build and run a Karma
       command.
    """
        if self.parsed_args.use_xvfb and not shakaBuildHelpers.is_linux():
            logging.error('xvfb can only be used on Linux')
            return 1

        if not shakaBuildHelpers.update_node_modules():
            logging.error('Failed to update node modules')
            return 1

        karma = shakaBuildHelpers.get_node_binary('karma')
        cmd = ['xvfb-run', '--auto-servernum'
               ] if self.parsed_args.use_xvfb else []
        cmd += karma + ['start']
        cmd += [karma_conf] if karma_conf else []
        cmd += ['--settings', json.dumps(self.karma_config)]

        # There is no need to print a status here as the gendep and build
        # calls will print their own status updates.
        if self.parsed_args.build:
            if gendeps.main([]) != 0:
                logging.error('Failed to generate project dependencies')
                return 1

            if build.main(['--force'] if self.parsed_args.force else []) != 0:
                logging.error('Failed to build project')
                return 1

        # Before Running the command, print the command.
        if self.parsed_args.print_command:
            logging.info('Karma Run Command')
            logging.info('%s', cmd)

        # Run the command.
        results = []
        for run in range(self.parsed_args.runs):
            logging.info('Running test (%d / %d, %d failed so far)...',
                         run + 1, self.parsed_args.runs,
                         len(results) - results.count(0))
            results.append(shakaBuildHelpers.execute_get_code(cmd))

        # Print a summary of the results.
        if self.parsed_args.runs > 1:
            logging.info('All runs completed. %d / %d runs passed.',
                         results.count(0), len(results))
            logging.info('Results (exit code): %r', results)
        else:
            logging.info('Run complete')
            logging.info('Result (exit code): %d', results[0])

        return 0 if all(result == 0 for result in results) else 1
示例#2
0
  def RunCommand(self, karma_conf):
    """Build a command and send it to Karma for execution.

       Uses |self.parsed_args| and |self.karma_config| to build and run a Karma
       command.
    """
    if self.parsed_args.use_xvfb and not shakaBuildHelpers.is_linux():
      logging.error('xvfb can only be used on Linux')
      return 1

    if not shakaBuildHelpers.update_node_modules():
      logging.error('Failed to update node modules')
      return 1

    karma = shakaBuildHelpers.get_node_binary('karma')
    cmd = ['xvfb-run', '--auto-servernum'] if self.parsed_args.use_xvfb else []
    cmd += karma + ['start']
    cmd += [karma_conf] if karma_conf else []
    cmd += ['--settings', json.dumps(self.karma_config)]

    # There is no need to print a status here as the gendep and build
    # calls will print their own status updates.
    if self.parsed_args.build:
      if gendeps.main([]) != 0:
        logging.error('Failed to generate project dependencies')
        return 1

      if build.main(['--force'] if self.parsed_args.force else []) != 0:
        logging.error('Failed to build project')
        return 1

    # Before Running the command, print the command.
    if self.parsed_args.print_command:
      logging.info('Karma Run Command')
      logging.info('%s', cmd)

    # Run the command.
    results = []
    for run in range(self.parsed_args.runs):
      logging.info('Running test (%d / %d)...', run + 1, self.parsed_args.runs)
      results.append(shakaBuildHelpers.execute_get_code(cmd))

    # Print a summary of the results.
    if self.parsed_args.runs > 1:
      logging.info('All runs completed. %d / %d runs passed.',
                   results.count(0),
                   len(results))
      logging.info('Results (exit code): %r', results)
    else:
      logging.info('Run complete')
      logging.info('Result (exit code): %d', results[0])

    return 0 if all(result == 0 for result in results) else 1
示例#3
0
def main(args):
  parser = argparse.ArgumentParser(
      description='User facing build script for building the Shaka'
                  ' Player Project.')

  parser.add_argument(
      '--locales',
      type=str,
      nargs='+',
      default=generateLocalizations.DEFAULT_LOCALES,
      help='The list of locales to compile in (default %(default)r)')

  parser.add_argument(
      '--fix',
      help='Automatically fix style violations.',
      action='store_true')

  parser.add_argument(
      '--force',
      '-f',
      help='Force building the library even if no files have changed.',
      action='store_true')

  parser.add_argument(
      '--debug',
      help='Limit which build types to build. Will at least build the debug '
           'version.',
      action='store_true')

  parser.add_argument(
      '--release',
      help='Limit which build types to build. Will at least build the '
           'release version.',
      action='store_true')

  parsed_args = parser.parse_args(args)

  # Make the dist/ folder, ignore errors.
  base = shakaBuildHelpers.get_source_base()
  try:
    os.mkdir(os.path.join(base, 'dist'))
  except OSError:
    pass

  # Generate localizations before running gendeps, so the output is available
  # to the deps system.
  # TODO(#1858): It might be time to look at a third-party build system.
  localizations = compiler.GenerateLocalizations(parsed_args.locales)
  if not localizations.generate(parsed_args.force):
    return 1

  if gendeps.main([]) != 0:
    return 1

  check_args = []
  if parsed_args.fix:
    check_args += ['--fix']
  if parsed_args.force:
    check_args += ['--force']
  if check.main(check_args) != 0:
    return 1

  docs_args = []
  if parsed_args.force:
    docs_args += ['--force']
  if docs.main(docs_args) != 0:
    return 1

  if not compile_less('ui', 'controls', parsed_args):
    return 1;
  if not compile_less('demo', 'demo', parsed_args):
    return 1

  build_args_with_ui = ['--name', 'ui', '+@complete']
  build_args_with_ui += ['--locales'] + parsed_args.locales
  build_args_without_ui = ['--name', 'compiled', '+@complete', '-@ui']

  if parsed_args.force:
    build_args_with_ui += ['--force']
    build_args_without_ui += ['--force']

  # Create the list of build modes to build with. If the list is empty
  # by the end, then populate it with every mode.
  modes = []
  modes += ['debug'] if parsed_args.debug else []
  modes += ['release'] if parsed_args.release else []

  # If --debug or --release are not given, build with everything.
  if not modes:
    modes += ['debug', 'release']

  for mode in modes:
    # Complete build includes the UI library, but it is optional and player lib
    # should build and work without it as well.
    # First, build the full build (UI included) and then build excluding UI.
    for build_args in [build_args_with_ui, build_args_without_ui]:
      if build.main(build_args + ['--mode', mode]) != 0:
        return 1

    is_debug = mode == 'debug'
    if not apps.build_all(parsed_args.force, is_debug):
      return 1

  return 0
示例#4
0
def main(args):
  parser = argparse.ArgumentParser(
      description='User facing build script for building the Shaka'
                  ' Player Project.')

  parser.add_argument(
      '--locales',
      type=str,
      nargs='+',
      default=generateLocalizations.DEFAULT_LOCALES,
      help='The list of locales to compile in (default %(default)r)')

  parser.add_argument(
      '--fix',
      help='Automatically fix style violations.',
      action='store_true')

  parser.add_argument(
      '--force',
      '-f',
      help='Force building the library even if no files have changed.',
      action='store_true')

  parser.add_argument(
      '--debug',
      help='Limit which build types to build. Will at least build the debug '
           'version.',
      action='store_true')

  parser.add_argument(
      '--release',
      help='Limit which build types to build. Will at least build the '
           'release version.',
      action='store_true')

  parsed_args = parser.parse_args(args)

  # Make the dist/ folder, ignore errors.
  base = shakaBuildHelpers.get_source_base()
  try:
    os.mkdir(os.path.join(base, 'dist'))
  except OSError:
    pass

  # Generate localizations before running gendeps, so the output is available
  # to the deps system.
  # TODO(#1858): It might be time to look at a third-party build system.
  localizations = compiler.GenerateLocalizations(parsed_args.locales)
  if not localizations.generate(parsed_args.force):
    return 1

  if gendeps.main([]) != 0:
    return 1

  check_args = []
  if parsed_args.fix:
    check_args += ['--fix']
  if parsed_args.force:
    check_args += ['--force']
  if check.main(check_args) != 0:
    return 1

  docs_args = []
  if parsed_args.force:
    docs_args += ['--force']
  if docs.main(docs_args) != 0:
    return 1

  if not compile_less('ui', 'controls', parsed_args):
    return 1;
  # if not compile_less('demo', 'demo', parsed_args):
  #   return 1

  build_args_with_ui = ['--name', 'ui', '+@complete']
  build_args_with_ui += ['--locales'] + parsed_args.locales
  build_args_without_ui = ['--name', 'compiled', '+@complete', '-@ui']

  if parsed_args.force:
    build_args_with_ui += ['--force']
    build_args_without_ui += ['--force']

  # Create the list of build modes to build with. If the list is empty
  # by the end, then populate it with every mode.
  modes = []
  modes += ['debug'] if parsed_args.debug else []
  modes += ['release'] if parsed_args.release else []

  # If --debug or --release are not given, build with everything.
  if not modes:
    modes += ['debug', 'release']

  for mode in modes:
    # Complete build includes the UI library, but it is optional and player lib
    # should build and work without it as well.
    # First, build the full build (UI included) and then build excluding UI.
    for build_args in [build_args_with_ui, build_args_without_ui]:
      if build.main(build_args + ['--mode', mode]) != 0:
        return 1

    is_debug = mode == 'debug'
    if not apps.build_all(parsed_args.force, is_debug):
      return 1

  return 0
示例#5
0
def main(args):
    parser = argparse.ArgumentParser(
        description='User facing build script for building the Shaka'
        ' Player Project.')

    parser.add_argument('--fix',
                        help='Automatically fix style violations.',
                        action='store_true')

    parser.add_argument(
        '--force',
        '-f',
        help='Force building the library even if no files have changed.',
        action='store_true')

    parser.add_argument(
        '--debug',
        help='Limit which build types to build. Will at least build the debug '
        'version.',
        action='store_true')

    parser.add_argument(
        '--release',
        help='Limit which build types to build. Will at least build the '
        'release version.',
        action='store_true')

    parsed_args = parser.parse_args(args)

    if gendeps.main([]) != 0:
        return 1

    check_args = []
    if parsed_args.fix:
        check_args += ['--fix']
    if parsed_args.force:
        check_args += ['--force']
    if check.main(check_args) != 0:
        return 1

    docs_args = []
    if parsed_args.force:
        docs_args += ['--force']
    if docs.main(docs_args) != 0:
        return 1

    src = os.path.join(shakaBuildHelpers.get_source_base(), 'ui',
                       'controls.less')
    output = os.path.join(shakaBuildHelpers.get_source_base(), 'dist',
                          'controls.css')
    less = compiler.Less([src], output)
    if not less.compile(parsed_args.force):
        return 1

    build_args_with_ui = ['--name', 'ui', '+@complete']
    build_args_without_ui = ['--name', 'compiled', '+@complete', '-@ui']

    if parsed_args.force:
        build_args_with_ui += ['--force']
        build_args_without_ui += ['--force']

    # Create the list of build modes to build with. If the list is empty
    # by the end, then populate it with every mode.
    modes = []
    modes += ['debug'] if parsed_args.debug else []
    modes += ['release'] if parsed_args.release else []

    # If --debug or --release are not given, build with everything.
    if not modes:
        modes += ['debug', 'release']

    for mode in modes:
        # Complete build includes the UI library, but it is optional and player lib
        # should build and work without it as well.
        # First, build the full build (UI included) and then build excluding UI.
        for build_args in [build_args_with_ui, build_args_without_ui]:
            if build.main(build_args + ['--mode', mode]) != 0:
                return 1

        is_debug = mode == 'debug'
        if not apps.build_all(parsed_args.force, is_debug):
            return 1

    return 0