From 78bcc70195704bdc9d9bce95832a93ae43678b9d Mon Sep 17 00:00:00 2001 From: Michael Dockter Date: Tue, 5 Dec 2023 15:12:34 -0500 Subject: [PATCH] 111.dockter.1 (#112) * #111 Refactor Makefiles to directory * #111 Refactor Makefiles to directory * #111 Refactor Makefiles to directory * #111 Refactor Makefiles to directory * #111 Refactor Makefiles to directory --- .../docker-push-containers-to-dockerhub.yaml | 1 + Makefile | 11 ++++++----- README.md | 2 +- Makefile.darwin => makefiles/darwin.mk | 2 +- makefiles/darwin_arm64.mk | 16 ++++++++++++++++ makefiles/darwin_x86_64.mk | 16 ++++++++++++++++ Makefile.linux => makefiles/linux.mk | 2 +- makefiles/linux_arm64.mk | 16 ++++++++++++++++ makefiles/linux_x86_64.mk | 16 ++++++++++++++++ Makefile.osdetect => makefiles/osdetect.mk | 0 Makefile.windows => makefiles/windows.mk | 2 +- makefiles/windows_arm64.mk | 17 +++++++++++++++++ makefiles/windows_x86_64.mk | 17 +++++++++++++++++ 13 files changed, 109 insertions(+), 9 deletions(-) rename Makefile.darwin => makefiles/darwin.mk (98%) create mode 100644 makefiles/darwin_arm64.mk create mode 100644 makefiles/darwin_x86_64.mk rename Makefile.linux => makefiles/linux.mk (98%) create mode 100644 makefiles/linux_arm64.mk create mode 100644 makefiles/linux_x86_64.mk rename Makefile.osdetect => makefiles/osdetect.mk (100%) rename Makefile.windows => makefiles/windows.mk (98%) create mode 100644 makefiles/windows_arm64.mk create mode 100644 makefiles/windows_x86_64.mk diff --git a/.github/workflows/docker-push-containers-to-dockerhub.yaml b/.github/workflows/docker-push-containers-to-dockerhub.yaml index 15a1d5e..7d7b43f 100644 --- a/.github/workflows/docker-push-containers-to-dockerhub.yaml +++ b/.github/workflows/docker-push-containers-to-dockerhub.yaml @@ -16,4 +16,5 @@ jobs: image-repository: senzing/test-ground image-tag: ${{ github.ref_name }} password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + platforms: "linux/amd64,linux/arm64" username: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/Makefile b/Makefile index 81ab15e..980d2fe 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Detect the operating system and architecture. -include Makefile.osdetect +include makefiles/osdetect.mk # ----------------------------------------------------------------------------- # Variables @@ -12,7 +12,7 @@ include Makefile.osdetect # PROGRAM_NAME is the name of the GIT repository. PROGRAM_NAME := $(shell basename `git rev-parse --show-toplevel`) -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +MAKEFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST))) MAKEFILE_DIRECTORY := $(shell dirname $(MAKEFILE_PATH)) TARGET_DIRECTORY := $(MAKEFILE_DIRECTORY)/target DOCKER_CONTAINER_NAME := $(PROGRAM_NAME) @@ -52,8 +52,8 @@ default: help # Operating System / Architecture targets # ----------------------------------------------------------------------------- --include Makefile.$(OSTYPE) --include Makefile.$(OSTYPE)_$(OSARCH) +-include makefiles/$(OSTYPE).mk +-include makefiles/$(OSTYPE)_$(OSARCH).mk .PHONY: hello-world @@ -74,7 +74,7 @@ dependencies: # - docker-build: https://docs.docker.com/engine/reference/commandline/build/ # ----------------------------------------------------------------------------- -PLATFORMS := darwin/amd64 linux/amd64 windows/amd64 +PLATFORMS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64 $(PLATFORMS): @echo Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME) @GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -o $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME) @@ -87,6 +87,7 @@ build: build-osarch-specific .PHONY: build-all $(PLATFORMS) build-all: $(PLATFORMS) @mv $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME) $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME).exe + @mv $(TARGET_DIRECTORY)/windows-arm64/$(PROGRAM_NAME) $(TARGET_DIRECTORY)/windows-arm64/$(PROGRAM_NAME).exe .PHONY: build-scratch diff --git a/README.md b/README.md index 773952d..0d69508 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ It also shows best practices that can be retro-fitted into existing repositories [![gosec.yaml](https://github.com/Senzing/template-go/actions/workflows/gosec.yaml/badge.svg)](https://github.com/Senzing/template-go/actions/workflows/gosec.yaml) [![go-test-linux.yaml](https://github.com/Senzing/template-go/actions/workflows/go-test-linux.yaml/badge.svg)](https://github.com/Senzing/template-go/actions/workflows/go-test-linux.yaml) [![go-test-darwin.yaml](https://github.com/Senzing/template-go/actions/workflows/go-test-darwin.yaml/badge.svg)](https://github.com/Senzing/template-go/actions/workflows/go-test-darwin.yaml) -[![bob-go-test-windows.yaml](https://github.com/Senzing/template-go/actions/workflows/go-test-windows.yaml/badge.svg)](https://github.com/Senzing/template-go/actions/workflows/go-test-windows.yaml) +[![go-test-windows.yaml](https://github.com/Senzing/template-go/actions/workflows/go-test-windows.yaml/badge.svg)](https://github.com/Senzing/template-go/actions/workflows/go-test-windows.yaml) ## Overview diff --git a/Makefile.darwin b/makefiles/darwin.mk similarity index 98% rename from Makefile.darwin rename to makefiles/darwin.mk index 97c74e1..0297f33 100644 --- a/Makefile.darwin +++ b/makefiles/darwin.mk @@ -11,7 +11,7 @@ LD_LIBRARY_PATH := $(SENZING_TOOLS_SENZING_DIRECTORY)/lib:$(SENZING_TOOLS_SENZIN DYLD_LIBRARY_PATH := $(LD_LIBRARY_PATH) # ----------------------------------------------------------------------------- -# OS-ARCH specific targets +# OS specific targets # ----------------------------------------------------------------------------- .PHONY: build-osarch-specific diff --git a/makefiles/darwin_arm64.mk b/makefiles/darwin_arm64.mk new file mode 100644 index 0000000..420cd03 --- /dev/null +++ b/makefiles/darwin_arm64.mk @@ -0,0 +1,16 @@ +# Makefile extensions for darwin-arm64. + +# ----------------------------------------------------------------------------- +# OS-ARCH specific targets +# ----------------------------------------------------------------------------- + +.PHONY: build-osarch-specific +build-osarch-specific: darwin/arm64 + +# ----------------------------------------------------------------------------- +# Makefile targets supported only by this platform. +# ----------------------------------------------------------------------------- + +.PHONY: only-darwin-arm64 +only-darwin-arm64: + @echo "Only darwin-arm64 has this Makefile target." diff --git a/makefiles/darwin_x86_64.mk b/makefiles/darwin_x86_64.mk new file mode 100644 index 0000000..6ce96f2 --- /dev/null +++ b/makefiles/darwin_x86_64.mk @@ -0,0 +1,16 @@ +# Makefile extensions for darwin-x86_64. + +# ----------------------------------------------------------------------------- +# OS-ARCH specific targets +# ----------------------------------------------------------------------------- + +.PHONY: build-osarch-specific +build-osarch-specific: darwin/amd64 + +# ----------------------------------------------------------------------------- +# Makefile targets supported only by this platform. +# ----------------------------------------------------------------------------- + +.PHONY: only-darwin-x86_64 +only-darwin-x86_64: + @echo "Only darwin-x86_64 has this Makefile target." diff --git a/Makefile.linux b/makefiles/linux.mk similarity index 98% rename from Makefile.linux rename to makefiles/linux.mk index f9b2fb4..34a4eb2 100644 --- a/Makefile.linux +++ b/makefiles/linux.mk @@ -6,7 +6,7 @@ # ----------------------------------------------------------------------------- -# OS-ARCH specific targets +# OS specific targets # ----------------------------------------------------------------------------- .PHONY: build-osarch-specific diff --git a/makefiles/linux_arm64.mk b/makefiles/linux_arm64.mk new file mode 100644 index 0000000..9d0bcb1 --- /dev/null +++ b/makefiles/linux_arm64.mk @@ -0,0 +1,16 @@ +# Makefile extensions for linux-arm64. + +# ----------------------------------------------------------------------------- +# OS-ARCH specific targets +# ----------------------------------------------------------------------------- + +.PHONY: build-osarch-specific +build-osarch-specific: linux/arm64 + +# ----------------------------------------------------------------------------- +# Makefile targets supported only by this platform. +# ----------------------------------------------------------------------------- + +.PHONY: only-linux-arm64 +only-linux-arm64: + @echo "Only linux-arm64 has this Makefile target." diff --git a/makefiles/linux_x86_64.mk b/makefiles/linux_x86_64.mk new file mode 100644 index 0000000..cd36983 --- /dev/null +++ b/makefiles/linux_x86_64.mk @@ -0,0 +1,16 @@ +# Makefile extensions for linux-x86_64. + +# ----------------------------------------------------------------------------- +# OS-ARCH specific targets +# ----------------------------------------------------------------------------- + +.PHONY: build-osarch-specific +build-osarch-specific: linux/amd64 + +# ----------------------------------------------------------------------------- +# Makefile targets supported only by this platform. +# ----------------------------------------------------------------------------- + +.PHONY: only-linux-x86_64 +only-linux-x86_64: + @echo "Only linux-x86_64 has this Makefile target." diff --git a/Makefile.osdetect b/makefiles/osdetect.mk similarity index 100% rename from Makefile.osdetect rename to makefiles/osdetect.mk diff --git a/Makefile.windows b/makefiles/windows.mk similarity index 98% rename from Makefile.windows rename to makefiles/windows.mk index ab40b78..156afa6 100644 --- a/Makefile.windows +++ b/makefiles/windows.mk @@ -6,7 +6,7 @@ # ----------------------------------------------------------------------------- -# OS-ARCH specific targets +# OS specific targets # ----------------------------------------------------------------------------- .PHONY: build-osarch-specific diff --git a/makefiles/windows_arm64.mk b/makefiles/windows_arm64.mk new file mode 100644 index 0000000..bde8009 --- /dev/null +++ b/makefiles/windows_arm64.mk @@ -0,0 +1,17 @@ +# Makefile extensions for windows-arm64. + +# ----------------------------------------------------------------------------- +# OS-ARCH specific targets +# ----------------------------------------------------------------------------- + +.PHONY: build-osarch-specific +build-osarch-specific: windows/arm64 + @mv $(TARGET_DIRECTORY)/windows-arm64/$(PROGRAM_NAME) $(TARGET_DIRECTORY)/windows-arm64/$(PROGRAM_NAME).exe + +# ----------------------------------------------------------------------------- +# Makefile targets supported only by this platform. +# ----------------------------------------------------------------------------- + +.PHONY: only-windows-arm64 +only-windows-arm64: + @echo "Only windows-arm64 has this Makefile target." diff --git a/makefiles/windows_x86_64.mk b/makefiles/windows_x86_64.mk new file mode 100644 index 0000000..39f9ac7 --- /dev/null +++ b/makefiles/windows_x86_64.mk @@ -0,0 +1,17 @@ +# Makefile extensions for windows. + +# ----------------------------------------------------------------------------- +# OS-ARCH specific targets +# ----------------------------------------------------------------------------- + +.PHONY: build-osarch-specific +build-osarch-specific: windows/amd64 + @mv $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME) $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME).exe + +# ----------------------------------------------------------------------------- +# Makefile targets supported only by this platform. +# ----------------------------------------------------------------------------- + +.PHONY: only-windows-x86_64 +only-windows-x86_64: + @echo "Only windows-x86_64 has this Makefile target."