Skip to content

Commit

Permalink
eXcode: clean up swiftc/SPM configuration
Browse files Browse the repository at this point in the history
relates to #39
  • Loading branch information
kfix committed Feb 13, 2022
1 parent 84585b0 commit 19d6266
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ include eXcode.mk
mk := $(firstword $(MAKEFILE_LIST))
$(info )
$(info [$(mk)])
$(info SPM options: $(swiftbuild))
spm_build := $(shell $(swiftbuild) --show-bin-path)
$(info $(platform) => $(spm_build))

appdir := $(outdir)/apps

Expand Down Expand Up @@ -92,9 +89,7 @@ webkitdir ?= /System/Library/Frameworks/WebKit.framework
jscdir ?= /System/Library/Frameworks/JavaScriptCore.framework

webkitver := $(shell defaults read "$(webkitdir)/Resources/Info" CFBundleVersion)
xcodever := $(shell defaults read "$(xcode)/Contents/Info" CFBundleShortVersionString)
$(info $(webkitdir) => $(webkitver))
$(info $(xcode) => $(xcodever))

ifeq (iphonesimulator, $(sdk))
codesign :=
Expand Down
31 changes: 21 additions & 10 deletions eXcode.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,36 @@ $(info [$(eXcode)] $$(sdk) := $(sdk))
$(info [$(eXcode)] $$(target) := $(target))
###########################

###################
# llvm scaffolding
###################
debug ?=
verbose ?=

###################
# swift scaffolding
###################
# https://github.com/apple/swift-driver
ifeq (1,$(CLTOOLS))
sdkpath := /$(shell pkgutil --volume / --only-dirs --files com.apple.pkg.CLTools_SDK_macOS110 | grep -m1 MacOSX11.3.sdk$$)
swiftc := /$(shell pkgutil --volume / --only-dirs --files com.apple.pkg.CLTools_Executables | grep -m1 usr/bin$$)/swiftc -sdk $(sdk) -target $(arch)-$(target_$(platform)) $(verbose)
swiftbuildbin := /$(patsubst %-build,%,$(shell pkgutil --volume / --only-files --files com.apple.pkg.CLTools_Executables | grep -m1 bin/swift-build$$))
### XXX: appears CLTools doesn't ship SPM libraries yet, so Package.swift can't be compiled
else
sdkpath := $(shell xcrun --show-sdk-path --sdk $(sdk))
swiftc := xcrun -sdk $(sdk) swiftc -target $(arch)-$(target_$(platform)) $(verbose)
swiftbuildbin := $(shell command -v swift)
endif

swiftlibdir := $(lastword $(wildcard /Library/Developer/CommandLineTools/usr/lib/swift/$(sdk) $(shell xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(sdk)))
swiftstaticdir := $(lastword $(wildcard /Library/Developer/CommandLineTools/usr/lib/swift_static/$(sdk) $(shell xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/$(sdk)))
$(info [$(eXcode)] compiling against $(sdkpath))
$(info [$(eXcode)] swift libraries: $(swiftlibdir) $(swiftstaticdir))
########################

swiftbuild := swift build --configuration release \
# SPM configuration
########################
swiftbuild := $(swiftbuildbin) build --configuration release \
--build-path $(outdir)/swiftpm \
-Xswiftc "-sdk" -Xswiftc $(sdkpath) \
-Xswiftc "-target" -Xswiftc $(arch)-$(target_$(platform))

swiftrun_mac := swift run --configuration release \
swiftrun_mac := $(swiftbuildbin) run --configuration release \
--build-path $(outdir_mac)/swiftpm

spm_build := $(shell $(swiftbuild) --show-bin-path)

$(info [$(eXcode)] $$(swiftbuild) := $(swiftbuild))
$(info [$(eXcode)] $$(spm_build) := $(spm_build))

0 comments on commit 19d6266

Please sign in to comment.