105 lines
3.1 KiB
Makefile
105 lines
3.1 KiB
Makefile
# VARIABLES
|
|
|
|
BINARY_BUILD_FOLDER = .build/release
|
|
BINARY_INSTALL_FOLDER = /usr/local/bin
|
|
BINARY_NAME_EXECUTABLE = doxy
|
|
DOCC_ARCHIVES = Doxy*.doccarchive
|
|
DOCC_ARCHIVES_FOLDER = Resources/Archives
|
|
DOCC_BUILD_FOLDER = .build/plugins/Swift-DocC/outputs
|
|
DOCKER_IMAGE_NAME = doxy-app
|
|
TARGET_APP = DoxyApp
|
|
TARGET_LIBRARY = DoxyLibrary
|
|
|
|
# FUNCTIONS
|
|
|
|
define copy-archives
|
|
@cp -rf $(DOCC_BUILD_FOLDER)/$(DOCC_ARCHIVES) $(1)
|
|
endef
|
|
|
|
define generate-archive
|
|
@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
|
|
|
|
outdated: ## Lists the SPM package dependencies that can be updated.
|
|
@swift package update --dry-run
|
|
|
|
update: ## Updates the SPM package dependencies.
|
|
@swift package update
|
|
|
|
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
|
|
|
|
install: build ## Installs the built executable into the local system.
|
|
@install -d $(BINARY_BUILD_FOLDER)
|
|
@install "$(BINARY_BUILD_FOLDER)/$(BINARY_NAME_EXECUTABLE)" "$(BINARY_INSTALL_FOLDER)"
|
|
|
|
uninstall: ## Uninstalls the built executable from the local system.
|
|
@rm -rf "$(BINARY_INSTALL_FOLDER)/$(BINARY_NAME_EXECUTABLE)"
|
|
|
|
# SWIFT PACKAGE MANAGER
|
|
|
|
clean: ## Deletes built SPM artifacts from the package.
|
|
@swift package clean
|
|
|
|
reset: ## Resets the complete SPM cache/build folder from the package.
|
|
@swift package reset
|
|
|
|
purge: ## Purges the global repository cache.
|
|
@swift package purge-cache
|
|
|
|
pristine: clean reset purge ## Cleans up all built archifacts and generated documentations from the project.
|
|
@rm -drf $(DOCC_ARCHIVES_FOLDER)/$(DOCC_ARCHIVES)
|
|
|
|
# DOCUMENTATION
|
|
|
|
build-doc: ## Builds the DocC documentation for the apps and library targets.
|
|
@$(call generate-archive,$(TARGET_APP))
|
|
@$(call generate-archive,$(TARGET_LIBRARY))
|
|
@$(call copy-archives,$(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
|
|
|
|
# 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
|