blob: c3a00110f4d983d112b6bf58921b78ca7243ea55 [file] [log] [blame]
// Copyright 2019 The Fuchsia 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
// WARNING THIS IS EXPERIMENTAL.
//
// Please do not share this tool as something this is ready for widespread use within the
// Fuchsia team.
//
// This is a tool for generating textproto configurations from starlark code. It uses an
// interpreter with custom Fuchsia-specific protobufs baked in. It is separate from the
// `lucicfg` interpreter to allow us to iterate quickly on recipe textproto configs
// without having to send commits to Chromium repos and roll new versions of `lucicfg`
// whenever we add a new recipe API or make changes to an existing API.
//
// This is intended for use by fuchsia-infra-team only and others that urgently need to
// update generated configs. Eventually we will delete this interpreter in favor of using
// lucicfg directly when our APIs are stabilized. The LUCI team is aware that our plan is
// to ultimately delete this tool in the near future.
//
// Example: go run ./cmd/fxicfg generate ./fxicfg/testdata/main.star
import (
"context"
"flag"
"os"
"github.com/google/subcommands"
"go.starlark.net/resolve"
)
func main() {
// Enable not-yet-standard Starlark features.
resolve.AllowLambda = true
resolve.AllowNestedDef = true
resolve.AllowFloat = true
resolve.AllowSet = true
subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(subcommands.FlagsCommand(), "")
subcommands.Register(&GenerateCommand{}, "")
flag.Parse()
os.Exit(int(subcommands.Execute(context.Background())))
}