• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shakaBuildHelpers.get_source_base函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shakaBuildHelpers.get_source_base函数的典型用法代码示例。如果您正苦于以下问题:Python get_source_base函数的具体用法?Python get_source_base怎么用?Python get_source_base使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_source_base函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: compile_demo

def compile_demo(rebuild, is_debug):
  """Compile the demo application.

  Args:
    rebuild: 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')

  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.get_source_base()
  def get(*args):
    return shakaBuildHelpers.get_all_files(os.path.join(base, *args), match)

  files = set(get('demo') + get('externs')) - set(get('demo/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'))
  # Add in the generated externs, so that the demo compilation knows the
  # definitions of the library APIs.
  extern_name = ('shaka-player.compiled.debug.externs.js' if is_debug
                 else 'shaka-player.compiled.externs.js')
  files.add(os.path.join(base, 'dist', extern_name))

  demo_build = Build(files)

  name = 'demo.compiled' + ('.debug' if is_debug else '')
  result_file, result_map = compute_output_files(name)

  # Don't build if we don't have to.
  if not rebuild and not demo_build.should_build(result_file):
    return True

  source_base = shakaBuildHelpers.get_source_base().replace('\\', '/')
  closure_opts = common_closure_opts + debug_closure_opts
  closure_opts += [
      # Ignore missing goog.require since we assume the whole library is
      # already included.
      '--jscomp_off=missingRequire', '--jscomp_off=strictMissingRequire',
      '--create_source_map', result_map, '--js_output_file', result_file,
      '--source_map_location_mapping', source_base + '|..',
      '-D', 'COMPILED=true',
  ]

  if not demo_build.build_raw(closure_opts):
    return False

  demo_build.add_source_map(result_file, result_map)
  return True
开发者ID:xzhan96,项目名称:xzhan96.github.io,代码行数:56,代码来源:build.py


示例2: compile_receiver

def compile_receiver(rebuild, is_debug):
  """Compile the cast receiver application.

  Args:
    rebuild: 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')

  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.get_source_base()
  def get(*args):
    return shakaBuildHelpers.get_all_files(os.path.join(base, *args), match)

  files = set(get('demo/common') + get('demo/cast_receiver') + get('externs'))
  # Add in the generated externs, so that the receiver compilation knows the
  # definitions of the library APIs.
  extern_name = ('shaka-player.compiled.debug.externs.js' if is_debug
                 else 'shaka-player.compiled.externs.js')
  files.add(os.path.join(base, 'dist', extern_name))

  receiver_build = Build(files)

  name = 'receiver.compiled' + ('.debug' if is_debug else '')
  result_file, result_map = compute_output_files(name)

  # Don't build if we don't have to.
  if not rebuild and not receiver_build.should_build(result_file):
    return True

  source_base = shakaBuildHelpers.get_source_base().replace('\\', '/')
  closure_opts = common_closure_opts + debug_closure_opts
  closure_opts += [
      # Ignore missing goog.require since we assume the whole library is
      # already included.
      '--jscomp_off=missingRequire', '--jscomp_off=strictMissingRequire',
      '--create_source_map', result_map, '--js_output_file', result_file,
      '--source_map_location_mapping', source_base + '|..',
      '-D', 'COMPILED=true',
  ]

  if not receiver_build.build_raw(closure_opts):
    return False

  receiver_build.add_source_map(result_file, result_map)
  return True
开发者ID:xzhan96,项目名称:xzhan96.github.io,代码行数:50,代码来源:build.py


示例3: CreateParser

def CreateParser():
  """Create the argument parser for this application."""
  base = shakaBuildHelpers.get_source_base()

  parser = argparse.ArgumentParser(
      description=__doc__,
      formatter_class=argparse.RawDescriptionHelpFormatter)

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

  parser.add_argument(
      '--source',
      type=str,
      default=os.path.join(base, 'ui', 'locales'),
      help='The folder path for JSON inputs')

  parser.add_argument(
      '--output',
      type=str,
      default=os.path.join(base, 'dist', 'locales.js'),
      help='The file path for JavaScript output')

  parser.add_argument(
      '--class-name',
      type=str,
      default='shaka.ui.Locales',
      help='The fully qualified class name for the JavaScript output')

  return parser
