예제 #1
0
def checkComplete():
    """Checks whether the 'complete' build references every file.  This is used
  by the build script to ensure that every file is included in at least one
  build type.

  Returns:
    True on success, False on failure.
  """
    complete = build.Build()
    # Normally we don't need to include @core, but because we look at the build
    # object directly, we need to include it here.  When using main(), it will
    # call addCore which will ensure core is included.
    if not complete.parseBuild(['+@complete', '+@core'], os.getcwd()):
        print >> sys.stderr, 'Error parsing complete build'
        return False

    match = re.compile(r'.*\.js$')
    base = shakaBuildHelpers.getSourceBase()
    allFiles = shakaBuildHelpers.getAllFiles(os.path.join(base, 'lib'), match)
    missingFiles = set(allFiles) - complete.include

    if len(missingFiles) > 0:
        print >> sys.stderr, 'There are files missing from the complete build:'
        for missing in missingFiles:
            # Convert to a path relative to source base.
            print >> sys.stderr, '  ' + os.path.relpath(missing, base)
        return False
    return True
예제 #2
0
  def buildLibrary(self, name):
    """Builds Shaka Player using the files in |self.include|.

    Arguments:
      name - The name of the build.

    Returns:
      True on success; False on failure.
    """
    self._addCore()

    sourceBase = shakaBuildHelpers.getSourceBase()
    resultPrefix = shakaBuildHelpers.cygwinSafePath(
        os.path.join(sourceBase, 'dist', 'shaka-player.' + name))
    resultFile = resultPrefix + '.js'
    resultDebug = resultPrefix + '.debug.js'
    resultMap = resultPrefix + '.debug.map'

    opts = ['--create_source_map', resultMap, '--js_output_file', resultDebug]
    if not self.buildRaw(opts):
      return False

    shutil.copyfile(resultDebug, resultFile)

    # 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 open(resultDebug, 'a') as f:
      f.write('//# sourceMappingURL=shaka-player.' + name + '.debug.js')

    return True
예제 #3
0
def checkComplete():
  """Checks whether the 'complete' build references every file.  This is used
  by the build script to ensure that every file is included in at least one
  build type.

  Returns:
    True on success, False on failure.
  """
  complete = build.Build()
  # Normally we don't need to include @core, but because we look at the build
  # object directly, we need to include it here.  When using main(), it will
  # call addCore which will ensure core is included.
  if not complete.parseBuild(['+@complete', '+@core'], os.getcwd()):
    print >> sys.stderr, 'Error parsing complete build'
    return False

  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.getSourceBase()
  allFiles = shakaBuildHelpers.getAllFiles(os.path.join(base, 'lib'), match)
  missingFiles = set(allFiles) - complete.include

  if len(missingFiles) > 0:
    print >> sys.stderr, 'There are files missing from the complete build:'
    for missing in missingFiles:
      # Convert to a path relative to source base.
      print >> sys.stderr, '  ' + os.path.relpath(missing, base)
    return False
  return True
예제 #4
0
def process(text, options):
  """Decodes a JSON string containing source map data.

  Arguments:
    text - A JSON string containing source map data.
    options - An object containing the command-line options.
  """

  # The spec allows a map file to start with )]} to prevent javascript from
  # including it.
  if text.startswith(')]}\'\n') or text.startswith(')]}\n'):
      _, text = text.split('\n', 1)

  # Decode the JSON data and get the parts we need.
  data = json.loads(text)
  # Paths are relative to the source code root.
  base = shakaBuildHelpers.getSourceBase()
  fileLines = open(os.path.join(base, data['file'])).readlines()
  names = data['names']
  mappings = data['mappings']
  tokens = decodeMappings(mappings, names)
  sizes = processSizes(tokens, fileLines)

  # Print out one of the results.
  if options.printTokens:
    printTokens(tokens, fileLines, sizes)
  elif options.printSizes:
    printSizes(sizes)
  elif options.printDeps or options.isClass:
    temp = processDeps(tokens, fileLines, options.isClass)
    printDeps(temp, options.inDot)
