1#!/usr/bin/env python
2#
3# Copyright 2018 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"""Create the mesa driver. This defers to a Docker container
10   with the build_mesa.sh script."""
11
12
13import argparse
14import subprocess
15
16# TODO(dogben): In the future, it might be simpler to build the docker image as
17# part of this script so that we don't need to push it to the container repo.
18# Doing so would make this script more repeatable, since someone could
19# accidentally change the Docker image that "v2" points to.
20DOCKER_IMAGE = 'gcr.io/skia-public/mesa-driver-builder:v2'
21BUILD_SCRIPT = '/opt/build_mesa.sh'
22MESA_VERSION = '18.3.3'
23
24
25def create_asset(target_dir):
26  """Create the asset."""
27  cmd = [
28    'docker', 'run', '--volume', '%s:/OUT' % target_dir,
29    '--env', 'MESA_VERSION=%s' % MESA_VERSION,
30    DOCKER_IMAGE, BUILD_SCRIPT
31  ]
32  print('Running docker cmd', cmd)
33  subprocess.check_output(cmd)
34
35
36def main():
37  parser = argparse.ArgumentParser()
38  parser.add_argument('--target_dir', '-t', required=True)
39  args = parser.parse_args()
40  create_asset(args.target_dir)
41
42
43if __name__ == '__main__':
44  main()
45