Files
ninja/misc/jobserver_test_helper.py
David 'Digit' Turner d4a4f3694c Support jobserver client mode automatically.
Detect that the environment variable MAKEFLAGS specifies a
jobserver pool to use, and automatically use it to control
build parallelism when this is the case.

NOTE: On Posix, the pipe-based protocol is not supported and
will be detected. Ninja will print a warning on startup then
ignore the content of MAKEFLAGS (there is a regression test
for this).

This is disabled is `--dry-run` or an explicit `-j<COUNT>`
is passed on the command-line. Note that the `-l` option
used to limit dispatch based on the overall load factor
will still be in effect if used.

+ Use default member initialization for BuildConfig struct.

+ Add a new regression test suite that uses the
  misc/jobserver_pool.py script that was introduced in
  a previous commit, to verify that everything works
  properly.
2025-04-22 14:14:45 +02:00

43 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright 2024 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Simple utility used by the jobserver test. Wait for specific time, then write start/stop times to output file."""
import argparse
import time
import sys
from pathlib import Path
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--duration-ms",
default="50",
help="sleep duration in milliseconds (default 50)",
)
parser.add_argument("output_file", type=Path, help="output file name.")
args = parser.parse_args()
now_time_ns = time.time_ns()
time.sleep(int(args.duration_ms) / 1000.0)
args.output_file.write_text(f"{now_time_ns}\n{time.time_ns()}\n")
return 0
if __name__ == "__main__":
sys.exit(main())