예제 #5
0
def runTests(args):
  """Runs all the karma tests."""
  # Update node modules if needed.
  shakaBuildHelpers.updateNodeModules()

  # Generate dependencies required for the tests.
  if gendeps.genDeps([]) != 0:
    return 1

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

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

  # Get the browsers supported on the local system.
  browsers = _GetBrowsers()
  if not browsers:
    print >> sys.stderr, 'Unrecognized system', system
    return 1

  if len(args) == 0:
    # Run tests in all available browsers.
    cmdLine = cmd + ['--browsers', browsers]
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
  else:
    # Run with command-line arguments from the user.
    cmdLine = cmd + args
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
예제 #6
0
def checkHtmlLint():
    """Runs the HTML linter over the HTML files."""
    htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
    base = shakaBuildHelpers.getSourceBase()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    cmdLine = [htmlhint_path] + file_paths
    shakaBuildHelpers.printCmdLine(cmdLine)
    return (subprocess.call(cmdLine) == 0)
예제 #7
0
def getLintFiles():
  """Returns an array of absolute paths to all the files to run the linter
  over.
  """
  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.getSourceBase()
  def get(arg):
    return shakaBuildHelpers.getAllFiles(os.path.join(base, arg), match)
  return get('test') + get('lib') + get('externs') + get('demo')
예제 #8
0
def checkHtmlLint():
  """Runs the HTML linter over the HTML files."""
  htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
  base = shakaBuildHelpers.getSourceBase()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  cmdLine = [htmlhint_path] + file_paths
  shakaBuildHelpers.printCmdLine(cmdLine)
  return (subprocess.call(cmdLine) == 0)
예제 #9
0
def getLintFiles():
    """Returns an array of absolute paths to all the files to run the linter
  over.
  """
    match = re.compile(r'.*\.js$')
    base = shakaBuildHelpers.getSourceBase()

    def get(arg):
        return shakaBuildHelpers.getAllFiles(os.path.join(base, arg), match)

    return get('test') + get('lib') + get('externs') + get('demo')
예제 #10
0
    def buildLibrary(self, name, rebuild):
        """Builds Shaka Player using the files in |self.include|.

    Arguments:
      name - The name of the build.
      rebuild - True to rebuild, False to ignore if no changes are detected.

    Returns:
      True on success; False on failure.
    """
        self._addCore()

        # In the build files, we use '/' in the paths, however Windows uses '\'.
        # Although Windows supports both, the source mapping will not work.  So
        # use Linux-style paths for arguments.
        sourceBase = shakaBuildHelpers.getSourceBase().replace('\\', '/')

        resultPrefix = shakaBuildHelpers.cygwinSafePath(
            os.path.join(sourceBase, 'dist', 'shaka-player.' + name))
        resultFile = resultPrefix + '.js'
        resultDebug = resultPrefix + '.debug.js'
        resultMap = resultPrefix + '.debug.map'

        # Detect changes to the library and only build if changes have been made.
        if not rebuild and os.path.isfile(resultFile):
            buildTime = os.path.getmtime(resultFile)
            completeBuild = Build()
            if completeBuild.parseBuild(['+@complete'], os.getcwd()):
                completeBuild._addCore()
                # Get a list of files modified since the build file was.
                editedFiles = filter(lambda x: os.path.getmtime(x) > buildTime,
                                     completeBuild.include)
                if len(editedFiles) == 0:
                    print 'No changes detected, not building.  Use --force to override.'
                    return True

        opts = [
            '--create_source_map', resultMap, '--js_output_file', resultDebug,
            '--source_map_location_mapping', sourceBase + '|..'
        ]
        if not self.buildRaw(opts):
            return False

        shutil.copyfile(resultDebug, resultFile)

        # 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 open(resultDebug, 'a') as f:
            f.write('//# sourceMappingURL=shaka-player.' + name + '.debug.map')

        return True
예제 #11
0
  def buildLibrary(self, name, rebuild):
    """Builds Shaka Player using the files in |self.include|.

    Arguments:
      name - The name of the build.
      rebuild - True to rebuild, False to ignore if no changes are detected.

    Returns:
      True on success; False on failure.
    """
    self._addCore()

    # In the build files, we use '/' in the paths, however Windows uses '\'.
    # Although Windows supports both, the source mapping will not work.  So
    # use Linux-style paths for arguments.
    sourceBase = shakaBuildHelpers.getSourceBase().replace('\\', '/')

    resultPrefix = shakaBuildHelpers.cygwinSafePath(
        os.path.join(sourceBase, 'dist', 'shaka-player.' + name))
    resultFile = resultPrefix + '.js'
    resultDebug = resultPrefix + '.debug.js'
    resultMap = resultPrefix + '.debug.map'

    # Detect changes to the library and only build if changes have been made.
    if not rebuild and os.path.isfile(resultFile):
      buildTime = os.path.getmtime(resultFile)
      completeBuild = Build()
      if completeBuild.parseBuild(['+@complete'], os.getcwd()):
        completeBuild._addCore()
        # Get a list of files modified since the build file was.
        editedFiles = filter(lambda x: os.path.getmtime(x) > buildTime,
                             completeBuild.include)
        if len(editedFiles) == 0:
          print 'No changes detected, not building.  Use --force to override.'
          return True

    opts = ['--create_source_map', resultMap, '--js_output_file', resultDebug,
            '--source_map_location_mapping', sourceBase + '|..']
    if not self.buildRaw(opts):
      return False

    shutil.copyfile(resultDebug, resultFile)

    # 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 open(resultDebug, 'a') as f:
      f.write('//# sourceMappingURL=shaka-player.' + name + '.debug.map')

    return True
