
from skia_master_scripts import factory as skia_factory

class AndroidFactory(skia_factory.SkiaFactory):
  """Overrides for Android builds."""

  def Build(self, clobber=None):
    """Build and return the complete BuildFactory.

    clobber: boolean indicating whether we should clean before building
    """
    if clobber is None:
      clobber = self._default_clobber
    if clobber:
      self._skia_cmd_obj.AddClean()

    self._skia_cmd_obj.AddRun(
        run_command='../android/bin/android_make all -d xoom %s' % (
            self._make_flags),
        description='BuildAll')

    return self._factory


from skia_master_scripts import factory as skia_factory

class AndroidFactory(skia_factory.SkiaFactory):
  """Overrides for Android builds."""

  def Build(self, clobber=None):
    """Build and return the complete BuildFactory.

    clobber: boolean indicating whether we should clean before building
    """
    if clobber is None:
      clobber = self._default_clobber
    if clobber:
      self._skia_cmd_obj.AddClean()

    self._skia_cmd_obj.AddRunCommand(
        command='../android/bin/android_make all -d nexus_s %s' % (
            self._make_flags),
        description='BuildAll')

    self.PushBinaryToDeviceAndRun(binary_name='tests', description='RunTests')

    return self._factory

  def PushBinaryToDeviceAndRun(self, binary_name, description, timeout=None):
    """Adds a build step: push a binary file to the USB-connected Android
    device and run it.

    binary_name: which binary to run on the device
    description: text description (e.g., 'RunTests')
    timeout: timeout in seconds, or None to use the default timeout
    """
    path_to_adb = self.TargetPathJoin('..', 'android', 'bin', 'linux', 'adb')
    command_list = [
        '%s root' % path_to_adb,
        '%s remount' % path_to_adb,
        '%s push out/%s/%s /system/bin/%s' % (
            path_to_adb, self._configuration, binary_name, binary_name),
        '%s logcat -c' % path_to_adb,
        '%s shell %s' % (path_to_adb, binary_name),
        '%s logcat -d' % path_to_adb,
        ]
    self._skia_cmd_obj.AddRunCommandList(
        command_list=command_list, description=description)

Add RunTests step for Android buildbots
Add RunTests step for Android buildbots

Requires https://codereview.appspot.com/5966078 ('Add AddRunCommandList(), a cleaner way of running multiple shell commands as a single buildbot step') to work.
Review URL: https://codereview.appspot.com/5975072

git-svn-id: 32fc27f4dcfb6c0385cd9719852b95fe6680452d@3594 2bbb7eff-a529-9590-31e7-b0007b416f81

  
  from skia_master_scripts import factory as skia_factory
  
  class AndroidFactory(skia_factory.SkiaFactory):
    """Overrides for Android builds."""
  
    def Build(self, clobber=None):
      """Build and return the complete BuildFactory.
  
      clobber: boolean indicating whether we should clean before building
      """
      if clobber is None:
        clobber = self._default_clobber
      if clobber:
        self._skia_cmd_obj.AddClean()
  
-     self._skia_cmd_obj.AddRun(
+     self._skia_cmd_obj.AddRunCommand(
-         run_command='../android/bin/android_make all -d xoom %s' % (
+         command='../android/bin/android_make all -d nexus_s %s' % (
              self._make_flags),
          description='BuildAll')
  
+     self.PushBinaryToDeviceAndRun(binary_name='tests', description='RunTests')
+ 
      return self._factory
  
+   def PushBinaryToDeviceAndRun(self, binary_name, description, timeout=None):
+     """Adds a build step: push a binary file to the USB-connected Android
+     device and run it.
+ 
+     binary_name: which binary to run on the device
+     description: text description (e.g., 'RunTests')
+     timeout: timeout in seconds, or None to use the default timeout
+     """
+     path_to_adb = self.TargetPathJoin('..', 'android', 'bin', 'linux', 'adb')
+     command_list = [
+         '%s root' % path_to_adb,
+         '%s remount' % path_to_adb,
+         '%s push out/%s/%s /system/bin/%s' % (
+             path_to_adb, self._configuration, binary_name, binary_name),
+         '%s logcat -c' % path_to_adb,
+         '%s shell %s' % (path_to_adb, binary_name),
+         '%s logcat -d' % path_to_adb,
+         ]
+     self._skia_cmd_obj.AddRunCommandList(
+         command_list=command_list, description=description)
+ 
Add RunTests step for Android buildbots
## Code Before:

from skia_master_scripts import factory as skia_factory

class AndroidFactory(skia_factory.SkiaFactory):
  """Overrides for Android builds."""

  def Build(self, clobber=None):
    """Build and return the complete BuildFactory.

    clobber: boolean indicating whether we should clean before building
    """
    if clobber is None:
      clobber = self._default_clobber
    if clobber:
      self._skia_cmd_obj.AddClean()

    self._skia_cmd_obj.AddRun(
        run_command='../android/bin/android_make all -d xoom %s' % (
            self._make_flags),
        description='BuildAll')

    return self._factory

## Instruction:
Add RunTests step for Android buildbots
## Code After:

from skia_master_scripts import factory as skia_factory

class AndroidFactory(skia_factory.SkiaFactory):
  """Overrides for Android builds."""

  def Build(self, clobber=None):
    """Build and return the complete BuildFactory.

    clobber: boolean indicating whether we should clean before building
    """
    if clobber is None:
      clobber = self._default_clobber
    if clobber:
      self._skia_cmd_obj.AddClean()

    self._skia_cmd_obj.AddRunCommand(
        command='../android/bin/android_make all -d nexus_s %s' % (
            self._make_flags),
        description='BuildAll')

    self.PushBinaryToDeviceAndRun(binary_name='tests', description='RunTests')

    return self._factory

  def PushBinaryToDeviceAndRun(self, binary_name, description, timeout=None):
    """Adds a build step: push a binary file to the USB-connected Android
    device and run it.

    binary_name: which binary to run on the device
    description: text description (e.g., 'RunTests')
    timeout: timeout in seconds, or None to use the default timeout
    """
    path_to_adb = self.TargetPathJoin('..', 'android', 'bin', 'linux', 'adb')
    command_list = [
        '%s root' % path_to_adb,
        '%s remount' % path_to_adb,
        '%s push out/%s/%s /system/bin/%s' % (
            path_to_adb, self._configuration, binary_name, binary_name),
        '%s logcat -c' % path_to_adb,
        '%s shell %s' % (path_to_adb, binary_name),
        '%s logcat -d' % path_to_adb,
        ]
    self._skia_cmd_obj.AddRunCommandList(
        command_list=command_list, description=description)
