From 3c8ed9b9bcab01d958a8253590fd3e2d4e912b27 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 18 Sep 2025 17:36:06 +0200 Subject: [PATCH] Added the Makefile and its respective .env files to the project. --- .env | 22 +++++++++++++ Makefile | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 .env create mode 100644 Makefile diff --git a/.env b/.env new file mode 100644 index 0000000..1dde1ce --- /dev/null +++ b/.env @@ -0,0 +1,22 @@ +# ===----------------------------------------------------------------------=== +# +# This source file is part of the Hummingbird DocC Middleware open source project +# +# Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors +# Licensed under the EUPL 1.2 or later. +# +# See LICENSE for license information +# See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors +# +# ===----------------------------------------------------------------------=== + +# --- DOCUMENTATION --- + +DOCC_GITHUB_OUTPUT=./docs +DOCC_GITHUB_BASE_PATH=hummingbird-docc-middleware +DOCC_PREVIEW_URL=http://localhost:8080/documentation/doccmiddleware +DOCC_XCODE_OUTPUT=./${SPM_LIBRARY_TARGET}.doccarchive + +# -- SWIFT PACKAGE MANAGER --- + +SPM_LIBRARY_TARGET=DocCMiddleware \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e11e383 --- /dev/null +++ b/Makefile @@ -0,0 +1,98 @@ +# ===----------------------------------------------------------------------=== +# +# This source file is part of the Hummingbird DocC Middleware open source project +# +# Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors +# Licensed under the EUPL 1.2 or later. +# +# See LICENSE for license information +# See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors +# +# ===----------------------------------------------------------------------=== + +# ENVIRONMENT VARIABLES + +environment ?= .env + +include $(environment) +export $(shell sed 's/=.*//' $(environment)) + +# LIBRARY + +lib-build: ## Builds the library + @swift build + +lib-release: ## Releases the library + @swift build -c release + +lib-test: ## Runs the unit tests for the library + @swift test \ + --disable-xctest \ + --enable-code-coverage \ + --enable-swift-testing \ + --parallel + +# SWIFT PACKAGE MANAGER + +pkg-clean: ## Deletes built SPM artifacts of the package + @swift package clean + +pkg-reset: ## Resets the complete SPM cache/build folder of the package + @swift package reset + +pkg-pristine: pkg-clean pkg-reset ## Deletes all built artifacts, caches, and documentations of the package + @rm -drf $(DOCC_GITHUB_OUTPUT) + @rm -drf $(DOCC_XCODE_OUTPUT) + +pkg-outdated: ## Lists the SPM package dependencies that can be updated + @swift package update --dry-run + +pkg-update: ## Updates the SPM package dependencies + @swift package update + +# DOCUMENTATION + +doc-generate: doc-generate-xcode doc-generate-github ## Generates the library documentation for both Github and Xcode + +doc-generate-github: ## Generates the library documentation for Github + @swift package \ + --allow-writing-to-directory $(DOCC_GITHUB_OUTPUT) \ + generate-documentation \ + --target $(SPM_LIBRARY_TARGET) \ + --disable-indexing \ + --transform-for-static-hosting \ + --hosting-base-path $(DOCC_GITHUB_BASE_PATH) \ + --output-path $(DOCC_GITHUB_OUTPUT) + +doc-generate-xcode: ## Generates the library documentation for Xcode + @swift package \ + --allow-writing-to-directory $(DOCC_XCODE_OUTPUT) \ + generate-documentation \ + --target $(SPM_LIBRARY_TARGET) \ + --output-path $(DOCC_XCODE_OUTPUT) + +doc-preview: ## Previews the library documentation in Safari + @open -a safari $(DOCC_PREVIEW_URL) + @swift package \ + --disable-sandbox \ + preview-documentation \ + --target $(SPM_LIBRARY_TARGET) + +# IDE + +ide-xcode: ## Opens this package with Xcode + @open -a Xcode Package.swift + +ide-vscode: ## Opens this package with Visual Studio Code + @code . + +# HELP + +# Output the documentation for each of the defined tasks when `help` is called. +# Reference: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +.PHONY: help + +help: ## Prints the written documentation for all the defined tasks + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +.DEFAULT_GOAL := help