예제 #12
0
def buildDocs(_):
    base = shakaBuildHelpers.getSourceBase()
    shutil.rmtree(os.path.join(base, 'docs', 'api'), ignore_errors=True)
    os.chdir(base)

    if shakaBuildHelpers.isWindows() or shakaBuildHelpers.isCygwin():
        # 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')

    cmdLine = [jsdoc, '-c', 'jsdoc.conf.json']
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
예제 #13
0
def checkLint():
  """Runs the linter over the library files."""
  jsdoc3_tags = ','.join([
      'static', 'summary', 'namespace', 'event', 'description', 'property',
      'fires', 'listens', 'example', 'exportDoc'])
  args = ['--nobeep', '--custom_jsdoc_tags', jsdoc3_tags, '--strict']
  base = shakaBuildHelpers.getSourceBase()
  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.
  cmdLine = ['python', cmd] + args + getLintFiles()
  shakaBuildHelpers.printCmdLine(cmdLine)
  return (subprocess.call(cmdLine) == 0)
예제 #14
0
def checkHtmlLint():
    """Runs the HTML linter over the HTML files.
  Skipped if htmlhint is not available.
  """
    htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
    if not os.path.exists(htmlhint_path):
        return True
    print 'Running htmlhint...'

    base = shakaBuildHelpers.getSourceBase()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    cmdLine = [htmlhint_path] + file_paths
    shakaBuildHelpers.printCmdLine(cmdLine)
    return (subprocess.call(cmdLine) == 0)
예제 #15
0
def buildDocs(_):
  base = shakaBuildHelpers.getSourceBase()
  shutil.rmtree(os.path.join(base, 'docs', 'api'), ignore_errors=True)
  os.chdir(base)

  if shakaBuildHelpers.isWindows() or shakaBuildHelpers.isCygwin():
    # 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')

  cmdLine = [jsdoc, '-c', 'jsdoc.conf.json']
  shakaBuildHelpers.printCmdLine(cmdLine)
  return subprocess.call(cmdLine)
예제 #16
0
def checkHtmlLint():
  """Runs the HTML linter over the HTML files.
  Skipped if htmlhint is not available.
  """
  htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
  if not os.path.exists(htmlhint_path):
    return True
  print 'Running htmlhint...'

  base = shakaBuildHelpers.getSourceBase()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  cmdLine = [htmlhint_path] + file_paths
  shakaBuildHelpers.printCmdLine(cmdLine)
  return (subprocess.call(cmdLine) == 0)
예제 #17
0
def checkLint():
    """Runs the linter over the library files."""
    jsdoc3_tags = ','.join([
        'static', 'summary', 'namespace', 'event', 'description', 'property',
        'fires', 'listens', 'example', 'exportDoc'
    ])
    args = ['--nobeep', '--custom_jsdoc_tags', jsdoc3_tags, '--strict']
    base = shakaBuildHelpers.getSourceBase()
    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.
    cmdLine = ['python', cmd] + args + getLintFiles()
    shakaBuildHelpers.printCmdLine(cmdLine)
    return (subprocess.call(cmdLine) == 0)
예제 #18
0
    def _addCore(self):
        """Adds the core library."""
        # Add externs and closure dependencies.
        sourceBase = shakaBuildHelpers.getSourceBase()
        match = re.compile(r'.*\.js$')
        self.include = self.include | set(
            shakaBuildHelpers.getAllFiles(os.path.join(
                sourceBase, 'externs'), match) + shakaBuildHelpers.getAllFiles(
                    os.path.join(sourceBase, 'third_party', 'closure'), match))

        # Check that there are no files in 'core' that are removed
        coreBuild = Build()
        coreBuild.parseBuild(['+@core'], os.getcwd())
        coreFiles = coreBuild.include
        if len(self.exclude & coreFiles) > 0:
            print >> sys.stderr, 'Cannot exclude files from core'
        self.include = self.include | coreFiles
