Skip to content

Commit

Permalink
Merge pull request #7 from ypopovych/master
Browse files Browse the repository at this point in the history
Latest Swift support + podspec
  • Loading branch information
dileping authored Nov 22, 2016
2 parents 8e4b5da + 75467e8 commit 10d9237
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 52 deletions.
25 changes: 10 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ env:
matrix:
include:
- script:
- xctool test -project $MODULE_NAME.xcodeproj -scheme $MODULE_NAME
#- xctool test -project $MODULE_NAME.xcodeproj -scheme $MODULE_NAME-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6'
#- xctool test -project $MODULE_NAME.xcodeproj -scheme $MODULE_NAME-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 1080p'
#- xctool build -project $MODULE_NAME.xcodeproj -scheme $MODULE_NAME-watchOS -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch - 42mm'
- xcodebuild clean test -project $MODULE_NAME.xcodeproj -scheme $MODULE_NAME | xcpretty --color && exit ${PIPESTATUS[0]}
os: osx
osx_image: xcode7.2
osx_image: xcode8.1
language: objective-c
before_install:
- brew update
- brew outdated carthage || brew upgrade carthage
- brew outdated xctool || brew upgrade xctool
- brew install discount
before_script:
# bootstrap the dependencies for the project
Expand All @@ -23,7 +19,7 @@ matrix:
before_deploy:
- carthage build --no-skip-current
- carthage archive $MODULE_NAME
#- pod trunk push CrossroadRegex.podspec
- pod trunk push $MODULE_NAME.podspec
deploy:
provider: releases
api_key:
Expand All @@ -34,7 +30,7 @@ matrix:
repo: crossroadlabs/Markdown
tags: true
- script:
- ./build
- swift build && swift test
sudo: required
dist: trusty
language: generic
Expand All @@ -44,14 +40,13 @@ matrix:
# install original swift distribution
- wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
- cd ..
- export SWIFT_VERSION="swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a"
- wget https://swift.org/builds/development/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz
- tar xzf $SWIFT_VERSION-ubuntu14.04.tar.gz
- export PATH="${PWD}/${SWIFT_VERSION}-ubuntu14.04/usr/bin:${PATH}"
- export SWIFT_VERSION="swift-3.0.1-release"
- SWIFT_VERSION_UPPER=`echo $SWIFT_VERSION | perl -n -e'/^(.*?)-([\.\d]*?)-(.*)$/; $code = uc $3; print "$1-$2-${code}"'`
- wget https://swift.org/builds/$SWIFT_VERSION/ubuntu1404/$SWIFT_VERSION_UPPER/$SWIFT_VERSION_UPPER-ubuntu14.04.tar.gz
- tar xzf $SWIFT_VERSION_UPPER-ubuntu14.04.tar.gz
- export PATH="${PWD}/${SWIFT_VERSION_UPPER}-ubuntu14.04/usr/bin:${PATH}"
- export LD_LIBRARY_PATH="${PWD}/${SWIFT_VERSION_UPPER}-ubuntu14.04/usr/lib/swift/linux/:$LD_LIBRARY_PATH"
# get back home
- cd $MODULE_NAME
# get crossroad build script
- wget https://raw.githubusercontent.com/crossroadlabs/utils/master/build
- chmod +x build
notifications:
email: false
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "crossroadlabs/CDiscount" ~> 0.1
github "crossroadlabs/CDiscount" ~> 2.2
21 changes: 21 additions & 0 deletions Markdown.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Pod::Spec.new do |s|
s.name = "Markdown"
s.version = "1.0.0-alpha.2"
s.summary = "Full markdown support for Swift - wrapper over Discount (this actually is what GitHub uses deep down)"
s.homepage = "https://github.com/crossroadlabs/Markdown"
s.license = { :type => 'LGPL', :file => 'LICENSE.LESSER.txt' }
s.authors = { 'Daniel Leping' => '[email protected]' }
s.source = { :git => "https://github.com/crossroadlabs/Markdown.git", :tag => "#{s.version}" }

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.tvos.deployment_target = '9.0'
s.watchos.deployment_target = '2.0'

s.source_files = 'Sources/Markdown/*.swift'
s.frameworks = 'Foundation'

s.requires_arc = true

