+def IsTaggingRequested(step):
+ val = step.getProperty("tag")
+ if val and re.match("^[0-9]+\.[0-9]+\.[0-9]+$", val):
+ return True
+ else:
+ return False
+
+def IsNoTaggingRequested(step):
+ return not IsTaggingRequested(step)
+
+def IsNoMasterBuild(step):
+ return repo_branch != "master"
+
+def GetBaseVersion(props):
+ if re.match("^[^-]+-[0-9]+\.[0-9]+$", repo_branch):
+ return repo_branch.split('-')[1]
+ else:
+ return "master"
+
+def GetVersionPrefix(props):
+ basever = GetBaseVersion(props)
+ if props.hasProperty("tag") and re.match("^[0-9]+\.[0-9]+\.[0-9]+$", props["tag"]):
+ return "%s/" % props["tag"]
+ elif basever != "master":
+ return "%s-SNAPSHOT/" % basever
+ else:
+ return ""
+
+def GetNumJobs(props):
+ if props.hasProperty("slavename") and props.hasProperty("nproc"):
+ return ((int(props["nproc"]) / (max_builds[props["slavename"]] + other_builds)) + 1)
+ else:
+ return 1
+
+def GetCC(props):
+ if props.hasProperty("cc_command"):
+ return props["cc_command"]
+ else:
+ return "gcc"
+
+def GetCXX(props):
+ if props.hasProperty("cxx_command"):
+ return props["cxx_command"]
+ else:
+ return "g++"
+
+def GetCwd(props):
+ if props.hasProperty("builddir"):
+ return props["builddir"]
+ elif props.hasProperty("workdir"):
+ return props["workdir"]
+ else:
+ return "/"
+
+def MakeEnv(overrides=None):
+ env = {
+ 'CC': WithProperties("%(cc)s", cc=GetCC),
+ 'CXX': WithProperties("%(cxx)s", cxx=GetCXX),
+ 'CCACHE_BASEDIR': WithProperties("%(cwd)s", cwd=GetCwd)
+ }
+ if overrides is not None:
+ env.update(overrides)
+ return env
+