blob: 933e525aeb536ea64e49d98c01d4765c935406dc [file] [log] [blame]
Colin Cross68f55102015-03-25 14:43:57 -07001// Copyright 2015 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// soong_glob is the command line tool that checks if the list of files matching a glob has
16// changed, and only updates the output file list if it has changed. It is used to optimize
17// out build.ninja regenerations when non-matching files are added. See
18// android/soong/common/glob.go for a longer description.
19package main
20
21import (
22 "flag"
23 "fmt"
24 "os"
25
26 "android/soong/env"
27)
28
29func usage() {
30 fmt.Fprintf(os.Stderr, "usage: soong_env env_file\n")
31 fmt.Fprintf(os.Stderr, "exits with success if the environment varibles in env_file match\n")
32 fmt.Fprintf(os.Stderr, "the current environment\n")
33 flag.PrintDefaults()
34 os.Exit(2)
35}
36
37func main() {
38 flag.Parse()
39
40 if flag.NArg() != 1 {
41 usage()
42 }
43
44 stale, err := env.StaleEnvFile(flag.Arg(0))
45 if err != nil {
46 fmt.Fprintf(os.Stderr, "error: %s\n", err.Error())
47 os.Exit(1)
48 }
49
50 if stale {
51 os.Exit(1)
52 }
53
54 os.Exit(0)
55}