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