Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add mechanism for specifying configure options per branch
  • Loading branch information
stratakis committed Jul 2, 2026
commit f27dd234ff0d67fcfa459e952cb30e3acc879507
18 changes: 16 additions & 2 deletions master/custom/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def setup(self, branch, worker, test_with_PTY=False, **kwargs):
oot_kwargs = {}
configure_cmd = [configure_cmd, "--prefix", "$(PWD)/target"]
configure_cmd += self.configureFlags
configure_cmd += worker.get_flags(branch, "configure")
self.addStep(
Configure(command=configure_cmd, **oot_kwargs)
)
Expand Down Expand Up @@ -225,6 +226,7 @@ def setup(self, branch, worker, test_with_PTY=False, **kwargs):
Configure(
command=["./configure", "--prefix", "$(PWD)/target"]
+ self.configureFlags
+ worker.get_flags(branch, "configure")
)
)

Expand Down Expand Up @@ -620,17 +622,23 @@ class BaseWindowsBuild(BaseBuild):
factory_tags = ["win32"]

def setup(self, branch, worker, **kwargs):
build_command = self.build_command + self.buildFlags
build_command = (
self.build_command
+ self.buildFlags
+ worker.get_flags(branch, "build")
)
test_command = [
*self.test_command,
*self.testFlags,
*worker.get_flags(branch, "test"),
*get_j_opts(worker, 2),
]
if not has_option("-R", self.testFlags):
test_command.extend((r"--junit-xml", JUNIT_FILENAME))
clean_command = [
*self.clean_command,
*self.cleanFlags,
*worker.get_flags(branch, "clean"),
*get_j_opts(worker),
]
self.addStep(Compile(command=build_command))
Expand Down Expand Up @@ -819,6 +827,7 @@ def setup(self, branch, worker, test_with_PTY=False, **kwargs):
configure_cmd = list(self.host_configure_cmd)
configure_cmd += ["--prefix", "$(PWD)/target/host"]
configure_cmd += self.configureFlags + self.extra_configure_flags
configure_cmd += worker.get_flags(branch, "configure")
configure_cmd += [util.Interpolate("--build=%(prop:build_triple)s")]
configure_cmd += [f"--host={self.host}"]
configure_cmd += ["--with-build-python=../build/python"]
Expand Down Expand Up @@ -1142,6 +1151,7 @@ def py313_setup(self, branch, worker, test_with_PTY=False, **kwargs):
configure_cmd = list(self.host_configure_cmd)
configure_cmd += self.configureFlags
configure_cmd += self.extra_configure_flags
configure_cmd += worker.get_flags(branch, "configure")
configure_cmd += [
f"--with-openssl={support_path}/openssl",
f"--build={self.arch}-apple-darwin",
Expand Down Expand Up @@ -1361,7 +1371,11 @@ class ValgrindBuild(UnixBuild):
def setup(self, branch, worker, **kwargs):
self.addStep(
Configure(
command=["./configure", "--prefix", "$(PWD)/target"] + self.configureFlags
command=(
["./configure", "--prefix", "$(PWD)/target"]
+ self.configureFlags
+ worker.get_flags(branch, "configure")
)
)
)

Expand Down
68 changes: 68 additions & 0 deletions master/custom/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,64 @@
KEEPALIVE = 60


class BranchWorkerFlags:
def __init__(
self,
*,
branches=None,
min_branch=None,
max_branch=None,
configure=(),
build=(),
test=(),
clean=(),
):
if isinstance(branches, str):
self.branches = (branches,)
elif branches is not None:
self.branches = tuple(branches)
else:
self.branches = None
self.min_branch = min_branch
self.max_branch = max_branch
self.configure = self._as_tuple(configure)
self.build = self._as_tuple(build)
self.test = self._as_tuple(test)
self.clean = self._as_tuple(clean)

@staticmethod
def _as_tuple(flags):
if isinstance(flags, str):
return (flags,)
return tuple(flags)

def applies_to(self, branch):
if self.branches is not None and branch.name not in self.branches:
return False

if self.min_branch is None and self.max_branch is None:
return True

if branch.version_tuple is None:
return False
if self.min_branch is not None and branch.version_tuple < self.min_branch:
return False
if self.max_branch is not None and branch.version_tuple > self.max_branch:
return False
return True

def get(self, kind):
if kind == "configure":
return self.configure
if kind == "build":
return self.build
if kind == "test":
return self.test
if kind == "clean":
return self.clean
raise ValueError(f"Unknown branch worker flag kind: {kind}")


class CPythonWorker:
def __init__(
self,
Expand All @@ -30,6 +88,7 @@ def __init__(
tags=None,
branches=None,
not_branches=None,
branch_flags=(),
parallel_builders=1,
parallel_tests=None,
timeout_factor=1,
Expand All @@ -40,6 +99,7 @@ def __init__(
self.tags = tags or set()
self.branches = branches
self.not_branches = not_branches
self.branch_flags = tuple(branch_flags)
self.parallel_tests = parallel_tests
self.timeout_factor = timeout_factor
self.exclude_test_resources = exclude_test_resources or []
Expand All @@ -62,6 +122,14 @@ def __init__(
max_builds=parallel_builders,
)

def get_flags(self, branch, kind):
flags = []
for rule in self.branch_flags:
if rule.applies_to(branch):
flags.extend(rule.get(kind))
return flags


# Some of Itamar's workers are reprovisioned every Wednesday at 9am PT.
# Builds scheduled between 8am - 10am PT on Wednesdays will be delayed to
# 10am PT.
Expand Down