开发者ID:google,项目名称:shaka-player,代码行数:34,代码来源:generateLocalizations.py


示例4: get_lint_files

def get_lint_files():
  """Returns the absolute paths to all the files to run the linter over."""
  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.get_source_base()
  def get(arg):
    return shakaBuildHelpers.get_all_files(os.path.join(base, arg), match)
  return get('test') + get('lib') + get('externs') + get('demo')
开发者ID:TheModMaker,项目名称:shaka-player,代码行数:7,代码来源:check.py


示例5: build_raw

  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()

    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
    if shakaBuildHelpers.execute_get_code(cmd_line) != 0:
      logging.error('Build failed')
      return False

    return True
开发者ID:indiereign,项目名称:shaka-player,代码行数:27,代码来源:build.py


示例6: check_complete

def check_complete(_):
  """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.
  """
  logging.info('Checking that the build files are complete...')

  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.parse_build(['[email protected]', '[email protected]'], os.getcwd()):
    logging.error('Error parsing complete build')
    return False

  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.get_source_base()
  all_files = shakaBuildHelpers.get_all_files(os.path.join(base, 'lib'), match)
  missing_files = set(all_files) - complete.include

  if missing_files:
    logging.error('There are files missing from the complete build:')
    for missing in missing_files:
      # Convert to a path relative to source base.
      logging.error('  ' + os.path.relpath(missing, base))
    return False
  return True
开发者ID:TheModMaker,项目名称:shaka-player,代码行数:31,代码来源:check.py


示例7: compute_output_files

def compute_output_files(base_name):
  source_base = shakaBuildHelpers.get_source_base().replace('\\', '/')
  prefix = shakaBuildHelpers.cygwin_safe_path(
      os.path.join(source_base, 'dist', base_name))
  js_path = prefix + '.js'
  map_path = prefix + '.map'
  return js_path, map_path
开发者ID:xzhan96,项目名称:xzhan96.github.io,代码行数:7,代码来源:build.py


示例8: process

def process(text, options):
  """Decodes a JSON string containing source map data.

  Args:
    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 output directory.
  base = os.path.join(shakaBuildHelpers.get_source_base(), 'dist')
  with open(os.path.join(base, data['file']), 'r') as f:
    file_lines = f.readlines()
  names = data['names']
  mappings = data['mappings']
  tokens = decode_mappings(mappings, names)
  sizes = process_sizes(tokens, file_lines)

  # Print out one of the results.
  if options.all_tokens:
    print_tokens(tokens, file_lines, sizes)
  elif options.function_sizes:
    print_sizes(sizes)
  elif options.function_deps or options.class_deps:
    temp = process_deps(tokens, file_lines, options.class_deps)
    print_deps(temp, options.dot_format)
开发者ID:google,项目名称:shaka-player,代码行数:32,代码来源:stats.py


示例9: check_tests

def check_tests(_):
  """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...')

  match = re.compile(r'.*\.js$')
  base = shakaBuildHelpers.get_source_base()
  def get(*args):
    return shakaBuildHelpers.get_all_files(os.path.join(base, *args), match)
  files = set(get('lib') + get('externs') + get('test') +
              get('third_party', 'closure'))
  files.add(os.path.join(base, 'demo', 'common', 'assets.js'))
  test_build = build.Build(files)

  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', '--jscomp_off=strictMissingRequire',
      '--checks-only', '-O', 'SIMPLE'
  ]
  return test_build.build_raw(closure_opts)
开发者ID:TheModMaker,项目名称:shaka-player,代码行数:27,代码来源:check.py


