Esempio n. 1
0
def copyVersionFile(destDir):
  gitHash = bbutil.getHEADSha()
  destFile = os.path.join(destDir, 'version.txt')
  with open(destFile, 'w') as fDest:
    if 'GN_GENERATORS' in os.environ:
      fDest.write('GN_GENERATORS="' + os.environ['GN_GENERATORS'] + '"\n')
    if 'GN_GENERATOR_FLAGS' in os.environ:
      fDest.write('GN_GENERATOR_FLAGS="' +
                  os.environ['GN_GENERATOR_FLAGS'] + '"\n')
    if 'GN_DEFINES' in os.environ:
      fDest.write('GN_DEFINES="' + os.environ['GN_DEFINES'] + '"\n')
    fDest.write('chromium.wtk2 commit ' + gitHash + '\n\n')
Esempio n. 2
0
def generateBuildNumber(contentVersion):
  # Get list of all tags
  cmd = 'git tag --sort=-v:refname'
  allTags = bbutil.getSplitShellOutput(cmd)

  # Get the release branch number
  currentBranchName = bbutil.getStrippedShellOutput(
          "git rev-parse --abbrev-ref HEAD")

  match = re.match('release/trml/(\\d*)', currentBranchName)

  if not match:
    raise Exception("You must be in a release branch to start a devkit build")

  releaseBranchNumber = int(match.group(1))

  # Iterate through all tags and find the latest build number with a matching
  # version of Content and a matching release branch number.  If we don't find
  # a tag, search by the previous release branch number.
  latestBuildNumber = 0
  latestBranchNumber = releaseBranchNumber

  while latestBranchNumber > 0:
    for tag in allTags:
      if contentVersion in tag:
        matches = re.match('^devkit/stable/{0}/bb(\\d*)(\\d\\d)$'.format(
                    contentVersion), tag)
        if int(matches.group(1)) == latestBranchNumber:
          latestBuildNumber = int(matches.group(2))
          break

    if 0 != latestBuildNumber:
      break

    latestBranchNumber -= 1

  if latestBuildNumber > 0:
    # Check to see if there are any new commits since the last build
    previousTag = 'devkit/stable/{0}/bb{1}{2:02d}'.format(
            contentVersion, latestBranchNumber, latestBuildNumber)

    commonAncestor = bbutil.getStrippedShellOutput(
            "git merge-base {0} HEAD".format(previousTag))
    if bbutil.getHEADSha() == commonAncestor:
      raise Exception("No new changes since " + previousTag)

  # If the last release branch was older than the current one, reset the
  # build counter
  if latestBranchNumber != releaseBranchNumber:
    latestBuildNumber = 0

  return "bb{0}{1:02d}".format(releaseBranchNumber, latestBuildNumber+1)