コード例 #1
0
 def _DoesIncludesSubMake(self):
     if self._includes_submake is None:
         if self._is_leaf:
             path = os.path.join(android_build.GetTop(), self._path)
             mk_parser = android_mk.CreateAndroidMK(path)
             self._includes_submake = mk_parser.IncludesMakefilesUnder()
         else:
             self._includes_submake = False
     return self._includes_submake
コード例 #2
0
ファイル: coverage.py プロジェクト: AOSDP/android_development
 def GetCoverageTargetForPath(self, path):
     """Find the CoverageTarget for given file system path"""
     android_mk_path = os.path.join(path, "Android.mk")
     if os.path.exists(android_mk_path):
         android_mk_parser = android_mk.CreateAndroidMK(path)
         target = coverage_target.CoverageTarget()
         target.SetBuildPath(os.path.join(path, "src"))
         target.SetName(
             android_mk_parser.GetVariable(android_mk_parser.PACKAGE_NAME))
         target.SetType("APPS")
         return target
     else:
         msg = "No Android.mk found at %s" % path
         raise errors.AbortError(msg)
コード例 #3
0
  def _FindSubTests(self, path, tests, upstream_build_path=None):
    """Recursively finds all tests within given path.

    Args:
      path: absolute file system path to check
      tests: current list of found tests
      upstream_build_path: the parent directory where Android.mk that builds
        sub-folders was found

    Returns:
      updated list of tests
    """
    if not os.path.isdir(path):
      return tests
    android_mk_parser = android_mk.CreateAndroidMK(path)
    if android_mk_parser:
      build_rel_path = self._MakePathRelativeToBuild(path)
      if not upstream_build_path:
        # haven't found a parent makefile which builds this dir. Use current
        # dir as build path
        tests.extend(self._CreateSuites(
            android_mk_parser, path, build_rel_path))
      else:
        tests.extend(self._CreateSuites(android_mk_parser, path,
                                        upstream_build_path))
      # TODO: remove this logic, and rely on caller to collapse build
      # paths via make_tree

      # Try to build as much of original path as possible, so
      # keep track of upper-most parent directory where Android.mk was found
      # that has rule to build sub-directory makefiles.
      # this is also necessary in case of overlapping tests
      # ie if a test exists at 'foo' directory  and 'foo/sub', attempting to
      # build both 'foo' and 'foo/sub' will fail.

      if android_mk_parser.IncludesMakefilesUnder():
        # found rule to build sub-directories. The parent path can be used,
        # or if not set, use current path
        if not upstream_build_path:
          upstream_build_path = self._MakePathRelativeToBuild(path)
      else:
        upstream_build_path = None
    for filename in os.listdir(path):
      self._FindSubTests(os.path.join(path, filename), tests,
                         upstream_build_path)
    return tests
コード例 #4
0
  def _GetTestFactoryForPath(self, path):
    """Get the test factory for given path.

    If given path is a valid tests build path, will return the TestFactory
    for creating tests.

    Args:
      path: the filesystem path to evaluate

    Returns:
      the TestFactory or None if path is not a valid tests build path
    """
    android_mk_parser = android_mk.CreateAndroidMK(path)
    if android_mk_parser:
      build_path = self._MakePathRelativeToBuild(path)
      return self._GetTestFactory(android_mk_parser, path, build_path)
    else:
      return None
コード例 #5
0
def main(argv):
  options, args = _ParseArgs(argv)
  app_path = args[0];

  if not os.path.exists(app_path):
    _PrintError("Error: Application path %s not found" % app_path)
    sys.exit()

  try:
    mk = android_mk.CreateAndroidMK(path=app_path)
    manifest = android_manifest.AndroidManifest(app_path=app_path)
    _ValidateInputFiles(mk, manifest)

    module_name = mk.GetVariable(mk.PACKAGE_NAME)
    _GenerateTestMK(mk, app_path)
    _GenerateTestManifest(manifest, module_name)
  except Exception, e:
    _PrintError("Error: %s" % e)
    _PrintError("Error encountered, script aborted")
    sys.exit()