示例10: build_library

    def build_library(self, name, rebuild):
        """Builds Shaka Player using the files in |self.include|.

    Args:
      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.add_core()

        # 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.
        source_base = shakaBuildHelpers.get_source_base().replace("\\", "/")

        result_prefix = shakaBuildHelpers.cygwin_safe_path(os.path.join(source_base, "dist", "shaka-player." + name))
        result_file = result_prefix + ".js"
        result_debug = result_prefix + ".debug.js"
        result_map = result_prefix + ".debug.map"

        # Detect changes to the library and only build if changes have been made.
        if not rebuild and os.path.isfile(result_file):
            build_time = os.path.getmtime(result_file)
            complete_build = Build()
            if complete_build.parse_build(["[email protected]"], os.getcwd()):
                complete_build.add_core()
                # Get a list of files modified since the build file was.
                edited_files = [f for f in complete_build.include if os.path.getmtime(f) > build_time]
                if not edited_files:
                    print "No changes detected, not building.  Use --force to override."
                    return True

        opts = [
            "--create_source_map",
            result_map,
            "--js_output_file",
            result_debug,
            "--source_map_location_mapping",
            source_base + "|..",
            "--dependency_mode=LOOSE",
            "--js=shaka-player.uncompiled.js",
        ]
        if not self.build_raw(opts):
            return False

        shutil.copyfile(result_debug, result_file)

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

        return True
开发者ID:CCC-EE,项目名称:shaka-player,代码行数:56,代码来源:build.py


示例11: main

def main(args):
  parser = argparse.ArgumentParser(
      description=__doc__,
      formatter_class=argparse.RawDescriptionHelpFormatter)

  parser.add_argument('-d', '--dot-format', action='store_true',
                      help='Prints in DOT format.')
  parser.add_argument('source_map', nargs='?',
                      default='shaka-player.compiled.map',
                      help='The source map or the name of the build to use.')

  print_types = parser.add_mutually_exclusive_group(required=True)
  print_types.add_argument('-c', '--class-deps', action='store_true',
                           help='Prints the class dependencies.')
  print_types.add_argument('-f', '--function-deps', action='store_true',
                           help='Prints the function dependencies.')
  print_types.add_argument(
      '-s', '--function-sizes', action='store_true',
      help='Prints the function sizes (in number of characters).')
  print_types.add_argument(
      '-t', '--all-tokens', action='store_true',
      help='Prints all tokens in the source map.')

  options = parser.parse_args(args)

  # Verify arguments are correct.
  if (options.dot_format and not options.function_deps
      and not options.class_deps):
    parser.error('--dot-format only valid with --function-deps or '
                 '--class-deps.')

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

    # 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:
      logging.error('"%s" not found; build Shaka first.', name)
      return 1

  with open(name, 'r') as f:
    process(f.read(), options)
  return 0
开发者ID:google,项目名称:shaka-player,代码行数:56,代码来源:stats.py


示例12: check_js_lint

def check_js_lint(args):
  """Runs the JavaScript linter."""
  # TODO: things not enforced: property doc requirements
  logging.info('Linting JavaScript...')

  base = shakaBuildHelpers.get_source_base()
  config_path = os.path.join(base, '.eslintrc.js')

  linter = compiler.Linter(get_lint_files(), config_path)
  return linter.lint(fix=args.fix, force=args.force)
开发者ID:google,项目名称:shaka-player,代码行数:10,代码来源:check.py


示例13: compile_less

def compile_less(path_name, main_file_name, parsed_args):
  match = re.compile(r'.*\.less$')
  base = shakaBuildHelpers.get_source_base()
  main_less_src = os.path.join(base, path_name, main_file_name + '.less')
  all_less_srcs = shakaBuildHelpers.get_all_files(
      os.path.join(base, path_name), match)
  output = os.path.join(base, 'dist', main_file_name + '.css')

  less = compiler.Less(main_less_src, all_less_srcs, output)
  return less.compile(parsed_args.force)
开发者ID:google,项目名称:shaka-player,代码行数:10,代码来源:all.py


示例14: add_closure

 def add_closure(self):
   """Adds the closure library and externs."""
   # Add externs and closure dependencies.
   source_base = shakaBuildHelpers.get_source_base()
   match = re.compile(r'.*\.js$')
   self.include |= set(
       shakaBuildHelpers.get_all_files(
           os.path.join(source_base, 'externs'), match) +
       shakaBuildHelpers.get_all_files(
           os.path.join(source_base, 'third_party', 'closure'), match))
开发者ID:google,项目名称:shaka-player,代码行数:10,代码来源:build.py


示例15: check_html_lint

def check_html_lint(args):
  """Runs the HTML linter."""
  logging.info('Linting HTML...')

  base = shakaBuildHelpers.get_source_base()
  files = ['index.html', os.path.join('demo', 'index.html'), 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  config_path = os.path.join(base, '.htmlhintrc')

  htmllinter = compiler.HtmlLinter(file_paths, config_path)
  return htmllinter.lint(force=args.force)
开发者ID:google,项目名称:shaka-player,代码行数:11,代码来源:check.py


示例16: build_library

  def build_library(self, name, rebuild, is_debug):
    """Builds Shaka Player using the files in |self.include|.

    Args:
      name: The name of the build.
      rebuild: 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.
    """
    self.add_core()

    # 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.
    source_base = shakaBuildHelpers.get_source_base().replace('\\', '/')
    if is_debug:
      name += '.debug'

    result_prefix = shakaBuildHelpers.cygwin_safe_path(
        os.path.join(source_base, 'dist', 'shaka-player.' + name))
    result_file = result_prefix + '.js'
    result_map = result_prefix + '.map'

    # Detect changes to the library and only build if changes have been made.
    if not rebuild and os.path.isfile(result_file):
      build_time = os.path.getmtime(result_file)
      complete_build = Build()
      if complete_build.parse_build(['[email protected]'], os.getcwd()):
        complete_build.add_core()
        # Get a list of files modified since the build file was.
        edited_files = [f for f in complete_build.include
                        if os.path.getmtime(f) > build_time]
        if not edited_files:
          logging.warning('No changes detected, not building.  Use --force '
                          'to override.')
          return True

    opts = ['--create_source_map', result_map, '--js_output_file', result_file,
            '--source_map_location_mapping', source_base + '|..']
    if not self.build_raw(opts, is_debug):
      return False

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

    if not self.generate_externs(name):
      return False

    return True
开发者ID:indiereign,项目名称:shaka-player,代码行数:54,代码来源:build.py


示例17: build_docs

def build_docs(_):
  """Builds the source code documentation."""
  logging.info('Building the docs...')

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

  jsdoc = shakaBuildHelpers.get_node_binary('jsdoc')
  cmd_line = jsdoc + ['-c', 'docs/jsdoc.conf.json']
  return shakaBuildHelpers.execute_get_code(cmd_line)
开发者ID:TheModMaker,项目名称:shaka-player,代码行数:11,代码来源:docs.py


示例18: check_html_lint

def check_html_lint(_):
  """Runs the HTML linter over the HTML files.

  Returns:
    True on success, False on failure.
  """
  logging.info('Running htmlhint...')
  htmlhint = shakaBuildHelpers.get_node_binary('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]
  config_path = os.path.join(base, '.htmlhintrc')
  cmd_line = htmlhint + ['--config=' + config_path] + file_paths
  return shakaBuildHelpers.execute_get_code(cmd_line) == 0
开发者ID:TheModMaker,项目名称:shaka-player,代码行数:14,代码来源:check.py


示例19: generate_externs

  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.
    """
    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'))

    cmd_line = ['node', extern_generator, '--output', output] + files
    if shakaBuildHelpers.execute_get_code(cmd_line) != 0:
      logging.error('Externs generation failed')
      return False

    return True
开发者ID:xzhan96,项目名称:xzhan96.github.io,代码行数:24,代码来源:build.py


示例20: check_closure_compiler_linter

def check_closure_compiler_linter(_):
  """Runs the Closure Compiler linter."""
  logging.info('Running Closure Compiler linter...')

  base = shakaBuildHelpers.get_source_base()
  closure_linter_path = os.path.join(base, 'third_party', 'closure', 'linter.jar')
  cmd_line = ['java', '-jar', closure_linter_path] + get_lint_files()

  # The compiler's linter tool doesn't return a status code (as of v20171203)
  # and has no options.  Instead of checking status, success is no output.
  output = shakaBuildHelpers.execute_get_output(cmd_line)
  if output != '':
    print output
    return False
  return True
开发者ID:xzhan96,项目名称:xzhan96.github.io,代码行数:15,代码来源:check.py



注:本文中的shakaBuildHelpers.get_source_base函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shake.Shake类代码示例发布时间:2022-05-27
下一篇:
Python shell.print_exception函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap