• 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	"os"
11	"path/filepath"
12
13	"go.skia.org/infra/go/exec"
14	"go.skia.org/infra/go/skerr"
15	"go.skia.org/infra/task_driver/go/td"
16)
17
18func main() {
19	var (
20		projectId = flag.String("project_id", "", "ID of the Google Cloud project.")
21		taskId    = flag.String("task_id", "", "ID of this task.")
22		taskName  = flag.String("task_name", "", "Name of the task.")
23		output    = flag.String("o", "", "If provided, dump a JSON blob of step data to the given file. Prints to stdout if '-' is given.")
24		local     = flag.Bool("local", true, "True if running locally (as opposed to on the bots)")
25
26		skiaCheckoutRoot = flag.String("skia_checkout_root", "./skia", "Path to Skia's checkout.")
27	)
28	ctx := td.StartRun(projectId, taskId, taskName, output, local)
29	defer td.EndRun(ctx)
30
31	skiaCheckoutAbsPath := td.MustGetAbsolutePathOfFlag(ctx, *skiaCheckoutRoot, "skia_checkout_root")
32	binPath := filepath.Join(skiaCheckoutAbsPath, "bin")
33
34	// Fetch GN before running gn_to_bp.py
35	if _, err := exec.RunCwd(ctx, skiaCheckoutAbsPath, filepath.Join(binPath, "fetch-gn")); err != nil {
36		td.Fatal(ctx, skerr.Wrap(err))
37	}
38
39	// Run gn_to_bp.py
40	gnEnv := []string{fmt.Sprintf("PATH=%s/:%s", binPath, os.Getenv("PATH"))}
41	if _, gnToBpErr := exec.RunCommand(ctx, &exec.Command{
42		Env:  gnEnv,
43		Dir:  skiaCheckoutAbsPath,
44		Name: "python2",
45		Args: []string{"-c", "from gn import gn_to_bp"},
46	}); gnToBpErr != nil {
47		td.Fatal(ctx, fmt.Errorf("Failed to run gn_to_bp: %s", gnToBpErr))
48	}
49	return
50}
51