# VARIABLES DOCC_ARCHIVES = Doxy*.doccarchive DOCC_ARCHIVES_FOLDER = Resources/Archives DOCC_BUILD_FOLDER = .build/plugins/Swift-DocC/outputs DOCC_TEST_FOLDER = Resources/Archives/Test DOCKER_IMAGE_NAME = doxy-app TARGET_APP = DoxyApp TARGET_LIBRARY = DoxyLibrary # FUNCTIONS define copy-docs @cp -rf $(DOCC_BUILD_FOLDER)/$(DOCC_ARCHIVES) $(1) endef define gen-doc @swift package plugin generate-documentation\ --target $(1)\ --hosting-base-path "archives/$(1)"\ --include-extended-types\ --symbol-graph-minimum-access-level internal\ --enable-inherited-docs endef # PROJECT build: ## Builds the project locally. @swift build -c release run: ## Runs the project locally. @swift run -c release tests: ## Runs all the test cases of the project. @swift test --enable-swift-testing # SWIFT PACKAGE MANAGER clean: ## Deletes built SPM artifacts from the package. @swift package clean outdated: ## Lists the SPM package dependencies that can be updated. @swift package update --dry-run reset: ## Resets the complete SPM cache/build folder from the package. @swift package reset update: ## Updates the SPM package dependencies. @swift package update # DOCUMENTATION build-doc: ## Builds the DocC documentation for the apps and library targets. @$(call gen-doc,$(TARGET_APP)) @$(call gen-doc,$(TARGET_LIBRARY)) @$(call copy-docs,$(DOCC_ARCHIVES_FOLDER)) preview-doc: ## Previews the DocC documentation for the library target. @swift package --disable-sandbox plugin preview-documentation\ --target $(TARGET_LIBRARY)\ --include-extended-types\ --symbol-graph-minimum-access-level internal\ --enable-inherited-docs test-doc: ## Builds the DocC documentation for the app and the library targets in the test folder. @$(call gen-doc,$(TARGET_APP)) @$(call gen-doc,$(TARGET_LIBRARY)) @$(call copy-docs,$(DOCC_TEST_FOLDER)) # DOCKER build-image: ## Builds a docker image out of the current source code @docker compose build mount-image: ## Mounts and starts a docker container locally @docker compose up --detach unmount-image: ## Stops and unmounts a docker container locally @docker compose down @make remove-image remove-image: # Removes the generated Docker images @docker image rm $(shell docker image ls | grep $(DOCKER_IMAGE_NAME) | awk '{print $$1 ":" $$2}') # 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