Serge Bazanski | 4b1e37c | 2021-09-28 12:49:15 +0200 | [diff] [blame] | 1 | // Copyright 2020 The Monogon Project Authors. |
| 2 | // |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | |
| 17 | // fietsje is the standalone command line tool which calls into the Fietsje |
| 18 | // library (//build/fietsje) to perform actual work. The split between cli and |
| 19 | // main library is used so that Fietsje can be called from other Go tooling |
| 20 | // without having to shell out to a binary. |
| 21 | package main |
| 22 | |
| 23 | import ( |
| 24 | "log" |
| 25 | "os" |
| 26 | "path" |
| 27 | |
| 28 | "source.monogon.dev/build/fietsje" |
| 29 | "source.monogon.dev/build/toolbase" |
| 30 | "source.monogon.dev/build/toolbase/gotoolchain" |
| 31 | ) |
| 32 | |
| 33 | func main() { |
| 34 | // Get absolute path of Monogon workspace directory currently operating on |
| 35 | // (either via bazel run or by running it directly in the root of a checkout), |
| 36 | // use it to build paths to shelf.pb.txt and repositories.bzl. |
| 37 | wd, err := toolbase.WorkspaceDirectory() |
| 38 | if err != nil { |
| 39 | log.Fatalf("%v", err) |
| 40 | } |
| 41 | shelfPath := path.Join(wd, "third_party/go/shelf.pb.text") |
| 42 | repositoriesBzlPath := path.Join(wd, "third_party/go/repositories.bzl") |
| 43 | // Set GOROOT as required by fietsje/go-the-tool. |
| 44 | os.Setenv("GOROOT", gotoolchain.Root) |
| 45 | |
| 46 | if err := fietsje.Monogon(shelfPath, repositoriesBzlPath); err != nil { |
| 47 | log.Fatal(err) |
| 48 | } |
| 49 | } |