Skip to content

Commit

Permalink
#25 Remove build-all
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Aug 16, 2023
1 parent 9afcf44 commit 485136f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 70 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@

# Go workspace file
go.work

# macOS artifacts
.DS_STORE

# Visual Studio code
.vscode
.history
target/

# Makefile
target/
99 changes: 36 additions & 63 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for go-cmdhelping.

# Detect the operating system and architecture
# Detect the operating system and architecture.

include Makefile.osdetect

Expand All @@ -23,13 +23,13 @@ BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//')
BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//')
GIT_REMOTE_URL := $(shell git config --get remote.origin.url)
GO_PACKAGE_NAME := $(shell echo $(GIT_REMOTE_URL) | sed -e 's|^git@github.com:|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|')
GO_OSARCH = $(subst /, ,$@)
GO_OS = $(word 1, $(GO_OSARCH))
GO_ARCH = $(word 2, $(GO_OSARCH))

# Recursive assignment ('=')

CC = gcc
GO_OSARCH = $(subst /, ,$@)
GO_OS = $(word 1, $(GO_OSARCH))
GO_ARCH = $(word 2, $(GO_OSARCH))

# Conditional assignment. ('?=')
# Can be overridden with "export"
Expand All @@ -41,9 +41,6 @@ LD_LIBRARY_PATH ?= /opt/senzing/g2/lib

.EXPORT_ALL_VARIABLES:

-include Makefile.$(OSTYPE)
-include Makefile.$(OSTYPE)_$(OSARCH)

# -----------------------------------------------------------------------------
# The first "make" target runs as default.
# -----------------------------------------------------------------------------
Expand All @@ -52,8 +49,14 @@ LD_LIBRARY_PATH ?= /opt/senzing/g2/lib
default: help

# -----------------------------------------------------------------------------
# Build
# - The "build" target is implemented in Makefile.OS.ARCH files.
# Operating System / Architecture targets
# -----------------------------------------------------------------------------

-include Makefile.$(OSTYPE)
-include Makefile.$(OSTYPE)_$(OSARCH)

# -----------------------------------------------------------------------------
# Dependency management
# -----------------------------------------------------------------------------

.PHONY: dependencies
Expand All @@ -62,6 +65,11 @@ dependencies:
@go get -t -u ./...
@go mod tidy

# -----------------------------------------------------------------------------
# Build
# - The "build" target is implemented in Makefile.OS.ARCH files.
# - docker-build: https://docs.docker.com/engine/reference/commandline/build/
# -----------------------------------------------------------------------------

PLATFORMS := darwin/amd64 linux/amd64 windows/amd64
$(PLATFORMS):
Expand All @@ -83,45 +91,11 @@ test:
@go test -v -p 1 ./...
# @go test -v ./engineconfiguration

# -----------------------------------------------------------------------------
# docker-build
# - https://docs.docker.com/engine/reference/commandline/build/
# -----------------------------------------------------------------------------

.PHONY: docker-build
docker-build:
@docker build \
--build-arg BUILD_ITERATION=$(BUILD_ITERATION) \
--build-arg BUILD_VERSION=$(BUILD_VERSION) \
--build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \
--build-arg PROGRAM_NAME=$(PROGRAM_NAME) \
--file Dockerfile \
--tag $(DOCKER_IMAGE_NAME) \
--tag $(DOCKER_IMAGE_NAME):$(BUILD_VERSION) \
.


.PHONY: docker-build-package
docker-build-package:
@docker build \
--build-arg BUILD_ITERATION=$(BUILD_ITERATION) \
--build-arg BUILD_VERSION=$(BUILD_VERSION) \
--build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \
--build-arg PROGRAM_NAME=$(PROGRAM_NAME) \
--no-cache \
--file package.Dockerfile \
--tag $(DOCKER_BUILD_IMAGE_NAME) \
.

# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------

.PHONY: run
run:
@go run main.go


.PHONY: docker-run
docker-run:
@docker run \
Expand All @@ -130,16 +104,15 @@ docker-run:
--name $(DOCKER_CONTAINER_NAME) \
$(DOCKER_IMAGE_NAME)


.PHONY: run
run:
@go run main.go

# -----------------------------------------------------------------------------
# Utility targets
# -----------------------------------------------------------------------------

.PHONY: update-pkg-cache
update-pkg-cache:
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)


.PHONY: clean
clean:
@go clean -cache
Expand All @@ -150,26 +123,26 @@ clean:
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true


.PHONY: help
help:
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
@echo "Makefile targets:"
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs


.PHONY: print-make-variables
print-make-variables:
@$(foreach V,$(sort $(.VARIABLES)), \
$(if $(filter-out environment% default automatic, \
$(origin $V)),$(warning $V=$($V) ($(value $V)))))

# -----------------------------------------------------------------------------
# Help
# -----------------------------------------------------------------------------

.PHONY: help
help:
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
@echo "Makefile targets:"
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
.PHONY: setup
setup:
@echo "No setup required."

# -----------------------------------------------------------------------------
# Optionally include platform-specific settings and targets.
# - Note: This is last because the "last one wins" when over-writing targets.
# -----------------------------------------------------------------------------

# -include Makefile.$(OSTYPE)
# -include Makefile.$(OSTYPE)_$(OSARCH)
.PHONY: update-pkg-cache
update-pkg-cache:
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)
2 changes: 1 addition & 1 deletion Makefile.darwin
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ build: darwin/amd64

.PHONY: only-darwin
only-darwin:
@echo "Only darwin has this Makefile target."
@echo "Only darwin has this Makefile target."
2 changes: 1 addition & 1 deletion Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ build: linux/amd64

.PHONY: only-linux
only-linux:
@echo "Only linux has this Makefile target."
@echo "Only linux has this Makefile target."
2 changes: 1 addition & 1 deletion Makefile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ build: windows/amd64

.PHONY: only-windows
only-windows:
@echo "Only windows has this Makefile target."
@echo "Only windows has this Makefile target."
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down

0 comments on commit 485136f

Please sign in to comment.