Skip to content

Commit

Permalink
Cleanup executable building + generate tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hpidcock committed Apr 23, 2020
1 parent 129b011 commit a3bd790
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_build/
cmd/juju/juju
cmd/jujud/jujud
cmd/builddb/builddb
Expand Down Expand Up @@ -26,4 +27,4 @@ juju-backup-*.tar.gz
.editorconfig
scripts/mgo-run-txn/mgo-run-txn
tests/tmp.*
*.out
*.out
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ $(shell go mod vendor)

PROJECT := github.com/juju/juju
PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PROJECT))
PROJECT_PACKAGES := $(shell go list $(PROJECT)/... | grep -v /vendor/ | grep -v /acceptancetests/ | grep -v mocks)
BUILD_DIR ?= $(PROJECT_DIR)/_build
MAIN_PACKAGES := $(shell go list -f '{{if eq .Name "main" }}{{.ImportPath}}{{end}}' $(PROJECT)/... | grep -v $(PROJECT)$$ | grep -v $(PROJECT)/vendor/ | grep -v $(PROJECT)/acceptancetests/ | grep -v $(PROJECT)/generate/ | grep -v mocks)
PROJECT_PACKAGES := $(shell go list $(PROJECT)/... | grep -v $(PROJECT)$$ | grep -v $(PROJECT)/vendor/ | grep -v $(PROJECT)/acceptancetests/ | grep -v $(PROJECT)/generate/ | grep -v mocks)

# Allow the tests to take longer on arm platforms.
ifeq ($(shell uname -p | sed -E 's/.*(armel|armhf|aarch64|ppc64le|ppc64|s390x).*/golang/'), golang)
Expand Down Expand Up @@ -99,8 +101,8 @@ test: run-tests
run-tests:
## run-tests: Run the unit tests
$(eval TMP := $(shell mktemp -d jj-XXX --tmpdir))
@echo 'go test --tags "$(BUILD_TAGS)" $(CHECK_ARGS) -test.timeout=$(TEST_TIMEOUT) $$PROJECT_PACKAGES -check.v'
@TMPDIR=$(TMP) go test --tags "$(BUILD_TAGS)" $(CHECK_ARGS) -test.timeout=$(TEST_TIMEOUT) $(PROJECT_PACKAGES) -check.v
@echo 'go test -tags "$(BUILD_TAGS)" $(CHECK_ARGS) -test.timeout=$(TEST_TIMEOUT) $$PROJECT_PACKAGES -check.v'
@TMPDIR=$(TMP) go test -tags "$(BUILD_TAGS)" $(CHECK_ARGS) -test.timeout=$(TEST_TIMEOUT) $(PROJECT_PACKAGES) -check.v
@rm -r $(TMP)

install: rebuild-schema go-install
Expand All @@ -112,12 +114,14 @@ clean:

go-install:
## go-install: Install Juju binaries without updating dependencies
@echo 'go install -mod=vendor -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(LINK_FLAGS) -v $$PROJECT_PACKAGES'
@go install -mod=vendor -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(LINK_FLAGS) -v $(PROJECT_PACKAGES)
@echo 'go install -mod=vendor -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(LINK_FLAGS) -v $$MAIN_PACKAGES'
@go install -mod=vendor -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(LINK_FLAGS) -v $(MAIN_PACKAGES)

go-build:
## go-build: Build Juju binaries without updating dependencies
@go build -mod=vendor -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(PROJECT_PACKAGES)
@mkdir -p $(BUILD_DIR)
@echo 'go build -mod=vendor -o $(BUILD_DIR) -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(LINK_FLAGS) -v $$MAIN_PACKAGES'
@go build -mod=vendor -o $(BUILD_DIR) -tags "$(BUILD_TAGS)" $(COMPILE_FLAGS) $(LINK_FLAGS) -v $(MAIN_PACKAGES)

else # --------------------------------

Expand Down Expand Up @@ -150,9 +154,9 @@ rebuild-schema:
## rebuild-schema: Rebuild the schema for clients with the latest facades
@echo "Generating facade schema..."
ifdef SCHEMA_PATH
@go run ./generate/schemagen/schemagen.go "$(SCHEMA_PATH)"
@go run $(PROJECT)/generate/schemagen "$(SCHEMA_PATH)"
else
@go run ./generate/schemagen/schemagen.go \
@go run $(PROJECT)/generate/schemagen \
./apiserver/facades/schema.json
endif

