From 9fced591750045be29ae22250ba038310bc02979 Mon Sep 17 00:00:00 2001 From: Theo Date: Sun, 3 Jun 2018 08:40:32 -0700 Subject: [PATCH 1/3] Added compactMap retrocompat --- Package.resolved | 18 +++++++++--------- Package.swift | 2 +- Sources/WeaverCodeGen/shim-swift-4.1.swift | 17 +++++++++++++++++ WeaverDI.xcodeproj/project.pbxproj | 4 ++++ 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 Sources/WeaverCodeGen/shim-swift-4.1.swift diff --git a/Package.resolved b/Package.resolved index e54015ba..f404023b 100644 --- a/Package.resolved +++ b/Package.resolved @@ -64,6 +64,15 @@ "version": "3.2.4" } }, + { + "package": "SWXMLHash", + "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", + "state": { + "branch": null, + "revision": "17d992beb3aaeda403fd35f8d5e70ab1a8124f35", + "version": "4.6.0" + } + }, { "package": "SourceKit", "repositoryURL": "https://github.com/norio-nomura/SourceKit.git", @@ -100,15 +109,6 @@ "version": "0.11.0" } }, - { - "package": "SWXMLHash", - "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", - "state": { - "branch": null, - "revision": "17d992beb3aaeda403fd35f8d5e70ab1a8124f35", - "version": "4.6.0" - } - }, { "package": "Yams", "repositoryURL": "https://github.com/jpsim/Yams.git", diff --git a/Package.swift b/Package.swift index 1b861f09..7ba5be33 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.1 +// swift-tools-version:4.0 import PackageDescription let package = Package( diff --git a/Sources/WeaverCodeGen/shim-swift-4.1.swift b/Sources/WeaverCodeGen/shim-swift-4.1.swift new file mode 100644 index 00000000..a4164882 --- /dev/null +++ b/Sources/WeaverCodeGen/shim-swift-4.1.swift @@ -0,0 +1,17 @@ +// +// shim-swift-4.2.swift +// WeaverCodeGen +// +// Created by Théophane Rupin on 6/3/18. +// + +import Foundation + +#if swift(>=4.1) +#else +extension Collection { + public func compactMap(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { + return try flatMap(transform) + } +} +#endif diff --git a/WeaverDI.xcodeproj/project.pbxproj b/WeaverDI.xcodeproj/project.pbxproj index 38a9624b..8def95b3 100644 --- a/WeaverDI.xcodeproj/project.pbxproj +++ b/WeaverDI.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 19F3CD6820C43F32007C3076 /* shim-swift-4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19F3CD6720C43F32007C3076 /* shim-swift-4.1.swift */; }; OBJ_199 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; }; OBJ_205 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_57 /* Package.swift */; }; OBJ_211 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_78 /* Package.swift */; }; @@ -457,6 +458,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 19F3CD6720C43F32007C3076 /* shim-swift-4.1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "shim-swift-4.1.swift"; sourceTree = ""; }; "Commander::Commander::Product" /* Commander.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Commander.framework; sourceTree = BUILT_PRODUCTS_DIR; }; OBJ_10 /* Dependencies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dependencies.swift; sourceTree = ""; }; OBJ_100 /* Reporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reporter.swift; sourceTree = ""; }; @@ -885,6 +887,7 @@ OBJ_17 /* WeaverCodeGen */ = { isa = PBXGroup; children = ( + 19F3CD6720C43F32007C3076 /* shim-swift-4.1.swift */, OBJ_18 /* AccessLevel.swift */, OBJ_19 /* AutoEquatable.generated.swift */, OBJ_20 /* AutoHashable.generated.swift */, @@ -1657,6 +1660,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 0; files = ( + 19F3CD6820C43F32007C3076 /* shim-swift-4.1.swift in Sources */, OBJ_329 /* AccessLevel.swift in Sources */, OBJ_330 /* AutoEquatable.generated.swift in Sources */, OBJ_331 /* AutoHashable.generated.swift in Sources */, From 3d511404ef105a5b057a26d10a2c9cb10fba7700 Mon Sep 17 00:00:00 2001 From: Theo Date: Mon, 4 Jun 2018 10:24:00 -0700 Subject: [PATCH 2/3] Improved Makefile rules --- Makefile | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index b7009b84..c548594a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ VERSION := $(shell /usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" WeaverDI.xcodeproj/WeaverCodeGen_Info.plist) -PREFIX = /usr/local +PREFIX=/usr/local +SWIFT_BUILD_FLAGS=--configuration release .PHONY: clean build install package generate_sources codecov build: - $(call build) + @swift build --disable-sandbox $(SWIFT_BUILD_FLAGS) generate_sources: bash -c "(command -v sourcery && sourcery) || echo 'warning: Sourcery is not installed'" @@ -12,29 +13,22 @@ generate_sources: clean: rm -rf .build -install: - $(call build) +install: build $(call install_files,$(PREFIX)) uninstall: rm "$(PREFIX)/bin/weaver" rm -rf "$(PREFIX)/share/weaver" -package: - $(call build) +package: build $(call install_files,./build/package/weaver) cd ./build/package/ && zip -r ../../weaver-$(VERSION).zip ./weaver -codecov: - $(call build) +codecov: build xcodebuild test -scheme Tests -enableCodeCoverage YES bash -c "bash <(curl -s https://codecov.io/bash) -J Weaver -t eaa7c4af-5ca2-4e08-8f07-38a44671e5e0" rm *.coverage.txt -define build - @swift build --disable-sandbox --configuration release -endef - define install_files install -d $(1)/bin install -d $(1)/share/weaver/Resources From 3957316b017ff0afe961ec09c2fbee3dad873ae2 Mon Sep 17 00:00:00 2001 From: Theo Date: Mon, 4 Jun 2018 10:35:31 -0700 Subject: [PATCH 3/3] Updated Sourcekiten --- Package.resolved | 22 +++++++++++----------- Package.swift | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Package.resolved b/Package.resolved index f404023b..86d18175 100644 --- a/Package.resolved +++ b/Package.resolved @@ -64,15 +64,6 @@ "version": "3.2.4" } }, - { - "package": "SWXMLHash", - "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", - "state": { - "branch": null, - "revision": "17d992beb3aaeda403fd35f8d5e70ab1a8124f35", - "version": "4.6.0" - } - }, { "package": "SourceKit", "repositoryURL": "https://github.com/norio-nomura/SourceKit.git", @@ -87,8 +78,8 @@ "repositoryURL": "https://github.com/jpsim/SourceKitten.git", "state": { "branch": null, - "revision": "b6b10419ee439167ba6f7bd928ad30754ff5eb5d", - "version": "0.20.0" + "revision": "7c09176766d4bbc5da377ad857953fb49510a6aa", + "version": "0.21.0" } }, { @@ -109,6 +100,15 @@ "version": "0.11.0" } }, + { + "package": "SWXMLHash", + "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", + "state": { + "branch": null, + "revision": "17d992beb3aaeda403fd35f8d5e70ab1a8124f35", + "version": "4.6.0" + } + }, { "package": "Yams", "repositoryURL": "https://github.com/jpsim/Yams.git", diff --git a/Package.swift b/Package.swift index 7ba5be33..990d69ea 100644 --- a/Package.swift +++ b/Package.swift @@ -7,9 +7,9 @@ let package = Package( .library(name: "WeaverDI", targets: ["WeaverDI"]) ], dependencies: [ - .package(url: "https://github.com/jpsim/SourceKitten.git", from: "0.19.1"), + .package(url: "https://github.com/jpsim/SourceKitten.git", from: "0.21.0"), .package(url: "https://github.com/kylef/Commander.git", from: "0.6.0"), - .package(url: "https://github.com/kylef/Stencil.git", from: "0.10.1") + .package(url: "https://github.com/kylef/Stencil.git", from: "0.11.0") ], targets: [ .target(name: "WeaverDI"),