Skip to content

Commit

Permalink
LLVMBuildFactory code cleaning.
Browse files Browse the repository at this point in the history
Cleaned dialing with repourl, added protection from potential leakage of is_legacy_mode kwarg, more radable name for src_dir.

Patch by Andrei Lebedev

Differential Revision: https://reviews.llvm.org/D69081

llvm-svn: 375168
  • Loading branch information
gkistanova committed Oct 17, 2019
1 parent d036233 commit cf644d9
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions zorg/buildbot/process/factory.py
Expand Up @@ -61,7 +61,7 @@ def __init__(self, steps=None, depends_on_projects=None, **kwargs):
"%(monorepo_dir)s/build" % {'monorepo_dir' : self.monorepo_dir}

# Repourl could be specified per builder. Otherwise we use github.
self.repourl = kwargs.pop('repourl', 'https://github.com/llvm/llvm-%s.git')
self.repourl_prefix = kwargs.pop('repourl', 'https://github.com/llvm/')


# Default build directory.
Expand Down Expand Up @@ -134,51 +134,52 @@ def addGetSourcecodeSteps(self, **kwargs):
return

# Checkout the monorepo.
_repourl = self.repourl
if '%' in _repourl:
_repourl = _repourl % 'project'
self.addStep(
Git(name='Checkout the source code',
repourl=_repourl,
repourl=self.repourl_prefix + "llvm-project.git",
progress=True,
workdir=WithProperties(self.monorepo_dir),
**kwargs))


# Checkout a given LLVM project to the given directory.
# TODO: Handle clean property and self.clean attribute.
def addGetSourcecodeForProject(self, project, srcdir=None, **kwargs):
def addGetSourcecodeForProject(self, project, src_dir=None, **kwargs):
# Remove 'is_legacy_mode' if it leaked in to kwargs.
kwargs.pop('is_legacy_mode', None)

# Bail out if we are in the legacy mode and SVN checkout is required.
if self.is_legacy_mode:
workdir, baseURL = svn_repos[project]

# Check out to the given directory if any.
# Otherwise this is a part of the unified source tree.
if srcdir is None:
srcdir = workdir % {'llvm_srcdir' : self.llvm_srcdir}
if src_dir is None:
src_dir = workdir % {'llvm_srcdir' : self.llvm_srcdir}

self.addStep(
SVN(name='svn-%s' % project,
workdir=workdir % {'llvm_srcdir' : srcdir},
workdir=src_dir,
baseURL=WithProperties(baseURL),
**kwargs))
else:
# project contains a repo name which is not a part of the monorepo.
# We do not enforce it here, though.
_repourl = kwargs.pop('repourl', self.repourl)
if '%' in _repourl:
_repourl = _repourl % project
_repourl = kwargs.pop('repourl', None)
if not _repourl:
_repourl = self.repourl_prefix + "llvm-%s.git" % project

# Check out to the given directory if any.
# Otherwise this is a part of the unified source tree.
if srcdir is None:
srcdir = 'llvm-%s' % project
if src_dir is None:
src_dir = 'llvm-%s' % project

# Ignore workdir if given. We check out to srcdir.
# Ignore workdir if given. We check out to src_dir.
kwargs.pop('workdir', None)

self.addStep(
Git(name='Checkout the %s' % project,
repourl=_repourl,
progress=True,
workdir=WithProperties(srcdir),
**kwargs))
workdir=WithProperties(src_dir),
**kwargs))

0 comments on commit cf644d9

Please sign in to comment.