Use an explicit path to Swift from Swiftly (#594)

Prior to this change, `make vmintid` failed with `which swift` equals to
`/usr/bin/swift`:

>
/Users/Dmitry/Apple/containerization/vminitd/.build/checkouts/swift-protobuf/Sources/SwiftProtobuf/AnyMessageStorage.swift:16:8:
error: compiled module was created by an older version of the compiler;
rebuild 'Foundation' and try again:
/Users/Dmitry/Library/org.swift.swiftpm/swift-sdks/swift-6.3-DEVELOPMENT-SNAPSHOT-2026-02-27-a_static-linux-0.1.0.artifactbundle/swift-6.3-DEVELOPMENT-SNAPSHOT-2026-02-27-a_static-linux-0.1.0/swift-linux-musl/musl-1.2.5.sdk/aarch64/usr/lib/swift_static/linux-static/Foundation.swiftmodule/aarch64-swift-linux-musl.swiftmodule

With an explicit path to Swift from Swiftly, `make vminitd` works both
with `which swift` equals to `~/.swiftly/bin/swift` or `/usr/bin/swift`.
This commit is contained in:
Dmitry Kovba authored and GitHub committed 2026-03-23 16:38:48 -07:00
1 parent d1b5bdb166
commit 2c79ff681f
1 file changed
+6 -5
+6 -5
View File
@@ -24,7 +24,8 @@ SWIFT_SDK_PATH := /tmp/$(notdir $(SWIFT_SDK_URL))
SWIFTLY_URL := https://download.swift.org/swiftly/darwin/swiftly.pkg
SWIFTLY_FILENAME := $(notdir $(SWIFTLY_URL))
SWIFTLY_BIN_DIR ?= ~/.swiftly/bin
BUILD_BIN_DIR := $(shell swift build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --show-bin-path)
SWIFT := $(SWIFTLY_BIN_DIR)/swift
BUILD_BIN_DIR := $(shell $(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --show-bin-path)
SYSTEM_TYPE := $(shell uname -s)
ifeq ($(SYSTEM_TYPE),Darwin)
@@ -41,8 +42,8 @@ all:
@mkdir -p ./bin/
@rm -f ./bin/vminitd
@rm -f ./bin/vmexec
@swift --version
@swift build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION)
@$(SWIFT) --version
@$(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION)
@install "$(BUILD_BIN_DIR)/vminitd" ./bin/
@install "$(BUILD_BIN_DIR)/vmexec" ./bin/
@@ -70,7 +71,7 @@ swift: swiftly
linux-sdk: swift
@echo Installing Static Linux SDK...
@curl -L -o $(SWIFT_SDK_PATH) $(SWIFT_SDK_URL)
-@swift sdk install $(SWIFT_SDK_PATH)
-@$(SWIFT) sdk install $(SWIFT_SDK_PATH)
@rm $(SWIFT_SDK_PATH)
.PHONY: macos-sdk
@@ -96,4 +97,4 @@ clean:
@echo Cleaning the vminitd build files...
@rm -f ./bin/vminitd
@rm -f ./bin/vmexec
@swift package clean $(SWIFT_CONFIGURATION)
@rm -rf .build