Added Linux support. (#172)
* Added check for os(Linux) * Sources adopted to Swift Linux Compiler v5.0 * Added Docker configuration to be used for Linux builds. * Renamed Script. * Docker configuration update. * Fixes Linux compile errors. * Nicification.
This commit is contained in:
committed by
rob phillips
parent
5aa5a55193
commit
c20e8e2d4c
@@ -0,0 +1,7 @@
|
||||
import XCTest
|
||||
|
||||
var tests = [XCTestCaseEntry]()
|
||||
|
||||
// FIXME: Run on macOS `swift test --generate-linuxmain` and maintain Linux Tests.
|
||||
|
||||
XCTMain(tests)
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
import UIKit
|
||||
@@ -22,3 +24,5 @@ extension CGPoint {
|
||||
return CGPoint(x: x + point.x, y: y + point.y)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
import UIKit
|
||||
@@ -26,3 +28,5 @@ extension CGRect {
|
||||
return CGRect(origin: origin.translated(by: point), size: size)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
import UIKit
|
||||
@@ -21,3 +23,5 @@ public struct QuoteStripeOptions {
|
||||
public var thickness: CGFloat = 2
|
||||
public var spacingAfter: CGFloat = 8
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
/// A configuration object used to initialze the `DownStyler`.
|
||||
public struct DownStylerConfiguration {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(watchOS)
|
||||
#if !os(watchOS) && !os(Linux)
|
||||
|
||||
#if canImport(UIKit)
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Created by John Nguyen on 09.04.19.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
|
||||
import Foundation
|
||||
|
||||
/// This class is used to generated an `NSMutableAttributedString` from the abstract syntax
|
||||
@@ -221,3 +223,4 @@ private extension String {
|
||||
return lines.joined(separator: .lineSeparator)
|
||||
}
|
||||
}
|
||||
#endif // !os(Linux)
|
||||
|
||||
+5
-2
@@ -9,8 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
public struct Down: DownASTRenderable, DownHTMLRenderable, DownXMLRenderable,
|
||||
DownLaTeXRenderable, DownGroffRenderable, DownCommonMarkRenderable,
|
||||
DownAttributedStringRenderable {
|
||||
DownLaTeXRenderable, DownGroffRenderable, DownCommonMarkRenderable {
|
||||
/// A string containing CommonMark Markdown
|
||||
public var markdownString: String
|
||||
|
||||
@@ -21,3 +20,7 @@ public struct Down: DownASTRenderable, DownHTMLRenderable, DownXMLRenderable,
|
||||
self.markdownString = markdownString
|
||||
}
|
||||
}
|
||||
|
||||
#if !os(Linux)
|
||||
extension Down: DownAttributedStringRenderable { }
|
||||
#endif // !os(Linux)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
#else
|
||||
@@ -32,3 +34,4 @@ extension NSAttributedString {
|
||||
}
|
||||
|
||||
}
|
||||
#endif // !os(Linux)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
import Foundation
|
||||
import libcmark
|
||||
|
||||
@@ -56,3 +57,4 @@ extension DownAttributedStringRenderable {
|
||||
return document.accept(visitor)
|
||||
}
|
||||
}
|
||||
#endif // !os(Linux)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Copyright © 2016-2019 Down. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(Linux)
|
||||
#if os(tvOS) || os(watchOS)
|
||||
// Sorry, not available for tvOS nor watchOS
|
||||
#else
|
||||
@@ -205,3 +206,4 @@ private extension WKNavigationDelegate {
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // !os(Linux)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# You can set the Swift version to what you need for your app. Versions can be found here: https://hub.docker.com/_/swift
|
||||
FROM swift:5.1
|
||||
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -q -y install libssl-dev zlib1g-dev \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
@@ -0,0 +1,6 @@
|
||||
# Building on Linux (Docker)
|
||||
|
||||
- Go to "docker" directory: `cd $REPO/docker`
|
||||
- Compose docket image: `docker-compose build`.
|
||||
- Build sources: `docker-compose run --rm down`.
|
||||
- Login docker image (i.e. to troubleshoot build failures): `docker-compose run --rm down bash`. After that you can run `swift build --package-path /app` or `cd /app && swift build`.
|
||||
@@ -0,0 +1,12 @@
|
||||
version: "3.3"
|
||||
services:
|
||||
down:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- ../:/app
|
||||
working_dir: /app
|
||||
stdin_open: true
|
||||
tty: true
|
||||
command: /app/docker/down-rebuild.sh
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "- Cleaning App"
|
||||
swift package clean
|
||||
if [ $? != 0 ]; then
|
||||
echo "❌ Linux build failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "- Building App"
|
||||
swift build --configuration release
|
||||
if [ $? != 0 ]; then
|
||||
echo "❌ Linux build failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Linux build completed!"
|
||||
Reference in New Issue
Block a user