• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"""
10Create bazel_build task_driver. This should rarely need to change, so by putting it into
11CIPD, we should reduce build latency by removing the need for the BuildTaskDrivers job.
12That job *is* idempotent, so Swarming does eventually deduplicate it sometimes (but not
13after a usually unrelated change to something in //bazel), but skipping the step is faster.
14"""
15
16
17import argparse
18import os
19import shutil
20import subprocess
21
22FILE_DIR = os.path.dirname(os.path.abspath(__file__))
23SKIA_ROOT_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir, os.pardir, os.pardir))
24
25def 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=@io_bazel_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
37def 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
44if __name__ == '__main__':
45  main()
46
47