예제 #19
0
  def _addCore(self):
    """Adds the core library."""
    # Add externs and closure dependencies.
    sourceBase = shakaBuildHelpers.getSourceBase()
    match = re.compile(r'.*\.js$')
    self.include = self.include | set(
        shakaBuildHelpers.getAllFiles(
            os.path.join(sourceBase, 'externs'), match) +
        shakaBuildHelpers.getAllFiles(
            os.path.join(sourceBase, 'third_party', 'closure'), match))

    # Check that there are no files in 'core' that are removed
    coreBuild = Build()
    coreBuild.parseBuild(['+@core'], os.getcwd())
    coreFiles = coreBuild.include
    if len(self.exclude & coreFiles) > 0:
      print >> sys.stderr, 'Cannot exclude files from core'
    self.include = self.include | coreFiles
예제 #20
0
def checkTests():
  """Runs an extra compile pass over the test code to check for type errors.

  Returns:
    True on success, False on failure.
  """
  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.getSourceBase()
  def get(*args):
    return shakaBuildHelpers.getAllFiles(os.path.join(base, *args), match)
  files = (get('lib') + get('externs') + get('test') + get('demo') +
      get('third_party', 'closure'))
  testBuild = build.Build(set(files))

  # Ignore missing goog.require since we assume the whole library is
  # already included.
  opts = ['--jscomp_off=missingRequire', '--checks-only', '-O', 'SIMPLE']
  return testBuild.buildRaw(opts)
예제 #21
0
def runTests(args):
  """Runs all the karma tests."""
  # Update node modules if needed.
  shakaBuildHelpers.updateNodeModules()

  # Generate dependencies and compile library.
  # This is required for the tests.
  print 'Generating dependencies...'
  if gendeps.genDeps([]) != 0:
    return 1
  print 'Compiling the library...'
  if build.main([]) != 0:
    return 1

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

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

  # Get the browsers supported on the local system.
  browsers = _GetBrowsers()
  if not browsers:
    print >> sys.stderr, 'Unrecognized system', system
    return 1

  print 'Starting tests...'
  if len(args) == 0:
    # Run tests in all available browsers.
    print 'Running with platform default:', '--browsers', browsers
    cmdLine = cmd + ['--browsers', browsers]
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
  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.'
    cmdLine = cmd + args
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
예제 #22
0
def genDeps(_):
  # Make the dist/ folder, ignore errors.
  base = shakaBuildHelpers.getSourceBase()
  try:
    os.mkdir(os.path.join(base, 'dist'))
  except OSError:
    pass
  os.chdir(base)
  depsWriter = os.path.join('third_party', 'closure', 'deps', 'depswriter.py')

  try:
    cmdLine = ['python', depsWriter] + depsArgs
    shakaBuildHelpers.printCmdLine(cmdLine)
    deps = subprocess.check_output(cmdLine)
    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
예제 #23
0
def genDeps(_):
    # Make the dist/ folder, ignore errors.
    base = shakaBuildHelpers.getSourceBase()
    try:
        os.mkdir(os.path.join(base, 'dist'))
    except OSError:
        pass
    os.chdir(base)
    depsWriter = os.path.join('third_party', 'closure', 'deps',
                              'depswriter.py')

    try:
        cmdLine = ['python', depsWriter] + depsArgs
        shakaBuildHelpers.printCmdLine(cmdLine)
        deps = subprocess.check_output(cmdLine)
        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
예제 #24
0
def checkTests():
    """Runs an extra compile pass over the test code to check for type errors.

  Returns:
    True on success, False on failure.
  """
    match = re.compile(r'.*\.js$')
    base = shakaBuildHelpers.getSourceBase()

    def get(*args):
        return shakaBuildHelpers.getAllFiles(os.path.join(base, *args), match)

    files = (get('lib') + get('externs') + get('test') + get('demo') +
             get('third_party', 'closure'))
    testBuild = build.Build(set(files))

    # Ignore missing goog.require since we assume the whole library is
    # already included.
    opts = ['--jscomp_off=missingRequire', '--checks-only', '-O', 'SIMPLE']
    return testBuild.buildRaw(opts)
