blob: bc55dc966a6fa80b758f2e0b439971593de5dacc [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
/*
Generate the tasks.json file.
*/
import (
"context"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"github.com/golang/glog"
"go.skia.org/infra/go/common"
"go.skia.org/infra/go/exec"
"go.skia.org/infra/go/util"
"go.skia.org/infra/task_scheduler/go/specs"
)
func main() {
common.Init()
root, err := specs.GetCheckoutRoot()
if err != nil {
glog.Fatal(err)
}
skiaDir := path.Join(root, "..", "skia")
if _, err := os.Stat(skiaDir); err != nil {
glog.Fatalf("Unable to find Skia checkout in %s; you probably need to run 'gclient sync'.")
}
infraBots := path.Join(root, "infra", "bots")
// Copy aux file into same dir as gen_tasks.go.
auxPath := path.Join(skiaDir, "infra", "bots", "gen_tasks_aux.go")
if aux, err := ioutil.ReadFile(path.Join(infraBots, "gen_tasks_aux.go")); err != nil {
glog.Fatalf("Unable to read gen_tasks_aux.go in %s: %s", infraBots, err)
} else {
if err := ioutil.WriteFile(auxPath, aux, os.ModePerm); err != nil {
glog.Fatalf("Unable to write gen_tasks_aux.go to %s: %s", path.Join(skiaDir, "infra", "bots"), err)
}
}
defer util.RemoveAll(auxPath)
args := []string{
"go", "run", path.Join(skiaDir, "infra", "bots", "gen_tasks.go"), auxPath,
fmt.Sprintf("--builder_name_schema=%s", path.Join(skiaDir, "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json")),
fmt.Sprintf("--assets_dir=%s", path.Join(skiaDir, "infra", "bots", "assets")),
fmt.Sprintf("--cfg_file=%s", path.Join(infraBots, "cfg.json")),
fmt.Sprintf("--jobs=%s", path.Join(infraBots, "jobs.json")),
"--logtostderr",
}
test := flag.Lookup("test")
if test != nil && test.Value.String() == "true" {
args = append(args, "--test")
}
if _, err := exec.RunCwd(context.Background(), root, args...); err != nil {
glog.Fatalf("Failed to run gen_tasks.go in skia.git: %s", err)
}
}