diff options
| author | Tommaso Negri <me@tommasongr.com> | 2026-08-28 10:02:40 +0200 |
|---|---|---|
| committer | Tommaso Negri <me@tommasongr.com> | 2026-08-28 10:02:40 +0200 |
| commit | 6fb37c1e64ac8b0effe810f61eda8c6bd6ce58f1 (patch) | |
| tree | 6e580212b4a28452b83aaa5995bdf486d8e97f44 /Sources | |
| parent | 90028519d6dfd95058900a9acb091fe8efd712b5 (diff) | |
| download | bar-6fb37c1e64ac8b0effe810f61eda8c6bd6ce58f1.tar.gz bar-6fb37c1e64ac8b0effe810f61eda8c6bd6ce58f1.zip | |
improve Makefile
Diffstat (limited to 'Sources')
| -rw-r--r-- | Sources/bar/bar.docc/Makefile | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Sources/bar/bar.docc/Makefile b/Sources/bar/bar.docc/Makefile new file mode 100644 index 0000000..5b6bcac --- /dev/null +++ b/Sources/bar/bar.docc/Makefile @@ -0,0 +1,55 @@ +MODULE := bar + +# Auto-detect docc binary: prefer standalone, fall back to xcrun +DOCC := $(shell which docc 2>/dev/null || echo "xcrun docc") + +# Resolve paths relative to the package root, regardless of where make is invoked. +PKG_ROOT := $(abspath $(dir $(firstword $(MAKEFILE_LIST)))/../../..) + +# SwiftPM emits symbol graphs for every module in the dependency graph. docc +# would then process dependency symbols too (e.g. FuzzyMatch), producing +# unrelated warnings. We emit into a staging dir and copy only our module's +# graphs into the directory docc actually reads. +SYMBOL_GRAPH_DIR := $(PKG_ROOT)/.build/symbolgraph +SYMBOL_GRAPH_STAGE := $(PKG_ROOT)/.build/symbolgraph-stage +DOCC_SOURCE := $(PKG_ROOT)/Sources/$(MODULE)/$(MODULE).docc + +.DEFAULT_GOAL := build + +# Build the project and emit symbol graphs via SwiftPM itself. +# This works for executable targets (which don't always emit a standalone +# .swiftmodule into the Modules dir), unlike invoking swift-symbolgraph-extract +# directly with -I <Modules>. +.PHONY: symbol-graphs +symbol-graphs: + swift package --package-path $(PKG_ROOT) clean + rm -rf $(SYMBOL_GRAPH_DIR) $(SYMBOL_GRAPH_STAGE) + mkdir -p $(SYMBOL_GRAPH_STAGE) + swift build \ + --package-path $(PKG_ROOT) \ + -Xswiftc -emit-symbol-graph \ + -Xswiftc -emit-symbol-graph-dir \ + -Xswiftc $(SYMBOL_GRAPH_STAGE) \ + -Xswiftc -symbol-graph-minimum-access-level \ + -Xswiftc internal + mkdir -p $(SYMBOL_GRAPH_DIR) + cp $(SYMBOL_GRAPH_STAGE)/$(MODULE).symbols.json $(SYMBOL_GRAPH_STAGE)/$(MODULE)@*.symbols.json $(SYMBOL_GRAPH_DIR)/ + +.PHONY: preview +preview: symbol-graphs + $(DOCC) preview $(DOCC_SOURCE) \ + --additional-symbol-graph-dir $(SYMBOL_GRAPH_DIR) \ + --fallback-default-module-kind Tool \ + --output-dir $(PKG_ROOT)/.docc-build + +.PHONY: build +build: symbol-graphs + $(DOCC) convert $(DOCC_SOURCE) \ + --additional-symbol-graph-dir $(SYMBOL_GRAPH_DIR) \ + --fallback-default-module-kind Tool \ + --transform-for-static-hosting \ + --hosting-base-path $(MODULE) \ + --output-path $(PKG_ROOT)/.docs \ + --source-service github \ + --source-service-base-url https://github.com/paninihouse/$(MODULE)/blob/master \ + --checkout-path ~/Developer/paninihouse/tools/$(MODULE)/ |