Expand Down Expand Up @@ -195,7 +199,7 @@ else
endif


GOCHECK_COUNT="$(shell go list -f '{{join .Deps "\n"}}' github.com/juju/juju/... | grep -c "gopkg.in/check.v*")"
GOCHECK_COUNT="$(shell go list -f '{{join .Deps "\n"}}' ${PROJECT}/... | grep -c "gopkg.in/check.v*")"
check-deps:
## check-deps: Check dependencies are correct versions
@echo "$(GOCHECK_COUNT) instances of gocheck not in test code"
Expand Down
2 changes: 1 addition & 1 deletion cloud/clouds.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/juju/juju/juju/osenv"
)

//go:generate go run ../generate/filetoconst/filetoconst.go fallbackPublicCloudInfo fallback-public-cloud.yaml fallback_public_cloud.go 2015 cloud
//go:generate go run github.com/juju/juju/generate/filetoconst fallbackPublicCloudInfo fallback-public-cloud.yaml fallback_public_cloud.go 2015 cloud

// AuthType is the type of authentication used by the cloud.
type AuthType string
Expand Down
4 changes: 2 additions & 2 deletions cloudconfig/userdatacfg_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/juju/juju/tools"
)

//go:generate go run ../generate/filetoconst/filetoconst.go UserDataScript windowsuserdatafiles/userdata.ps1 winuserdatawrapper.go 2016 cloudconfig
//go:generate go run ../generate/winuserdata/winuserdata.go 2016 winuserdata.go cloudconfig
//go:generate go run github.com/juju/juju/generate/filetoconst UserDataScript windowsuserdatafiles/userdata.ps1 winuserdatawrapper.go 2016 cloudconfig
//go:generate go run github.com/juju/juju/generate/winuserdata 2016 winuserdata.go cloudconfig

type aclType string

Expand Down
2 changes: 1 addition & 1 deletion testing/certgen/certgen.go → generate/certgen/certgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func main() {
var outputTemplate = template.Must(template.New("").Parse(`// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// MACHINE GENERATED BY github.com/juju/juju/testing/certgen. DO NOT EDIT.
// MACHINE GENERATED BY github.com/juju/juju/generate/certgen. DO NOT EDIT.
package testing
// Generated on {{.GeneratedAt}}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/aws/aws-sdk-go v1.29.8
github.com/bmizerany/pat v0.0.0-20160217103242-c068ca2f0aac
github.com/boltdb/bolt v1.3.1-0.20170131192018-e9cf4fae01b5 // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/coreos/go-systemd/v22 v22.0.0-20200316104309-cb8b64719ae3
github.com/dnaeon/go-vcr v1.0.1 // indirect
github.com/docker/distribution v2.6.0-rc.1.0.20180522175653-f0cc92778478+incompatible
Expand Down
2 changes: 1 addition & 1 deletion provider/vsphere/internal/vsphereclient/createvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/juju/juju/provider/common"
)

//go:generate go run ../../../../generate/filetoconst/filetoconst.go UbuntuOVF ubuntu.ovf ovf_ubuntu.go 2017 vsphereclient
//go:generate go run github.com/juju/juju/generate/filetoconst UbuntuOVF ubuntu.ovf ovf_ubuntu.go 2017 vsphereclient

// NetworkDevice defines a single network device attached to a newly created VM.
type NetworkDevice struct {
Expand Down
2 changes: 1 addition & 1 deletion testing/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"
)

//go:generate go run github.com/juju/juju/testing/certgen
//go:generate go run github.com/juju/juju/generate/certgen

// NewCA returns a random one of the pre-generated certs to speed up
// tests. The comment on the certs are not going to match the args.
Expand Down
2 changes: 1 addition & 1 deletion testing/certs_generated.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

// MACHINE GENERATED BY github.com/juju/juju/testing/certgen. DO NOT EDIT.
// MACHINE GENERATED BY github.com/juju/juju/generate/certgen. DO NOT EDIT.
package testing

// Generated on 08 Apr 20 15:32 AEST
Expand Down

0 comments on commit a3bd790

Please sign in to comment.