xref: /linux/scripts/jobserver-exec (revision f96163865a1346b199cc38e827269296f0f24ab0)
1#!/usr/bin/env python3
2# SPDX-License-Identifier: GPL-2.0+
3
4"""
5Determines how many parallel tasks "make" is expecting, as it is
6not exposed via any special variables, reserves them all, runs a subprocess
7with PARALLELISM environment variable set, and releases the jobs back again.
8
9See:
10    https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html#POSIX-Jobserver
11"""
12
13import os
14import sys
15
16LIB_DIR = "../tools/lib/python"
17SRC_DIR = os.path.dirname(os.path.realpath(__file__))
18
19sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
20
21from jobserver import JobserverExec                  # pylint: disable=C0415
22
23
24def main():
25    """Main program"""
26    if len(sys.argv) < 2:
27        name = os.path.basename(__file__)
28        sys.exit("usage: " + name +" command [args ...]\n" + __doc__)
29
30    with JobserverExec() as jobserver:
31        jobserver.run(sys.argv[1:])
32
33
34if __name__ == "__main__":
35    main()
36