github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/apps/distgo/params/build.go (about)

     1  // Copyright 2016 Palantir Technologies, Inc.
     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  package params
    16  
    17  import (
    18  	"github.com/palantir/godel/apps/distgo/pkg/osarch"
    19  )
    20  
    21  type Build struct {
    22  	// Skip specifies whether the build step should be skipped entirely. Its primary use is for products that handle
    23  	// their own build logic in the "dist" step ("dist-only" products).
    24  	Skip bool
    25  
    26  	// Script is the content of a script that is written to file a file and run before this product is built. The
    27  	// contents of this value are written to a file with a header `#!/bin/bash` and executed. The script process
    28  	// inherits the environment variables of the Go process and also has the following environment variables
    29  	// defined:
    30  	//
    31  	//   PROJECT_DIR: the root directory of project
    32  	//   PRODUCT: product name,
    33  	//   VERSION: product version
    34  	//   IS_SNAPSHOT: 1 if the version contains a git hash as part of the string, 0 otherwise
    35  	Script string
    36  
    37  	// MainPkg is the location of the main package for the product relative to the root directory. For example,
    38  	// "./distgo/main".
    39  	MainPkg string
    40  
    41  	// OutputDir is the directory to which the executable is written.
    42  	OutputDir string
    43  
    44  	// BuildArgsScript is the content of a script that is written to a file and run before this product is built
    45  	// to provide supplemental build arguments for the product. The contents of this value are written to a file
    46  	// with a header `#!/bin/bash` and executed. The script process inherits the environment variables of the Go
    47  	// process. Each line of output of the script is provided to the "build" command as a separate argument. For
    48  	// example, the following script would add the arguments "-ldflags" "-X" "main.year=$YEAR" to the build command:
    49  	//
    50  	//   build-args-script: |
    51  	//                      YEAR=$(date +%Y)
    52  	//                      echo "-ldflags"
    53  	//                      echo "-X"
    54  	//                      echo "main.year=$YEAR"
    55  	BuildArgsScript string
    56  
    57  	// VersionVar is the path to a variable that is set with the version information for the build. For example,
    58  	// "github.com/palantir/godel/cmd/godel.Version". If specified, it is provided to the "build" command as an
    59  	// ldflag.
    60  	VersionVar string
    61  
    62  	// Environment specifies values for the environment variables that should be set for the build. For example,
    63  	// the following sets CGO to false:
    64  	//
    65  	//   environment:
    66  	//     CGO_ENABLED: "0"
    67  	Environment map[string]string
    68  
    69  	// OSArchs specifies the GOOS and GOARCH pairs for which the product is built. If blank, defaults to the GOOS
    70  	// and GOARCH of the host system at runtime.
    71  	OSArchs []osarch.OSArch
    72  }