+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 GetNextBuild(builder, requests):
+ for r in requests:
+ if r.properties and r.properties.hasProperty("tag"):
+ return r
+ return requests[0]
+
+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
+