s.dependency 'CDiscount', '~> 2.2'
end
44 changes: 32 additions & 12 deletions Markdown.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
65285FDA1C86028600A67889 = {
isa = PBXGroup;
children = (
65285FE61C86028600A67889 /* Markdown */,
65285FF21C86028700A67889 /* MarkdownTests */,
920A20891DE1011000743624 /* Sources */,
920A208A1DE1013300743624 /* Tests */,
65285FE51C86028600A67889 /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -89,8 +89,23 @@
65285FF31C86028700A67889 /* MarkdownTests.swift */,
65285FF51C86028700A67889 /* Info.plist */,
);
name = MarkdownTests;
path = Tests/Markdown;
path = MarkdownTests;
sourceTree = "<group>";
};
920A20891DE1011000743624 /* Sources */ = {
isa = PBXGroup;
children = (
65285FE61C86028600A67889 /* Markdown */,
);
path = Sources;
sourceTree = "<group>";
};
920A208A1DE1013300743624 /* Tests */ = {
isa = PBXGroup;
children = (
65285FF21C86028700A67889 /* MarkdownTests */,
);
path = Tests;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand All @@ -110,7 +125,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 65285FF81C86028700A67889 /* Build configuration list for PBXNativeTarget "Markdown" */;
buildPhases = (
965FCFE41C872299006E84C5 /* Check Carthage Checkouts direcotry */,
965FCFE41C872299006E84C5 /* Check Carthage Checkouts directory */,
65285FDF1C86028600A67889 /* Sources */,
65285FE01C86028600A67889 /* Frameworks */,
65285FE11C86028600A67889 /* Headers */,
Expand Down Expand Up @@ -150,7 +165,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = "Crossroad Labs, LTD.";
TargetAttributes = {
65285FE31C86028600A67889 = {
Expand Down Expand Up @@ -197,14 +212,14 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
965FCFE41C872299006E84C5 /* Check Carthage Checkouts direcotry */ = {
965FCFE41C872299006E84C5 /* Check Carthage Checkouts directory */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Carthage Checkouts direcotry";
name = "Check Carthage Checkouts directory";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -256,8 +271,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down Expand Up @@ -306,8 +323,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -329,6 +348,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -345,7 +365,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Markdown/Info.plist;
INFOPLIST_FILE = Sources/Markdown/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = xyz.crossroadlabs.Markdown;
Expand All @@ -366,7 +386,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Markdown/Info.plist;
INFOPLIST_FILE = Sources/Markdown/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = xyz.crossroadlabs.Markdown;
Expand All @@ -380,7 +400,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Tests/Markdown/Info.plist;
INFOPLIST_FILE = Tests/MarkdownTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = xyz.crossroadlabs.MarkdownTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -391,7 +411,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Tests/Markdown/Info.plist;
INFOPLIST_FILE = Tests/MarkdownTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = xyz.crossroadlabs.MarkdownTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 3 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import PackageDescription

let package = Package(
name: "Markdown",
targets: [
Target(
name: "Markdown"
),
],
dependencies: [.Package(url: "https://github.com/crossroadlabs/CDiscount.git", majorVersion: 0)],
exclude: ["Carthage"]
dependencies: [
.Package(url: "https://github.com/crossroadlabs/CDiscount.git", majorVersion: 2, minor: 2)
]
)
2 changes: 1 addition & 1 deletion Markdown/Errors.swift → Sources/Markdown/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//
//===----------------------------------------------------------------------===//

public enum Error : ErrorProtocol {
public enum MarkdownError : Error {
case Compile(code:Int32)
case Produce(code:Int32)
}
2 changes: 1 addition & 1 deletion Markdown/Info.plist → Sources/Markdown/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0-alpha.1</string>
<string>1.0.0-alpha.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
8 changes: 4 additions & 4 deletions Markdown/Markdown.swift → Sources/Markdown/Markdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import CDiscount

private typealias PMMIOT = UnsafeMutablePointer<Void>
private typealias PMMIOT = UnsafeMutableRawPointer
private typealias MKDFUN = (PMMIOT, UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>) -> Int32

public class Markdown {
Expand All @@ -31,7 +31,7 @@ public class Markdown {
self._markdown = markdown
let result = mkd_compile(markdown, options.rawValue)
if result <= 0 {
throw Error.Compile(code: result)
throw MarkdownError.Compile(code: result)
}
}

Expand All @@ -44,7 +44,7 @@ public class Markdown {
}

private func data(with fun:MKDFUN, deallocator:(UnsafeMutablePointer<Int8>?)->Void) throws -> String {
var dest = [UnsafeMutablePointer<Int8>?](repeating: UnsafeMutablePointer<Int8>(allocatingCapacity: 1), count: 1)
var dest = [UnsafeMutablePointer<Int8>?](repeating: UnsafeMutablePointer<Int8>.allocate(capacity: 1), count: 1)

let result = fun(_markdown, &dest)
defer {
Expand All @@ -53,7 +53,7 @@ public class Markdown {
}
}
if result < 0 {
throw Error.Produce(code: result)
throw MarkdownError.Produce(code: result)
}

guard let data = dest[0] else {
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import XCTest

@testable import Markdowntest
import MarkdownTests

XCTMain([
MarkdownTests(),
])
var tests = [XCTestCaseEntry]()

tests += MarkdownTests.allTests()

XCTMain(tests)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MarkdownTests: XCTestCase {
// no dispatch
func testStress() {
let id = UUID().uuidString
let queue = DispatchQueue(label: id, attributes: DispatchQueueAttributes.concurrent)
let queue = DispatchQueue(label: id, attributes: .concurrent)

for i in 0...10000 {
let expectation = self.expectation(description: "OK " + String(i))
Expand All @@ -105,25 +105,25 @@ class MarkdownTests: XCTestCase {
}
}

self.waitForExpectations(timeout: 30, handler: nil)
self.waitForExpectations(timeout: 60, handler: nil)
}

#endif

}

#if os(Linux)
extension MarkdownTests : XCTestCaseProvider {
var allTests : [(String, () throws -> Void)] {
var tests:[(String, () throws -> Void)] = [
extension MarkdownTests {
static var allTests : [(String, (MarkdownTests) -> () throws -> Void)] {
var tests:[(String, (MarkdownTests) -> () throws -> Void)] = [
("testHeader", testHeader),
("testBody", testBody),
("testTableOfContents", testTableOfContents),
("testStyle", testStyle),
]

#if dispatch
tests.append(("testStress", testStress))
tests.append(("testStress", testStress))
#endif

return tests
Expand Down
9 changes: 9 additions & 0 deletions Tests/MarkdownTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

#if os(Linux)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(MarkdownTests.allTests)
]
}
#endif

0 comments on commit 10d9237

Please sign in to comment.