Commit Graph

43 Commits

Author SHA1 Message Date
Pam Selle 83e6703bf7 Remove revision from version command
The revision field is only populated on dev builds so this means
most releases of Terraform have an empty "terraform_revision" field
in the JSON output. Since we recommend developers use go tooling
to `go build` this tool when developing, the revision is not useful
data and so it is removed.
2021-01-12 16:35:30 -05:00
Julian Grinblat 0b3c0f64c2
build: Allow building on non-terraform named directory (#25340)
* Allow building on non-terraform named directory

* Fix gofmt errors

* Fix generate-plugins.go unused variable error
2020-06-26 12:07:58 -04:00
Alvin Huang ada89661d5 don't update deps of gox in docker build and use -mod=readonly 2020-06-17 15:34:30 -04:00
Sander van Harmelen 03e82687d6 build.sh: only set git commit info for dev builds
This commit fixes a problem where `make bin` would strip of any prerelease info.
2019-02-06 20:32:54 +01:00
Martin Atkins c133de863b build: Update most things for Go 1.11 modules
We're still using vendoring for now until we get _all_ of our tooling
updated, so the main idea here is to force use of the vendor directory
when running tests and building for development so we can quickly find
situations where we forget to run "go mod vendor".

We also setting GO111MODULE=off for installation of tools. Right now this
is the best way to install a tool in GOBIN without also interfering with
go.mod and go.sum, until a better pattern for managing tool dependencies
is devised by the Go team.

Finally, we run "go mod download" before launching "gox" in the main
build process, to prime the local module cache once so that the concurrent
"go build" processes won't race to populate it redundantly. This means
that we'll be producing final builds from the module cache rather than
from vendor as with everything else -- there's currently no way to tell
gox to use -mod=vendor -- but that should be fine in practice since
our go.sum file will ensure that we get the exact sources we expect in
the module cache before building.
2018-11-19 09:02:35 -08:00
Loren Gordon 55d4e460de Uses the current working directory to name the built binary
This patch allows `build.sh` to be used with terraform plugins to
easily create cross-platform packages, using the same method as the
terraform Makefile:

```
mkdir scripts
curl https://raw.githubusercontent.com/hashicorp/terraform/master/scripts/build.sh -o scripts/build.sh
TF_RELEASE=1 sh -c "scripts/build.sh"  # make bin
```
2017-10-30 10:49:47 -07:00
Clint 385e564250 fix build ld_flag (#16430) 2017-10-24 14:10:15 -05:00
Jake Champlin 91ab75991d
core: use codified default for prerelease string 2017-05-22 11:28:15 -04:00
Jake Champlin bd68789006
core: Use environment variables to set VersionPrerelease at compile time
Instead of using a hardcoded version prerelease string, which makes release automation difficult, set the version prerelease string from an environment variable via the go linker tool during compile time.

The environment variable `TF_RELEASE` should only be set via the `make bin` target, and thus leaves the version prerelease string unset. Otherwise, when running a local compile of terraform via the `make dev` makefile target, the version prerelease string is set to `"dev"`, as usual.

This also requires some changes to both the circonus and postgresql providers, as they directly used the `VersionPrerelease` constant. We now simply call the `VersionString()` function, which returns the proper interpolated version string with the prerelease string populated correctly.

`TF_RELEASE` is unset:

```sh
$ make dev
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/05/22 10:38:19 Generated command/internal_plugin_list.go
==> Removing old directory...
==> Building...
Number of parallel builds: 3

-->     linux/amd64: github.com/hashicorp/terraform

==> Results:
total 209M
-rwxr-xr-x 1 jake jake 209M May 22 10:39 terraform

$ terraform version
Terraform v0.9.6-dev (fd472e4a86500606b03c314f70d11f2bc4bc84e5+CHANGES)
```

`TF_RELEASE` is set (mimicking the `make bin` target):

```sh
$ TF_RELEASE=1 make dev
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/05/22 10:40:39 Generated command/internal_plugin_list.go
==> Removing old directory...
==> Building...
Number of parallel builds: 3

-->     linux/amd64: github.com/hashicorp/terraform

==> Results:
total 121M
-rwxr-xr-x 1 jake jake 121M May 22 10:42 terraform

$ terraform version
Terraform v0.9.6
```
2017-05-22 10:49:15 -04:00
James Bardin f85232a239 Remove darwin/386 from the build
There isn't a supported configuration that runs darwin/386, so remove it
from the build.
2016-11-16 13:46:57 -05:00
Jake Champlin 8cbef79dbf Allow specifying ldflags via env vars
Allows specifying `LD_FLAGS` during development builds.

```
$ LD_FLAGS="-linkmode=external" make dev
```

Since the version of DTrace on macOS Sierra (On the public beta's at least) has been updated, this allows DTrace to run on Terraform during development/debugging.

```
$ sudo dtrace -n 'pid$target::main.main:entry' -c "terraform apply"
dtrace: description 'pid$target::main.main:entry' matched 1 probe

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

foo = bar
dtrace: pid 23096 has exited
CPU     ID                    FUNCTION:NAME
  2 265673                  main.main:entry
```

Also redirects the `@which stringer` command inside the `generate` Makefile target to `/dev/null` so we stop echoing the path to the `stringer` binary on every call to `generate`.
2016-08-24 10:56:23 -04:00
James Nugent 11259dee07 build: Exclude darwin/arm from OS/Arch targets
Fixes #8365
2016-08-22 14:34:53 +02:00
Gabi Davar 33b3206ead make linux amd64 binaries static again.
* regression caused by mitchellh/gox#49
* pass CGO_ENABLED=0
2016-06-10 16:23:11 +03:00
Adam Ward 4a29be7b50 Don't assume dev platform was built 2016-05-16 10:00:44 +10:00
Chris Bednarski 6360e6c8b6 Implemented internal plugin calls; which allows us to compile plugins into the main terraform binary 2016-05-10 14:40:11 -04:00
Soren Mathiasen f44706c661 Reduce the size of the binaries 2016-04-19 15:15:56 +02:00
Paul Hinze 0cf6ba6f64 README/Makefile: Mention & auto-install gox 2016-02-25 06:48:43 -06:00
Paul Hinze d21b0897a9 Makefile/docs: Lock in 1.6 req, doc vendored deps
* Drop Go 1.5 compatibility env vars
 * Drop `make updatedeps` from `Makefile` and docs
 * Update README w/ vendored dep instructions
2016-02-24 16:13:49 -06:00
Paul O'Connor e3c6c05395 Put the equals in the correct place 2016-02-17 17:44:38 +01:00
Paul O'Connor 21f15aea3f Use new link ldflags syntax 2016-02-17 17:35:04 +01:00
Paul Hinze 6791172e21 build.sh: don't dive into vendored deps when building
Doing a straight `./...`  build results in errors from unvendored
package references being picked up in some vendored libraries'
`examples/` subdirs.

So we'll switch to the recommended `go list | grep -v /vendor/` strategy
to determine what to build.
2016-02-01 11:28:41 -06:00
Paul Hinze 6fe2703665 Vendor all dependencies w/ Godep
* Remove `make updatedeps` from Travis build. We'll follow up with more
   specific plans around dependency updating in subsequent PRs.
 * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to
   filter out `/vendor/` from `./...` where appropriate.
 * Temporarily remove `vet` from the `make test` target until we can
   figure out how to get it to not vet `vendor/`. (Initial
   experimentation failed to yield the proper incantation.)

Everything is pinned to current master, with the exception of:

 * Azure/azure-sdk-for-go which is pinned before the breaking change today
 * aws/aws-sdk-go which is pinned to the most recent tag

The documentation still needs to be updated, which we can do in a follow
up PR. The goal here is to unblock release.
2016-01-29 15:08:48 -06:00
James Nugent 094e380bb1 Add Solaris builds of Terraform 2016-01-05 09:53:19 -05:00
James Nugent 6d6487e288 Make gofmt errors fail build and add `make fmt`
We may want to consider requiring `gofmt -s` compliance in future
builds, but for now we just use `gofmt`.
2015-12-17 12:35:13 -05:00
Jeff Zellner ac462d2ef1 use /usr/bin/env bash 2015-06-30 11:52:11 -06:00
Mitchell Hashimoto 9422571ca2 update CHANGELOG 2015-05-15 20:36:58 -07:00
Paul Hinze 11280a09b3 Merge pull request #1538 from fatih/build-script-fix
scripts/build.sh: fix GOPATH/bin folder breaking build
2015-04-15 11:50:55 -05:00
Fatih Arslan 0c80207bff scripts/build.sh: fix GOPATH/bin folder breaking build
If GOPATH/bin doesn't exists the build scripts just exists, leaving the
`terraform/bin` folder with only one single binary called `terraform`.
Discovered while setting up a new GOPATH just for terraform.
2015-04-15 19:36:44 +03:00
Eli Shvartsman 44d6123894 get dependencies without installing them
For now, make dev creates in ${MAIN_GOPATH}/bin/ files like 'provider-google' alongside with 'terraform-provider-google'.
If we decided to build plugins with custom names and install them manually with 'cp' command, it could make sense not to do it here.
2015-04-15 13:08:37 +03:00
Jeff Mitchell 996e7ff3e4 Add quickdev option; skips getting dependencies to make repeated builds a bit faster and less network-heavy 2015-03-06 17:07:16 +00:00
Joseph Anthony Pasquale Holsten 29a91c7db7 quote $DIR to allow $GOPATH to include spaces 2014-11-25 15:26:41 -08:00
Mitchell Hashimoto 5152f05d0a scripts: copy binaries to gopath 2014-09-29 18:18:14 -07:00
Mitchell Hashimoto 32c88dce4a scripts: make bin/ dir 2014-08-31 09:31:57 -07:00
Mitchell Hashimoto 1b191a5183 scripts: fix dev build 2014-08-28 16:47:14 -07:00
Mitchell Hashimoto e7e60cb493 scripts: quiet 2014-08-28 10:21:13 -07:00
Mitchell Hashimoto f67dfce2ae scripts: fix extension in file copy for build 2014-08-28 10:20:49 -07:00
Mitchell Hashimoto 0b5b971f8e scripts: build script cross compiles 2014-08-28 09:54:09 -07:00
Mitchell Hashimoto f46d3ff332 scripts: don't copy libucl.dll anymore 2014-08-19 10:02:29 -07:00
Mitchell Hashimoto b569a5d8b6 scripts: build script 2014-07-28 10:54:25 -07:00
Mitchell Hashimoto 8cd4814beb scripts: unix line endings 2014-06-26 10:07:31 -07:00
Mitchell Hashimoto d02cf6d979 scripts: make build.sh executable 2014-06-26 10:07:08 -07:00
Mitchell Hashimoto 38d4f2a1bd scripts: human-readable sizes 2014-05-29 17:52:06 -07:00
Mitchell Hashimoto effe895d22 scripts: build script 2014-05-29 17:51:11 -07:00