• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package main
6
7import (
8	"flag"
9	"fmt"
10	"path/filepath"
11
12	"go.skia.org/infra/go/exec"
13	"go.skia.org/infra/go/skerr"
14	"go.skia.org/infra/task_driver/go/td"
15)
16
17func main() {
18	var (
19		projectId = flag.String("project_id", "", "ID of the Google Cloud project.")
20		taskId    = flag.String("task_id", "", "ID of this task.")
21		taskName  = flag.String("task_name", "", "Name of the task.")
22		output    = flag.String("o", "", "If provided, dump a JSON blob of step data to the given file. Prints to stdout if '-' is given.")
23		local     = flag.Bool("local", true, "True if running locally (as opposed to on the bots)")
24
25		skiaCheckoutRoot = flag.String("skia_checkout_root", "./skia", "Path to Skia's checkout.")
26	)
27	ctx := td.StartRun(projectId, taskId, taskName, output, local)
28	defer td.EndRun(ctx)
29
30	skiaCheckoutAbsPath := td.MustGetAbsolutePathOfFlag(ctx, *skiaCheckoutRoot, "skia_checkout_root")
31	binPath := filepath.Join(skiaCheckoutAbsPath, "bin")
32
33	// Fetch GN before running gn_to_bp.py
34	if _, err := exec.RunCwd(ctx, skiaCheckoutAbsPath, filepath.Join(binPath, "fetch-gn")); err != nil {
35		td.Fatal(ctx, skerr.Wrap(err))
36	}
37
38	// Run gn_to_bp.py
39	gnPath := fmt.Sprintf("%s/gn", binPath)
40	if _, gnToBpErr := exec.RunCommand(ctx, &exec.Command{
41		Dir:  skiaCheckoutAbsPath,
42		Name: "python3",
43		Args: []string{"gn/gn_to_bp.py", "--gn", gnPath},
44	}); gnToBpErr != nil {
45		td.Fatal(ctx, fmt.Errorf("Failed to run gn_to_bp: %s", gnToBpErr))
46	}
47	return
48}
49