| 1 |
#!/usr/bin/env python3 |
| 2 |
# SPDX-License-Identifier: GPL-2.0+ |
| 3 |
|
| 4 |
""" |
| 5 |
Determines how many parallel tasks "make" is expecting, as it is |
| 6 |
not exposed via any special variables, reserves them all, runs a subprocess |
| 7 |
with PARALLELISM environment variable set, and releases the jobs back again. |
| 8 |
|
| 9 |
See: |
| 10 |
https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html#POSIX-Jobserver |
| 11 |
""" |
| 12 |
|
| 13 |
import os |
| 14 |
import sys |
| 15 |
|
| 16 |
LIB_DIR = "../tools/lib/python" |
| 17 |
SRC_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 18 |
|
| 19 |
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) |
| 20 |
|
| 21 |
from jobserver import JobserverExec # pylint: disable=C0415 |
| 22 |
|
| 23 |
|
| 24 |
def 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 |
|
| 34 |
if __name__ == "__main__": |
| 35 |
main() |