59 lines
1.1 KiB
Python
59 lines
1.1 KiB
Python
import os
|
|
import json
|
|
from snapshot import create_snapshot
|
|
from scheduler import build_distcc_hosts
|
|
from config import CONFIG
|
|
|
|
|
|
def run(cmd, cwd, env):
|
|
import subprocess
|
|
|
|
p = subprocess.Popen(
|
|
cmd,
|
|
shell=True,
|
|
cwd=cwd,
|
|
env=env,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT,
|
|
text=True
|
|
)
|
|
|
|
for line in p.stdout:
|
|
print(line, end="")
|
|
|
|
p.wait()
|
|
return p.returncode
|
|
|
|
|
|
def build_target(project, snapshot, target, nodes):
|
|
env = os.environ.copy()
|
|
env["DISTCC_HOSTS"] = build_distcc_hosts(nodes)
|
|
|
|
cmd = project["targets"][target]
|
|
|
|
print(f"[FESTER] target={target}")
|
|
print(f"[FESTER] snapshot={snapshot['hash']}")
|
|
|
|
return run(cmd, snapshot["path"], env)
|
|
|
|
|
|
def run_release(project):
|
|
snapshot = create_snapshot(project["source"])
|
|
nodes = CONFIG["nodes"]
|
|
|
|
results = {}
|
|
|
|
for target in project["targets"]:
|
|
results[target] = build_target(project, snapshot, target, nodes)
|
|
|
|
return results
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
|
|
with open(sys.argv[1], "r") as f:
|
|
project = json.load(f)
|
|
|
|
run_release(project)
|