jobserver-exec 914 B

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