예제 #25
0
    def buildRaw(self, extra_opts):
        """Builds the files in |self.include| using the given extra Closure options.

    Arguments:
      extra_opts - An array of extra options to give to Closure.

    Returns:
      True on success; False on failure.
    """
        jar = os.path.join(shakaBuildHelpers.getSourceBase(), 'third_party',
                           'closure', 'compiler.jar')
        jar = shakaBuildHelpers.cygwinSafePath(jar)
        files = map(shakaBuildHelpers.cygwinSafePath, list(self.include))

        try:
            cmdLine = ['java', '-jar', jar] + closure_opts + extra_opts + files
            shakaBuildHelpers.printCmdLine(cmdLine)
            subprocess.check_call(cmdLine)
            return True
        except subprocess.CalledProcessError:
            print >> sys.stderr, 'Build failed'
            return False
예제 #26
0
  def buildRaw(self, extra_opts):
    """Builds the files in |self.include| using the given extra Closure options.

    Arguments:
      extra_opts - An array of extra options to give to Closure.

    Returns:
      True on success; False on failure.
    """
    jar = os.path.join(shakaBuildHelpers.getSourceBase(),
        'third_party', 'closure', 'compiler.jar')
    jar = shakaBuildHelpers.cygwinSafePath(jar)
    files = map(shakaBuildHelpers.cygwinSafePath, list(self.include))

    try:
      cmdLine = ['java', '-jar', jar] + closure_opts + extra_opts + files
      shakaBuildHelpers.printCmdLine(cmdLine)
      subprocess.check_call(cmdLine)
      return True
    except subprocess.CalledProcessError:
      print >> sys.stderr, 'Build failed'
      return False
예제 #27
0
  def _getBuildFilePath(self, name, root):
    """Gets the full path to a build file, if it exists.  Returns None if not.

    Arguments:
      name - The string name to check.

    Returns:
      The full path to the build file.
    """
    sourceBase = shakaBuildHelpers.getSourceBase()
    localPath = os.path.join(root, name)
    buildPath = os.path.join(sourceBase, 'build', 'types', name)
    if (os.path.isfile(localPath) and os.path.isfile(buildPath)
        and localPath != buildPath):
      print >> sys.stderr, 'Build file "%s" is ambiguous' % name
      return None
    elif os.path.isfile(localPath):
      return localPath
    elif os.path.isfile(buildPath):
      return buildPath
    else:
      print >> sys.stderr, 'Build file not found: ' + name
      return None
예제 #28
0
    def _getBuildFilePath(self, name, root):
        """Gets the full path to a build file, if it exists.  Returns None if not.

    Arguments:
      name - The string name to check.

    Returns:
      The full path to the build file.
    """
        sourceBase = shakaBuildHelpers.getSourceBase()
        localPath = os.path.join(root, name)
        buildPath = os.path.join(sourceBase, 'build', 'types', name)
        if (os.path.isfile(localPath) and os.path.isfile(buildPath)
                and localPath != buildPath):
            print >> sys.stderr, 'Build file "%s" is ambiguous' % name
            return None
        elif os.path.isfile(localPath):
            return localPath
        elif os.path.isfile(buildPath):
            return buildPath
        else:
            print >> sys.stderr, 'Build file not found: ' + name
            return None
예제 #29
0
def changelogVersion():
  """Gets the version of the library from the CHANGELOG."""
  path = os.path.join(shakaBuildHelpers.getSourceBase(), 'CHANGELOG.md')
  with open(path, 'r') as f:
    match = re.search(r'## (.*) \(', f.read())
    return match.group(1) if match else ''
예제 #30
0
def playerVersion():
  """Gets the version of the library from player.js."""
  path = os.path.join(shakaBuildHelpers.getSourceBase(), 'lib', 'player.js')
  with open(path, 'r') as f:
    match = re.search(r'goog\.define\(\'GIT_VERSION\', \'(.*)\'\)', f.read())
    return match.group(1) if match else ''
