Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Swift Package Manager #141

Merged
merged 5 commits into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ git:
branches:
only:
- master
script: make test
script: placeholder # workaround for https://github.com/travis-ci/travis-ci/issues/4681
matrix:
include:
- script: make test
env: JOB=Xcode
- script: swift build
env: JOB=SPM
before_install:
- make swift_snapshot_install
- make spm_bootstrap
- 'export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"'
exclude:
- script: placeholder # workaround for https://github.com/travis-ci/travis-ci/issues/4681
notifications:
email: false
slack: realmio:vPdpsG9NLDo2DNlbqtcMAQuE
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ OUTPUT_PACKAGE=SourceKitten.pkg
VERSION_STRING=$(shell agvtool what-marketing-version -terse1)
COMPONENTS_PLIST=Source/sourcekitten/Components.plist

SWIFT_SNAPSHOT=swift-2.2-SNAPSHOT-2016-01-11-a

.PHONY: all bootstrap clean install package test uninstall

all: bootstrap
Expand Down Expand Up @@ -66,3 +68,19 @@ archive:
carthage archive SourceKittenFramework

release: package archive

swift_snapshot_install:
curl https://swift.org/builds/xcode/$(SWIFT_SNAPSHOT)/$(SWIFT_SNAPSHOT)-osx.pkg -o swift.pkg
sudo installer -pkg swift.pkg -target /

spm_bootstrap:
cd /usr/local/include; svn export --force http://llvm.org/svn/llvm-project/cfe/trunk/include/clang-c/
cp clang_c_module.modulemap /usr/local/include/clang-c/module.modulemap
cp /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/libclang.dylib /usr/local/lib/
mkdir -p /usr/local/include/sourcekitdInProc
curl https://raw.githubusercontent.com/apple/swift/$(SWIFT_SNAPSHOT)/tools/SourceKit/tools/sourcekitd/include/sourcekitd/sourcekitd.h > /usr/local/include/sourcekitdInProc/sourcekitd.h
curl https://static.realm.io/libsourcekitdInProc/$(SWIFT_SNAPSHOT)/libsourcekitdInProc.dylib -o /usr/local/lib/libsourcekitdInProc.dylib

spm_teardown:
rm -rf /usr/local/include/clang-c /usr/local/lib/libclang.dylib
rm -rf /usr/local/include/sourcekitdInProc /usr/local/lib/libsourcekitdInProc.dylib
16 changes: 16 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PackageDescription

let package = Package(
name: "SourceKitten",
targets: [
Target(name: "SourceKittenFramework"),
Target(name: "sourcekitten",
dependencies: [.Target(name: "SourceKittenFramework")])
],
dependencies: [
.Package(url: "https://github.com/jpsim/SourceKit.git", majorVersion: 1),
.Package(url: "https://github.com/jpsim/SWXMLHash.git", majorVersion: 1),
.Package(url: "https://github.com/jpsim/Commandant.git", majorVersion: 1)
],
exclude: ["Source/SourceKittenFrameworkTests"]
)
4 changes: 4 additions & 0 deletions Source/SourceKittenFramework/Clang+SourceKitten.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif
import Foundation
import SWXMLHash

struct ClangIndex {
Expand Down
5 changes: 5 additions & 0 deletions Source/SourceKittenFramework/ClangTranslationUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// Copyright (c) 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif
import Foundation

extension SequenceType where Generator.Element: Hashable {
func distinct() -> [Generator.Element] {
return Array(Set(self))
Expand Down
4 changes: 4 additions & 0 deletions Source/SourceKittenFramework/Documentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif

public struct Documentation {
let parameters: [Parameter]
let returnDiscussion: [Text]
Expand Down
3 changes: 3 additions & 0 deletions Source/SourceKittenFramework/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import Foundation
import SWXMLHash
#if SWIFT_PACKAGE
import SourceKit
#endif

/// Represents a source file.
public final class File {
Expand Down
4 changes: 4 additions & 0 deletions Source/SourceKittenFramework/ObjCDeclarationKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif

/**
Objective-C declaration kinds.
More or less equivalent to `SwiftDeclarationKind`, but with made up values because there's no such
Expand Down
4 changes: 4 additions & 0 deletions Source/SourceKittenFramework/Parameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Copyright © 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif

public struct Parameter {
let name: String
let discussion: [Text]
Expand Down
3 changes: 3 additions & 0 deletions Source/SourceKittenFramework/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import Foundation
#if SWIFT_PACKAGE
import SourceKit
#endif

public protocol SourceKitRepresentable {
func isEqualTo(rhs: SourceKitRepresentable) -> Bool
Expand Down
5 changes: 5 additions & 0 deletions Source/SourceKittenFramework/SourceDeclaration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// Copyright © 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif
import Foundation

public func insertMarks(declarations: [SourceDeclaration], limitRange: NSRange? = nil) -> [SourceDeclaration] {
guard declarations.count > 0 else { return [] }
guard let path = declarations.first?.location.file, let file = File(path: path) else {
Expand Down
5 changes: 5 additions & 0 deletions Source/SourceKittenFramework/SourceLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// Copyright © 2015 SourceKitten. All rights reserved.
//

#if SWIFT_PACKAGE
import Clang_C
#endif
import Foundation

public struct SourceLocation {
let file: String
let line: UInt32
Expand Down
3 changes: 3 additions & 0 deletions Source/SourceKittenFramework/SwiftDocs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import Foundation
#if SWIFT_PACKAGE
import SourceKit
#endif

/// Represents docs for a Swift file.
public struct SwiftDocs {
Expand Down
3 changes: 1 addition & 2 deletions Source/sourcekitten/VersionCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import Commandant
import Result

private let version = NSBundle(identifier: "com.sourcekitten.SourceKittenFramework")!
.objectForInfoDictionaryKey("CFBundleShortVersionString")!
private let version = "0.7.4"

struct VersionCommand: CommandType {
let verb = "version"
Expand Down
1 change: 1 addition & 0 deletions Source/sourcekitten/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2015 SourceKitten. All rights reserved.
//

import Darwin
import Commandant

let registry = CommandRegistry<SourceKittenError>()
Expand Down
5 changes: 5 additions & 0 deletions clang_c_module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Clang_C {
umbrella "."
link "clang"
module * { export * }
}