Exemple #1
0
def _get_browsers():
    """Uses the platform name to configure which browsers will be tested."""
    browsers = None
    if shakaBuildHelpers.is_linux():
        # For MP4 support on Linux Firefox, install gstreamer1.0-libav.
        # Opera on Linux only supports MP4 for Ubuntu 15.04+, so it is not in the
        # default list of browsers for Linux at this time.
        browsers = "Chrome,Firefox"
    elif shakaBuildHelpers.is_darwin():
        browsers = "Chrome,Firefox,Safari"
    elif shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
        browsers = "Chrome,Firefox,IE"
    return browsers
Exemple #2
0
def _get_browsers():
    """Uses the platform name to configure which browsers will be tested."""
    browsers = None
    if shakaBuildHelpers.is_linux():
        # For MP4 support on Linux Firefox, install gstreamer1.0-libav.
        # Opera on Linux only supports MP4 for Ubuntu 15.04+, so it is not in the
        # default list of browsers for Linux at this time.
        browsers = 'Chrome,Firefox'
    elif shakaBuildHelpers.is_darwin():
        browsers = 'Chrome,Firefox,Safari'
    elif shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
        browsers = 'Chrome,Firefox,IE'
    return browsers
Exemple #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)
Exemple #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)
Exemple #5
0
def _GetDefaultBrowsers():
    """Use the platform name to get which browsers can be tested."""

    if shakaBuildHelpers.is_linux():
        # For MP4 support on Linux Firefox, install gstreamer1.0-libav.
        # Opera on Linux only supports MP4 for Ubuntu 15.04+, so it is not in the
        # default list of browsers for Linux at this time.
        return ['Chrome', 'Firefox']

    if shakaBuildHelpers.is_darwin():
        return ['Chrome', 'Firefox', 'Safari']

    if shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
        return ['Chrome', 'Firefox', 'IE']

    raise Error('Unrecognized system: %s' % platform.uname()[0])
Exemple #6
0
def _GetDefaultBrowsers():
  """Use the platform name to get which browsers can be tested."""

  if shakaBuildHelpers.is_linux():
    # For MP4 support on Linux Firefox, install gstreamer1.0-libav.
    # Opera on Linux only supports MP4 for Ubuntu 15.04+, so it is not in the
    # default list of browsers for Linux at this time.
    return ['Chrome','Firefox']

  if shakaBuildHelpers.is_darwin():
    return ['Chrome','Firefox','Safari']

  if shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
    return ['Chrome','Firefox','IE']

  raise Error('Unrecognized system: %s' % platform.uname()[0])
Exemple #7
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']
  return shakaBuildHelpers.execute_get_code(cmd_line)
Exemple #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']
  return shakaBuildHelpers.execute_get_code(cmd_line)
Exemple #9
0
    def compile(self, options, force=False):
        """Builds the files in |self.source_files| using the given Closure
    command-line options.

    Args:
      options: An array of options to give to Closure.
      force: Generate the output even if the inputs have not changed.

    Returns:
      True on success; False on failure.
    """
        if not force:
            if self.timestamp_file:
                if not _must_build(self.timestamp_file, self.source_files):
                    return True
            else:
                if not _must_build(self.compiled_js_path, self.source_files):
                    return True

        jar = _get_source_path(
            'node_modules/google-closure-compiler-java/compiler.jar')

        output_options = []
        if self.output_compiled_bundle:
            output_options += [
                '--js_output_file',
                self.compiled_js_path,
            ]

            if self.add_source_map:
                source_base = _get_source_path('')

                output_options += [
                    '--create_source_map',
                    self.source_map_path,
                    # This uses a simple string replacement to create relative paths.
                    # "source|replacement".
                    '--source_map_location_mapping',
                    source_base + '|../',
                ]
                if shakaBuildHelpers.is_windows(
                ) or shakaBuildHelpers.is_cygwin():
                    output_options += [
                        # On Windows, the source map needs to use '/' for paths, so we
                        # need to have this mapping so it creates the correct relative
                        # paths.  For some reason, we still need the mapping above for
                        # other parts of the source map.
                        '--source_map_location_mapping',
                        source_base.replace('\\', '/') + '|../',
                    ]

            if self.add_wrapper:
                output_options += self._prepare_wrapper()

        cmd_line = ['java', '-jar', jar] + output_options + options
        cmd_line += self.source_files

        if shakaBuildHelpers.execute_get_code(cmd_line) != 0:
            logging.error('Build failed')
            return False

        if self.output_compiled_bundle and self.add_source_map:
            # Add a special source-mapping comment so that Chrome and Firefox can map
            # line and character numbers from the compiled library back to the
            # original source locations.
            with shakaBuildHelpers.open_file(self.compiled_js_path, 'a') as f:
                f.write('//# sourceMappingURL=%s' %
                        os.path.basename(self.source_map_path))

        if self.timestamp_file:
            _update_timestamp(self.timestamp_file)

        return True