예제 #31
0
    # So since we can't use the new annotations, we have to ignore complaints
    # about the old one.
    '--jscomp_off=deprecatedAnnotations',

    # 'analyzerChecks' complains about countless instances of implicitly nullable
    # types, plus a few other issues.  Even the closure library doesn't pass
    # these checks, and the implicit nullability check in particular is over-
    # zealous and unhelpful.  So we disable the whole category of
    # 'analyzerChecks'.
    '--jscomp_off=analyzerChecks',

    '--extra_annotation_name=listens',
    '--extra_annotation_name=exportDoc',

    '--conformance_configs', '%s/build/conformance.textproto' % \
      shakaBuildHelpers.cygwinSafePath(shakaBuildHelpers.getSourceBase()),

    '-O', 'ADVANCED',
    '--generate_exports',
    '--output_wrapper_file=%s/build/wrapper.template.js' % \
      shakaBuildHelpers.cygwinSafePath(shakaBuildHelpers.getSourceBase()),

    '-D', 'COMPILED=true',
    '-D', 'goog.DEBUG=false',
    '-D', 'goog.STRICT_MODE_COMPATIBLE=true',
    '-D', 'goog.ENABLE_DEBUG_LOADER=false',
    '-D', 'goog.asserts.ENABLE_ASSERTS=false',
    '-D', 'shaka.log.MAX_LOG_LEVEL=0',
    '-D', 'GIT_VERSION="%s"' % shakaBuildHelpers.calculateVersion()
]
예제 #32
0
  # So since we can't use the new annotations, we have to ignore complaints
  # about the old one.
  '--jscomp_off=deprecatedAnnotations',

  # 'analyzerChecks' complains about countless instances of implicitly nullable
  # types, plus a few other issues.  Even the closure library doesn't pass
  # these checks, and the implicit nullability check in particular is over-
  # zealous and unhelpful.  So we disable the whole category of
  # 'analyzerChecks'.
  '--jscomp_off=analyzerChecks',

  '--extra_annotation_name=listens',
  '--extra_annotation_name=exportDoc',

  '--conformance_configs', '%s/build/conformance.textproto' % \
      shakaBuildHelpers.cygwinSafePath(shakaBuildHelpers.getSourceBase()),

  '-O', 'ADVANCED',
  '--generate_exports',
  '--output_wrapper_file=%s/build/wrapper.template.js' % \
      shakaBuildHelpers.cygwinSafePath(shakaBuildHelpers.getSourceBase()),

  '-D', 'COMPILED=true',
  '-D', 'goog.DEBUG=false',
  '-D', 'goog.STRICT_MODE_COMPATIBLE=true',
  '-D', 'goog.ENABLE_DEBUG_LOADER=false',
  '-D', 'goog.asserts.ENABLE_ASSERTS=false',
  '-D', 'shaka.log.MAX_LOG_LEVEL=0',
  '-D', 'GIT_VERSION="%s"' % shakaBuildHelpers.calculateVersion()
]
예제 #33
0
def main(args):
  options = Options()
  doneArgs = False
  name = 'shaka-player.compiled.debug.map'

  # Process the command-line arguments.
  for arg in args:
    if doneArgs or arg[0] != '-':
      name = arg
    elif arg == '-f' or arg == '--function-deps':
      options.printDeps = True
    elif arg == '-t' or arg == '--all-tokens':
      options.printTokens = True
    elif arg == '-s' or arg == '--function-sizes':
      options.printSizes = True
    elif arg == '-c' or arg == '--class-deps':
      options.isClass = True
    elif arg == '-d' or arg == '--dot-format':
      options.inDot = True
    elif arg == '--':
      doneArgs = True
    elif arg == '-h' or arg == '--help':
      printHelp()
      return 0
    else:
      print >> sys.stderr, 'Unrecognized argument:', arg
      printHelp()
      return 1

  # Try to find the file
  if not os.path.isfile(name):
    # Get the source code base directory
    base = shakaBuildHelpers.getSourceBase()

    # Supports the following searches:
    # * File name given, map in dist/
    # * Type given, map in working directory
    # * Type given, map in dist/
    if os.path.isfile(os.path.join(base, 'dist' , name)):
      name = os.path.join(base, 'dist', name)
    elif os.path.isfile(
          os.path.join('shaka-player.' + name + '.debug.map')):
      name = os.path.join('shaka-player.' + name + '.debug.map')
    elif os.path.isfile(
          os.path.join(base, 'dist', 'shaka-player.' + name + '.debug.map')):
      name = os.path.join(base, 'dist', 'shaka-player.' + name + '.debug.map')
    else:
      print >> sys.stderr, name, 'not found; build Shaka first.'
      return 1

  # Verify arguments are correct.
  if (options.printSizes + options.printDeps + options.printTokens +
      options.isClass) != 1:
    print >> sys.stderr, 'Must include exactly one output type.'
    printHelp()
    return 1
  elif options.inDot and not options.printDeps and not options.isClass:
    print >> sys.stderr, '--dot-format only valid with --function-deps or \
--class-deps.'
    return 1
  else:
    process(open(name).read(), options)
    return 0