| 1 |
#!/usr/bin/env python |
| 2 |
# |
| 3 |
# Copyright 2022 Google LLC |
| 4 |
# |
| 5 |
# Use of this source code is governed by a BSD-style license that can be |
| 6 |
# found in the LICENSE file. |
| 7 |
|
| 8 |
|
| 9 |
""" |
| 10 |
Create bazel_build task_driver. This should rarely need to change, so by putting it into |
| 11 |
CIPD, we should reduce build latency by removing the need for the BuildTaskDrivers job. |
| 12 |
That job *is* idempotent, so Swarming does eventually deduplicate it sometimes (but not |
| 13 |
after a usually unrelated change to something in //bazel), but skipping the step is faster. |
| 14 |
""" |
| 15 |
|
| 16 |
|
| 17 |
import argparse |
| 18 |
import os |
| 19 |
import shutil |
| 20 |
import subprocess |
| 21 |
|
| 22 |
FILE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 23 |
SKIA_ROOT_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir, os.pardir, os.pardir)) |
| 24 |
|
| 25 |
def create_asset(target_dir): |
| 26 |
"""Compiles the task driver using bazel, which is presumed to be on PATH """ |
| 27 |
out = subprocess.check_output([ |
| 28 |
"bazel", "build", "//infra/bots/task_drivers/bazel_build", |
| 29 |
"--platforms=@rules_go//go/toolchain:linux_amd64", |
| 30 |
], encoding='utf-8') |
| 31 |
print(out) |
| 32 |
path_to_binary = os.path.join(SKIA_ROOT_DIR, 'bazel-bin', 'infra', 'bots', 'task_drivers', |
| 33 |
'bazel_build', 'bazel_build_', 'bazel_build') |
| 34 |
shutil.copy(path_to_binary, target_dir) |
| 35 |
|
| 36 |
|
| 37 |
def main(): |
| 38 |
parser = argparse.ArgumentParser() |
| 39 |
parser.add_argument('--target_dir', '-t', required=True) |
| 40 |
args = parser.parse_args() |
| 41 |
create_asset(args.target_dir) |
| 42 |
|
| 43 |
|
| 44 |
if __name__ == '__main__': |
| 45 |
main() |
| 46 |
|