diff --git a/development/makefiles/changelog.mk b/development/makefiles/changelog.mk index f1d8fed60aa9de2a659c3466bd346aed4cfed89d..c3ae83114f80b47c10e7d99bb4a8c89eefeaa334 100644 --- a/development/makefiles/changelog.mk +++ b/development/makefiles/changelog.mk @@ -17,8 +17,10 @@ endif ifeq ($(GIT_CHGLOG_BIN),) $(shell $(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@latest) + GIT_CHGLOG_BIN := $(shell command -v git-chglog 2> /dev/null) endif + ifneq ($(shell test -d $(GIT_CHGLOG_CONFIG_DIR) && echo -n yes),yes) $(shell mkdir -p $(GIT_CHGLOG_CONFIG_DIR)) endif @@ -135,4 +137,4 @@ $(GIT_CHGLOG_CONFIG_DIR)/CHANGELOG.tpl.md: ## location of CHANGELOG.md file CHANGELOG_FILE ?= $(PROJECT_ROOT)CHANGELOG.md -EXECUTABLES = $(EXECUTABLES:-) $(GIT_CHGLOG_BIN) \ No newline at end of file +EXECUTABLES = $(EXECUTABLES:-) $(GIT_CHGLOG_BIN) diff --git a/development/makefiles/directories-go-lib.mk b/development/makefiles/directories-go-lib.mk new file mode 100644 index 0000000000000000000000000000000000000000..5dd10706f18eb7c8bd9a62a293be4b59d1a59aac --- /dev/null +++ b/development/makefiles/directories-go-lib.mk @@ -0,0 +1,32 @@ +############################################################################################# +############################################################################################# +## +## DIRECTORIES +## +############################################################################################# +############################################################################################# + +APPLICATION_PATH ?= $(PROJECT_ROOT) +DEPLOYMENT_PATH ?= $(PROJECT_ROOT) +DEVELOPMENT_PATH ?= $(PROJECT_ROOT) +DOCUMENTATION_PATH ?= $(PROJECT_ROOT) + +RESOURCE_PATH ?= $(APPLICATION_PATH) +SOURCE_PATH ?= $(APPLICATION_PATH) + +## SCRIPTS_PATH IS DEPRECATED +SCRIPTS_PATH ?= $(DEVELOPMENT_PATH)script/ + +DEVELOPMENT_SCRIPTS_PATH ?= $(DEVELOPMENT_PATH)script/ +BUILD_PATH ?= $(DEPLOYMENT_PATH)build/ +VENDOR_PATH ?= $(DEPLOYMENT_PATH)vendor/ + +DEPLOYMENT_SCRIPTS_PATH ?= $(DEPLOYMENT_PATH)script/ +LICENSE_PATH ?= $(PROJECT_ROOT) + +PROJECT_DIRECTORIES := $(PROJECT_DIRECTORIES) \ + $(APPLICATION_PATH) \ + $(VENDOR_PATH) \ + $(DEVELOPMENT_SCRIPTS_PATH) \ + $(BUILD_PATH) + diff --git a/development/makefiles/go.mk b/development/makefiles/go.mk index 00ff9478e3e0d69e4370abb88dcaca5f88185437..6cb58e936eb9de9c2d1e3a463c9f2233338c7c5f 100644 --- a/development/makefiles/go.mk +++ b/development/makefiles/go.mk @@ -14,3 +14,14 @@ EXECUTABLES = $(EXECUTABLES:-) $(GO); ifeq ($(shell command -v $(GO) 2> /dev/null),) $(error "go is not installed. Please install go <https://go.dev/doc/install>") endif + +GOPATH=$(shell go env GOPATH) + +ifeq ($(GOPATH),) + DIRS := bin pkg src + GOPATH=$(DEPLOYMENT_PATH)/go/ + $(shell mkdir -p $(GOPATH)) + $(shell $(foreach entry,$(DIRS),mkdir -p "$(GOPATH)$(entry)";)) + export PATH=$(PATH):$(GOPATH)/bin +endif + diff --git a/development/makefiles/readme-go-lib.mk b/development/makefiles/readme-go-lib.mk new file mode 100644 index 0000000000000000000000000000000000000000..ae10cdc29efd4bfaa2c8fa0bd6586eb2cc783cee --- /dev/null +++ b/development/makefiles/readme-go-lib.mk @@ -0,0 +1,80 @@ +############################################################################################# +############################################################################################# +## +## README +## +############################################################################################# +############################################################################################# + + +define README_FILE_CONTENT +# $(COMPONENT_NAME) + +$(COMPONENT_NAME) is ... + +## Documentation + +To check out docs and examples, visit .... + +## Installation + +```shell +go get $(shell git config --get remote.origin.url | sed -E 's/^\s*.*:\/\///g') +``` + +**Note:** This library uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies. + +## Usage + +## Contributing + +Merge requests are welcome. For major changes, please open an issue first to discuss what +you would like to change. **Please make sure to update tests as appropriate.** + +Versioning is done with [SemVer](https://semver.org/). +Changelog is generated with [git-chglog](https://github.com/git-chglog/git-chglog#git-chglog) + +Commit messages should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. +Messages are started with a type, which is one of the following: + +- **feat**: A new feature +- **fix**: A bug fix +- **doc**: Documentation only changes +- **refactor**: A code change that neither fixes a bug nor adds a feature +- **perf**: A code change that improves performance +- **test**: Adding missing or correcting existing tests +- **chore**: Other changes that don't modify src or test files + +The footer would be used for a reference to an issue or a breaking change. + +A commit that has a footer `BREAKING CHANGE:`, or appends a ! after the type/scope, +introduces a breaking API change (correlating with MAJOR in semantic versioning). +A BREAKING CHANGE can be part of commits of any type. + +the following is an example of a commit message: + +```text +feat: add 'extras' field +``` + +## Questions + +For questions and commercial support, please contact [schukai GmbH](https://www.schukai.com/). +The issue list of this repo is exclusively for bug reports and feature requests. + +## Issues + +Please make sure to read the Issue Reporting Checklist before opening an +issue. Issues not conforming to the guidelines may be closed immediately. + +## License + +$(COPYRIGHT_TEXT) + +$(COPYRIGHT_URL) + +You can also purchase a commercial license. + + +endef + diff --git a/development/makefiles/readme-go-utilities.mk b/development/makefiles/readme-go-utilities.mk index d9fd70eaef9ef4f0ffaa1f786dd98771d3665ca1..ae10cdc29efd4bfaa2c8fa0bd6586eb2cc783cee 100644 --- a/development/makefiles/readme-go-utilities.mk +++ b/development/makefiles/readme-go-utilities.mk @@ -18,9 +18,44 @@ To check out docs and examples, visit .... ## Installation +```shell +go get $(shell git config --get remote.origin.url | sed -E 's/^\s*.*:\/\///g') +``` + +**Note:** This library uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies. ## Usage +## Contributing + +Merge requests are welcome. For major changes, please open an issue first to discuss what +you would like to change. **Please make sure to update tests as appropriate.** + +Versioning is done with [SemVer](https://semver.org/). +Changelog is generated with [git-chglog](https://github.com/git-chglog/git-chglog#git-chglog) + +Commit messages should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. +Messages are started with a type, which is one of the following: + +- **feat**: A new feature +- **fix**: A bug fix +- **doc**: Documentation only changes +- **refactor**: A code change that neither fixes a bug nor adds a feature +- **perf**: A code change that improves performance +- **test**: Adding missing or correcting existing tests +- **chore**: Other changes that don't modify src or test files + +The footer would be used for a reference to an issue or a breaking change. + +A commit that has a footer `BREAKING CHANGE:`, or appends a ! after the type/scope, +introduces a breaking API change (correlating with MAJOR in semantic versioning). +A BREAKING CHANGE can be part of commits of any type. + +the following is an example of a commit message: + +```text +feat: add 'extras' field +``` ## Questions diff --git a/development/makefiles/target-go-fetch-licenses.mk b/development/makefiles/target-go-fetch-licenses.mk index 242f3d346950f04bdc2ae8bb3d465b0ba9b7ebda..65fe5cdc864b4fafa6cebf21920dff5f65a55a45 100644 --- a/development/makefiles/target-go-fetch-licenses.mk +++ b/development/makefiles/target-go-fetch-licenses.mk @@ -11,16 +11,22 @@ ifeq ($(GO),) endif GO_MOD_FILE := $(SOURCE_PATH)go.mod +GO_LICENSES_BIN := $(shell command -v go-licenses) + + +ifeq ($(GO_LICENSES_BIN),) + $(shell $(GO) install github.com/google/go-licenses@latest) + GO_LICENSES_BIN := $(shell command -v go-licenses 2> /dev/null) + EXECUTABLES = $(EXECUTABLES:-) go-licenses; +endif ifeq ($(shell test -e $(GO_MOD_FILE) && echo -n yes),yes) GO_CURRENT_MODULE := $(shell cat $(GO_MOD_FILE) | head -n1 | cut -d" " -f2) - # go install github.com/google/go-licenses@latest - EXECUTABLES = $(EXECUTABLES:-) go-licenses; endif .PHONY: go-fetch-licenses ## Fetch licenses for all modules -go-fetch-licenses: +go-fetch-licenses: ifeq ($(GO_CURRENT_MODULE),) $(QUIET) $(ECHOERRORMARKER) "no go.mod file found, skipping fetching licenses" else diff --git a/development/makefiles/target-init-go-lib.mk b/development/makefiles/target-init-go-lib.mk new file mode 100644 index 0000000000000000000000000000000000000000..69c165e41024c52086971958f142bdf1df92dec7 --- /dev/null +++ b/development/makefiles/target-init-go-lib.mk @@ -0,0 +1,49 @@ +############################################################################################# +############################################################################################# +## +## INIT-STANDARD +## +############################################################################################# +############################################################################################# + +# @see .PHONY https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets +.PHONY: init-go-lib + +# The default directories are defined in the +# directories-standard.mk file, but all other +# targets can define directories as well. + +$(PROJECT_DIRECTORIES): + $(foreach path,$(PROJECT_DIRECTORIES),\ + $(shell $(MKDIR) -p $(path))) + +## init go lib project +init-go-lib: $(PROJECT_DIRECTORIES) $(PROJECT_ROOT).gitignore $(PROJECT_ROOT)README.md $(LICENSE_PATH)LICENSE + $(ECHOMARKER) "Run init-go-lib" + $(ECHO) "Done" + +############################################################################################# +############################################################################################# +## +## LICENSE +## +############################################################################################# +############################################################################################# + +export LICENSE_FILE_CONTENT +$(LICENSE_PATH)LICENSE: + $(QUIET) $(ECHO) "$$LICENSE_FILE_CONTENT" >> $@ + +############################################################################################# +############################################################################################# +## +## README +## +############################################################################################# +############################################################################################# + +export README_FILE_CONTENT +$(PROJECT_ROOT)README.md: + $(QUIET) $(ECHO) "$$README_FILE_CONTENT" >> $@ + +