Skip to content

Commit

Permalink
change: SPM Supported
Browse files Browse the repository at this point in the history
  • Loading branch information
MorningStarJ committed Mar 8, 2020
1 parent 9a52e64 commit 6d31495
Show file tree
Hide file tree
Showing 34 changed files with 166 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions Cabbage.xcodeproj/xcshareddata/xcschemes/Cabbage.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:Cabbage.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -52,6 +50,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
stopOnEveryThreadSanitizerIssue = "YES"
migratedStopOnEveryIssue = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
Expand All @@ -64,8 +63,6 @@
ReferencedContainer = "container:Cabbage.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
25 changes: 25 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Cabbage",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Cabbage",
targets: ["Cabbage"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Cabbage",
dependencies: ["AVFoundation", "CoreGraphics", "CoreMedia", "CoreImage", "Accelerate"]),
]
)
1 change: 1 addition & 0 deletions Sources/Cabbage/AVAssetReaderImageResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/AVAssetReverseImageResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/AVAssetTrackResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/AudioMixer.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/AudioProcessingChain.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/AudioProcessingTapHolder.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/AudioTransition.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/CGMathFunctions.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/CMTimeExtensition.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/CompositionGenerator.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/CompositionProvider.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/CoreImageExtension.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/ImageCompositionGroupProvider.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/ImageGeneratorExtension.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/ImageOverlayItem.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/ImageResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/KeyframeVideoConfiguration.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/Log.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/PHAssetImageResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/PHAssetLivePhotoResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/PHAssetTrackResource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/Resource.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/TimeRangeExtension.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/Timeline.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/TimingFunctionFactory.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/TrackConfiguration.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/TrackItem.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/VideoCompositionInstruction.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/VideoCompositor.swift
1 change: 1 addition & 0 deletions Sources/Cabbage/VideoTransition.swift
101 changes: 101 additions & 0 deletions scripts/package-spm.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/swift
//
// package-spm.swift
// scripts
//
// Created by Krunoslav Zaher on 12/26/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

import Foundation

/**
This script packages normal Rx* structure into `Sources` directory.

* creates and updates links to normal project structure
* builds unit tests `main.swift`

Unfortunately, Swift support for Linux, libdispatch and package manager are still quite unstable,
so certain class of unit tests is excluded for now.

*/

// It is kind of ironic that we need to additionally package for package manager :/

let fileManager = FileManager.default

let allowedExtensions = [
".swift",
".h",
".m",
".c",
]

func isExtensionAllowed(_ path: String) -> Bool {
return (allowedExtensions.map { path.hasSuffix($0) }).reduce(false) { $0 || $1 }
}

func checkExtension(_ path: String) throws {
if !isExtensionAllowed(path) {
throw NSError(domain: "Security", code: -1, userInfo: ["path" : path])
}
}

func packageRelativePath(_ paths: [String], targetDirName: String, excluded: [String] = []) throws {
let targetPath = "Sources/\(targetDirName)"

print("Checking " + targetPath)

for file in try fileManager.contentsOfDirectory(atPath: targetPath).sorted { $0 < $1 } {
if file != "include" && file != ".DS_Store" {
print("Checking extension \(file)")
try checkExtension(file)

print("Cleaning \(file)")
try fileManager.removeItem(atPath: "\(targetPath)/\(file)")
}
}

for sourcePath in paths {
var isDirectory: ObjCBool = false
print("loop sourcePath: \(sourcePath)")
fileManager.fileExists(atPath: sourcePath, isDirectory: &isDirectory)

let files: [String] = isDirectory.boolValue ? fileManager.subpaths(atPath: sourcePath)!
: [sourcePath]

for file in files {
if !isExtensionAllowed(file) {
print("Skipping \(file)")
continue
}

if excluded.contains(file) {
print("Skipping \(file)")
continue
}

let fileRelativePath = isDirectory.boolValue ? "\(sourcePath)/\(file)" : file

let destinationURL = NSURL(string: "../../\(fileRelativePath)")!

let fileName = (file as NSString).lastPathComponent
let atURL = NSURL(string: "file:///\(fileManager.currentDirectoryPath)/\(targetPath)/\(fileName)")!

if fileName.hasSuffix(".h") {
let sourcePath = NSURL(string: "file:///" + fileManager.currentDirectoryPath + "/" + sourcePath + "/" + file)!
//throw NSError(domain: sourcePath.description, code: -1, userInfo: nil)
try fileManager.copyItem(at: sourcePath as URL, to: atURL as URL)
}
else {
print("Linking \(fileName) [\(atURL)] -> \(destinationURL)")
try fileManager.createSymbolicLink(at: atURL as URL, withDestinationURL: destinationURL as URL)
}
}
}
}


try packageRelativePath([
"Cabbage/Sources"
], targetDirName: "Cabbage")

0 comments on commit 6d31495

Please sign in to comment.