global: calculate suitable number of jobs
[buildbot.git] / phase2 / master.cfg
index 06e1b597bfe04521a5cb677d4caba4f7dcf347c6..c711b09deeb7a9db47731f4365a4a9dfe91861bb 100644 (file)
@@ -29,6 +29,7 @@ from buildbot.buildslave import BuildSlave
 
 slave_port = 9990
 persistent = False
+other_builds = 0
 
 if ini.has_option("general", "port"):
        slave_port = ini.getint("general", "port")
@@ -36,17 +37,21 @@ if ini.has_option("general", "port"):
 if ini.has_option("general", "persistent"):
        persistent = ini.getboolean("general", "persistent")
 
+if ini.has_option("general", "other_builds"):
+       other_builds = ini.getint("general", "other_builds")
+
 c['slaves'] = []
+max_builds = dict()
 
 for section in ini.sections():
        if section.startswith("slave "):
                if ini.has_option(section, "name") and ini.has_option(section, "password"):
                        name = ini.get(section, "name")
                        password = ini.get(section, "password")
-                       max_builds = 1
+                       max_builds[name] = 1
                        if ini.has_option(section, "builds"):
-                               max_builds = ini.getint(section, "builds")
-                       c['slaves'].append(BuildSlave(name, password, max_builds = max_builds))
+                               max_builds[name] = ini.getint(section, "builds")
+                       c['slaves'].append(BuildSlave(name, password, max_builds = max_builds[name]))
 
 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
 # This must match the value configured into the buildslaves (with their
@@ -179,6 +184,12 @@ def GetDirectorySuffix(props):
        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
+
 
 c['builders'] = []
 
@@ -269,7 +280,7 @@ for arch in arches:
                name = "compile",
                description = "Building packages",
                workdir = "build/sdk",
-               command = ["make", WithProperties("-j%(nproc:~4)s"), "V=s", "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_SIGNED_PACKAGES=y"]))
+               command = ["make", WithProperties("-j%(jobs)d", jobs=GetNumJobs), "V=s", "IGNORE_ERRORS=n m y", "BUILD_LOG=1", "CONFIG_SIGNED_PACKAGES=y"]))
 
        if gpg_keyid is not None:
                factory.addStep(MasterShellCommand(