Giter Club home page Giter Club logo

perfecttemplate's Introduction

PerfectTemplate 简体中文

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 5.0 Platforms macOS | Linux License Apache PerfectlySoft Twitter Slack Status

Perfect Empty Starter Project

This repository holds a blank Perfect project which can be cloned to serve as a starter for new work. It builds with Swift Package Manager and produces a stand-alone HTTP executable.

Compatibility with Swift

The master branch of this project currently compiles with Xcode 10 and the Swift 4.1 or higher toolchain on Ubuntu.

Building & Running

The following will clone and build an empty starter project and launch the server on port 8181.

git clone https://github.com/PerfectlySoft/PerfectTemplate.git
cd PerfectTemplate
swift run

You should see the following output:

[INFO] Starting HTTP server localhost on 0.0.0.0:8181

This means the server is running and waiting for connections. Access http://localhost:8181/ to see the greeting. Hit control-c to terminate the server.

Starter Content

The template file contains a simple "hello, world!" request handler and shows how to serve static files, and compress outgoing content.

import PerfectHTTP
import PerfectHTTPServer

// An example request handler.
// This 'handler' function can be referenced directly in the configuration below.
func handler(request: HTTPRequest, response: HTTPResponse) {
	// Respond with a simple message.
	response.setHeader(.contentType, value: "text/html")
	response.appendBody(string: "<html><title>Hello, world!</title><body>Hello, world!</body></html>")
	// Ensure that response.completed() is called when your processing is done.
	response.completed()
}

// Configure one server which:
//	* Serves the hello world message at <host>:<port>/
//	* Serves static files out of the "./webroot"
//		directory (which must be located in the current working directory).
//	* Performs content compression on outgoing data when appropriate.
var routes = Routes()
routes.add(method: .get, uri: "/", handler: handler)
routes.add(method: .get, uri: "/**",
		   handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
try HTTPServer.launch(name: "localhost",
					  port: 8181,
					  routes: routes,
					  responseFilters: [
						(PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])

Further Information

For more information on the Perfect project, please visit perfect.org.

perfecttemplate's People

Contributors

iamjono avatar kjessup avatar rockfordwei avatar rpinz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perfecttemplate's Issues

Cannot resolve dependencies on Ubuntu 20.04 + swift 5.3

The command I execute:

git clone [email protected]:PerfectlySoft/PerfectTemplate.git && cd PerfectTemplate && swift run

The output I observe:

Cloning into 'PerfectTemplate'...
remote: Enumerating objects: 285, done.
remote: Total 285 (delta 0), reused 0 (delta 0), pack-reused 285
Receiving objects: 100% (285/285), 61.98 KiB | 453.00 KiB/s, done.
Resolving deltas: 100% (143/143), done.
Fetching https://github.com/PerfectlySoft/Perfect-HTTPServer.git
Cloning https://github.com/PerfectlySoft/Perfect-HTTPServer.git
Resolving https://github.com/PerfectlySoft/Perfect-HTTPServer.git at 3.0.23
Updating https://github.com/PerfectlySoft/Perfect-HTTPServer.git
Fetching https://github.com/PerfectlySoft/Perfect-CZlib-src.git
Fetching https://github.com/PerfectlySoft/Perfect-HTTP.git
Fetching https://github.com/PerfectlySoft/Perfect-Net.git
Cloning https://github.com/PerfectlySoft/Perfect-HTTP.git
Resolving https://github.com/PerfectlySoft/Perfect-HTTP.git at 3.3.0
Cloning https://github.com/PerfectlySoft/Perfect-Net.git
Resolving https://github.com/PerfectlySoft/Perfect-Net.git at 3.3.0
Cloning https://github.com/PerfectlySoft/Perfect-CZlib-src.git
Resolving https://github.com/PerfectlySoft/Perfect-CZlib-src.git at 0.0.4
error: the Package.resolved file is most likely severely out-of-date and is preventing correct resolution; delete the resolved file and try again

But if I delete "PerfectHTTPServer" from the target dependency list and replace all the code in main.swift with a simple print, I get only warning:

warning: dependency 'PerfectHTTPServer' is not used by any target

So there should be a mistake somewhere in dependencies declarations.

Mac OS run failed

megatron@localhost PerfectTemplate % swift run
Building for debugging...
/Users/megatron/Documents/Web/PerfectTemplate/.build/checkouts/PerfectLib/Sources/PerfectLib/Log.swift:73:28: error: cannot convert value of type 'CVaListPointer' to expected argument type '__darwin_va_list?' (aka 'Optional<UnsafeMutablePointer>')
vsyslog(priority, "%s", $0)
^
[2/3] Compiling PerfectLib Log.swift

Cannot compile on linux

I saw an other issue mentioning a linking error under linux.
What happens to my case is compile error.

alkis@alkisPC:~/p/swift/logic2$ git clone https://github.com/PerfectlySoft/PerfectTemplate.git
Cloning into 'PerfectTemplate'...
remote: Counting objects: 230, done.
remote: Total 230 (delta 0), reused 0 (delta 0), pack-reused 230
Receiving objects: 100% (230/230), 53.17 KiB | 259.00 KiB/s, done.
Resolving deltas: 100% (117/117), done.
alkis@alkisPC:~/p/swift/logic2$ cd PerfectTemplate
alkis@alkisPC:~/p/swift/logic2/PerfectTemplate$ swift build
Fetching https://github.com/PerfectlySoft/Perfect-HTTPServer.git
Fetching https://github.com/PerfectlySoft/Perfect-Net.git
Fetching https://github.com/PerfectlySoft/Perfect-HTTP.git
Fetching https://github.com/PerfectlySoft/Perfect-CZlib-src.git
Fetching https://github.com/PerfectlySoft/Perfect-Crypto.git
Fetching https://github.com/PerfectlySoft/Perfect-LinuxBridge.git
Fetching https://github.com/PerfectlySoft/Perfect-Thread.git
Fetching https://github.com/PerfectlySoft/PerfectLib.git
Fetching https://github.com/PerfectlySoft/Perfect-COpenSSL-Linux.git
Completed resolution in 21.39s
Cloning https://github.com/PerfectlySoft/Perfect-LinuxBridge.git
Resolving https://github.com/PerfectlySoft/Perfect-LinuxBridge.git at 3.0.0
Cloning https://github.com/PerfectlySoft/Perfect-CZlib-src.git
Resolving https://github.com/PerfectlySoft/Perfect-CZlib-src.git at 0.0.4
Cloning https://github.com/PerfectlySoft/Perfect-Crypto.git
Resolving https://github.com/PerfectlySoft/Perfect-Crypto.git at 3.1.2
Cloning https://github.com/PerfectlySoft/Perfect-Net.git
Resolving https://github.com/PerfectlySoft/Perfect-Net.git at 3.2.0
Cloning https://github.com/PerfectlySoft/Perfect-HTTPServer.git
Resolving https://github.com/PerfectlySoft/Perfect-HTTPServer.git at 3.0.17
Cloning https://github.com/PerfectlySoft/PerfectLib.git
Resolving https://github.com/PerfectlySoft/PerfectLib.git at 3.1.1
Cloning https://github.com/PerfectlySoft/Perfect-Thread.git
Resolving https://github.com/PerfectlySoft/Perfect-Thread.git at 3.0.4
Cloning https://github.com/PerfectlySoft/Perfect-COpenSSL-Linux.git
Resolving https://github.com/PerfectlySoft/Perfect-COpenSSL-Linux.git at 3.0.1
Cloning https://github.com/PerfectlySoft/Perfect-HTTP.git
Resolving https://github.com/PerfectlySoft/Perfect-HTTP.git at 3.1.0
warning: PackageDescription API v3 is deprecated and will be removed in the future; used by package(s): PerfectTemplate, PerfectThread, COpenSSL, LinuxBridge
Compile PerfectCZlib zutil.c
Compile PerfectCZlib inffast.c
Compile PerfectCZlib inflate.c
Compile PerfectCZlib inftrees.c
Compile PerfectCZlib trees.c
Compile PerfectCZlib infback.c
Compile PerfectCZlib uncompr.c
Compile PerfectCZlib gzwrite.c
Compile PerfectCZlib gzread.c
Compile PerfectCZlib gzlib.c
Compile PerfectCZlib gzclose.c
Compile PerfectCZlib deflate.c
Compile PerfectCZlib crc32.c
Compile PerfectCZlib adler32.c
Compile PerfectCZlib compress.c
Compile PerfectCHTTPParser http_parser.c
Compile LinuxBridge LinuxBridge.c
Compile COpenSSL openssl.c
Compile Swift Module 'PerfectThread' (3 sources)
Compile Swift Module 'PerfectLib' (9 sources)
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/PerfectLib.git-7127146926598439540/Sources/PerfectLib/Dir.swift:129:16: warning: 'readdir_r' is deprecated
        return readdir_r(d, &dirEnt, endPtr)
               ^
Compile Swift Module 'PerfectCrypto' (7 sources)
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/Keys.swift:35:35: error: use of undeclared type 'EVP_PKEY'
        init(_ key: UnsafeMutablePointer<EVP_PKEY>?) {
                                         ^~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer<BIO>?
                                            ^~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
        fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
                                                      ^~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:232:11: error: initializer does not override a designated initializer from its superclass
        override init(bio: BIOPointer) {
        ~~~~~~~~ ^
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:210:14: error: 'checkedResult' produces 'Int', not the expected contextual result type 'Int'
                return try checkedResult(Int(BIO_write(head, bytes.baseAddress, Int32(bytes.count))))
                           ^
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:281:25: error: use of undeclared type 'EVP_MD'
        var evp: UnsafePointer<EVP_MD> {
                               ^~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:408:25: error: use of undeclared type 'EVP_CIPHER'
        var evp: UnsafePointer<EVP_CIPHER> {
                               ^~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/Keys.swift:31:33: error: use of undeclared type 'EVP_PKEY'
        let pkey: UnsafeMutablePointer<EVP_PKEY>?
                                       ^~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/Keys.swift:35:35: error: use of undeclared type 'EVP_PKEY'
        init(_ key: UnsafeMutablePointer<EVP_PKEY>?) {
                                         ^~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/Keys.swift:71:32: error: use of undeclared type 'EVP_PKEY'
        init(kp: UnsafeMutablePointer<EVP_PKEY>?) {
                                      ^~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/Keys.swift:80:32: error: use of undeclared type 'EVP_PKEY'
                var kp: UnsafeMutablePointer<EVP_PKEY>? = nil
                                             ^~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer<BIO>?
                                            ^~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/Keys.swift:198:32: error: use of undeclared type 'EVP_PKEY'
                var kp: UnsafeMutablePointer<EVP_PKEY>?
                                             ^~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
        fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
                                                      ^~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer<BIO>?
                                            ^~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
        fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
                                                      ^~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer<BIO>?
                                            ^~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:32:3: error: use of unresolved identifier 'ERR_load_crypto_strings'
                ERR_load_crypto_strings()
                ^~~~~~~~~~~~~~~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:34:3: error: use of unresolved identifier 'OPENSSL_add_all_algorithms_conf'
                OPENSSL_add_all_algorithms_conf()
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:36:20: error: use of unresolved identifier 'CRYPTO_num_locks'; did you mean 'CRYPTO_dynlock'?
                for i in 0..<Int(CRYPTO_num_locks()) {
                                 ^~~~~~~~~~~~~~~~
                                 CRYPTO_dynlock
COpenSSL.CRYPTO_dynlock:1:15: note: 'CRYPTO_dynlock' declared here
public struct CRYPTO_dynlock {
              ^
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:49:3: error: use of unresolved identifier 'CRYPTO_set_locking_callback'
                CRYPTO_set_locking_callback(lockingCallback)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:59:3: error: use of unresolved identifier 'CRYPTO_set_id_callback'
                CRYPTO_set_id_callback(threadIdCallback)
                ^~~~~~~~~~~~~~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:275:30: error: use of undeclared type 'BIO'
        func bio() -> UnsafePointer<BIO>? {
                                    ^~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:281:25: error: use of undeclared type 'EVP_MD'
        var evp: UnsafePointer<EVP_MD> {
                               ^~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:408:25: error: use of undeclared type 'EVP_CIPHER'
        var evp: UnsafePointer<EVP_CIPHER> {
                               ^~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
        fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
                                                      ^~~~~~~~~~
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:304:19: error: use of unresolved identifier 'EVP_MD_CTX_create'
                guard let ctx = EVP_MD_CTX_create() else {
                                ^~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_free:1:13: note: did you mean 'EVP_MD_CTX_free'?
public func EVP_MD_CTX_free(_ ctx: OpaquePointer!)
            ^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
            ^
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:348:19: error: use of unresolved identifier 'EVP_MD_CTX_create'
                guard let ctx = EVP_MD_CTX_create() else {
                                ^~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_free:1:13: note: did you mean 'EVP_MD_CTX_free'?
public func EVP_MD_CTX_free(_ ctx: OpaquePointer!)
            ^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
            ^
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:308:4: error: use of unresolved identifier 'EVP_MD_CTX_destroy'
                        EVP_MD_CTX_destroy(ctx)
                        ^~~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_ctrl:1:13: note: did you mean 'EVP_MD_CTX_ctrl'?
public func EVP_MD_CTX_ctrl(_ ctx: OpaquePointer!, _ cmd: Int32, _ p1: Int32, _ p2: UnsafeMutableRawPointer!) -> Int32
            ^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
            ^
/home/alkis/p/swift/logic2/PerfectTemplate/.build/checkouts/Perfect-Crypto.git--6717123795754789427/Sources/PerfectCrypto/OpenSSLInternal.swift:352:4: error: use of unresolved identifier 'EVP_MD_CTX_destroy'
                        EVP_MD_CTX_destroy(ctx)
                        ^~~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_ctrl:1:13: note: did you mean 'EVP_MD_CTX_ctrl'?
public func EVP_MD_CTX_ctrl(_ ctx: OpaquePointer!, _ cmd: Int32, _ p1: Int32, _ p2: UnsafeMutableRawPointer!) -> Int32
            ^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
            ^
error: terminated(1): /opt/swift-4.2/usr/bin/swift-build-tool -f /home/alkis/p/swift/logic2/PerfectTemplate/.build/debug.yaml main output:
    

alkis@alkisPC:~/p/swift/logic2/PerfectTemplate$ 

system: Ubuntu 18.04
swift --version:

Swift version 4.2 (swift-4.2-CONVERGENCE)
Target: x86_64-unknown-linux-gnu

Error building PerfectThread

Hi

When I run the following in terminal...
git clone https://github.com/PerfectlySoft/PerfectTemplate.git
cd PerfectTemplate
swift build
.build/debug/PerfectTemplate

I get the following error.

Compile Swift Module 'PerfectThread' (2 sources)
/Users/gary/PerfectTemplate/Packages/PerfectThread-0.10.0/Sources/ThreadQueue.swift:210:97: error: cannot convert value of type 'UnsafeMutablePointer' (aka 'UnsafeMutablePointer<()>') to expected argument type 'UnsafeMutablePointer<_>'
let unleakyObject = Unmanaged.fromOpaque(UnsafeMutablePointer(p)).takeRetainedValue()
^
/Users/gary/PerfectTemplate/Packages/PerfectThread-0.10.0/Sources/ThreadQueue.swift:233:37: error: value of type 'Unmanaged' has no member 'toOpaque'
let leakyObject = Unmanaged.passRetained(holderObject).toOpaque()
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/gary/PerfectTemplate/.build/debug.yaml
Garys-MacBook:PerfectTemplate gary$ .build/debug/PerfectTemplate
-bash: .build/debug/PerfectTemplate: No such file or directory

error building in release mode on linux

It was building yesterday, maybe some recent edits caused it?

release.yaml.zip

Verify swift version
root@e7885353a3d2:/s/PerfectTemplate# swift --version Swift version 3.0 (swift-3.0-PREVIEW-2) Target: x86_64-unknown-linux-gnu

build in release mode
root@e7885353a3d2:/s/PerfectTemplate# swift build -c release

Errors:
Linking .build/release/PerfectTemplate /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectThread.build/Threading.swift.o: multiple definition of 'pthread_cond_timedwait_relative_np' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectThread.build/ThreadQueue.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCP.swift.o: multiple definition of 'linux_errno' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCP.swift.o: multiple definition of 'linux_fcntl_get' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCP.swift.o: multiple definition of 'linux_fcntl_set' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetEvent.swift.o: multiple definition of 'SIG_IGN' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/Net.swift.o: multiple definition of 'linux_errno' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetNamedPipe.swift.o: multiple definition of 'linux_errno' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetNamedPipe.swift.o: multiple definition of 'linux_fcntl_get' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here /usr/bin/ld.gold: error: /s/PerfectTemplate/.build/release/PerfectNet.build/NetNamedPipe.swift.o: multiple definition of 'linux_fcntl_set' /usr/bin/ld.gold: /s/PerfectTemplate/.build/release/PerfectNet.build/NetTCPSSL.swift.o: previous definition here clang: error: linker command failed with exit code 1 (use -v to see invocation) <unknown>:0: error: link command failed with exit code 1 (use -v to see invocation) <unknown>:0: error: build had 1 command failures error: exit(1): /usr/bin/swift-build-tool -f /s/PerfectTemplate/.build/release.yaml

Can't run inside docker

Hi,
I'm trying to get the template to work inside a docker container but it doesn't work.
Here is my docker-compose file:

version: '2'
services:
  swiftapi:
    build: ./perfect
    volumes:
      - ./perfect/PerfectTemplate:/usr/src/PerfectTemplate
      - /usr/src/PerfectTemplate/.debug/
    ports:
      - 4000:8181

then inside my service dockerfile I have this

FROM ubuntu:16.04
LABEL maintainer="Haris Amin <[email protected]>"
LABEL Description="Docker Container for the Apple's Swift programming language"

# Install related packages and set LLVM 3.8 as the compiler
RUN apt-get -q update && \
    apt-get -q install -y \
    make \
    libc6-dev \
    clang-3.8 \
    curl \
    libedit-dev \
    libpython2.7 \
    libicu-dev \
    libssl-dev \
    libxml2 \
    tzdata \
    git \
    libcurl4-openssl-dev \
    pkg-config \
    && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 \
    && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 \
    && rm -r /var/lib/apt/lists/*    

# Everything up to here should cache nicely between Swift versions, assuming dev dependencies change little
ARG SWIFT_PLATFORM=ubuntu16.04
ARG SWIFT_BRANCH=swift-4.1.1-release
ARG SWIFT_VERSION=swift-4.1.1-RELEASE

ENV SWIFT_PLATFORM=$SWIFT_PLATFORM \
    SWIFT_BRANCH=$SWIFT_BRANCH \
    SWIFT_VERSION=$SWIFT_VERSION

# Download GPG keys, signature and Swift package, then unpack, cleanup and execute permissions for foundation libs
RUN SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz \
    && curl -fSsL $SWIFT_URL -o swift.tar.gz \
    && curl -fSsL $SWIFT_URL.sig -o swift.tar.gz.sig \
    && export GNUPGHOME="$(mktemp -d)" \
    && set -e; \
        for key in \
      # pub   rsa4096 2017-11-07 [SC] [expires: 2019-11-07]
      # 8513444E2DA36B7C1659AF4D7638F1FB2B2B08C4
      # uid           [ unknown] Swift Automatic Signing Key #2 <[email protected]>
          8513444E2DA36B7C1659AF4D7638F1FB2B2B08C4 \
      # pub   4096R/91D306C6 2016-05-31 [expires: 2018-05-31]
      #       Key fingerprint = A3BA FD35 56A5 9079 C068  94BD 63BC 1CFE 91D3 06C6
      # uid                  Swift 3.x Release Signing Key <[email protected]>
          A3BAFD3556A59079C06894BD63BC1CFE91D306C6 \
      # pub   4096R/71E1B235 2016-05-31 [expires: 2019-06-14]
      #       Key fingerprint = 5E4D F843 FB06 5D7F 7E24  FBA2 EF54 30F0 71E1 B235
      # uid                  Swift 4.x Release Signing Key <[email protected]>          
          5E4DF843FB065D7F7E24FBA2EF5430F071E1B235 \
        ; do \
          gpg --quiet --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
        done \
    && gpg --batch --verify --quiet swift.tar.gz.sig swift.tar.gz \
    && tar -xzf swift.tar.gz --directory / --strip-components=1 \
    && rm -r "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz \
&& chmod -R o+r /usr/lib/swift 

WORKDIR /usr/src/PerfectTemplate
COPY ./PerfectTemplate .
RUN swift --version
RUN swift build
EXPOSE 8181

ENTRYPOINT  [".build/debug/PerfectTemplate"]



Running the docker-compose up command shows this in the logs

swiftapi_1 | standard_init_linux.go:190: exec user process caused "exec format error"

How can I fix it?

Regards

Can not build on Ubuntu18.04 with Swift 5.0.1.

System: Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.18.0-18-generic x86_64)

Swift Version:
Swift version 5.0.1 (swift-5.0.1-RELEASE)
Target: x86_64-unknown-linux-gnu

git clone https://github.com/PerfectlySoft/PerfectTemplate.git
cd PerfectTemplate
swift run

And occur some error.

[1/6] Compiling Swift Module 'PerfectCrypto' (7 sources)
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer?
^~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
^~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:232:11: error: initializer does not override a designated initializer from its superclass
override init(bio: BIOPointer) {
~~~~~~~~ ^
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:281:25: error: use of undeclared type 'EVP_MD'
var evp: UnsafePointer<EVP_MD> {
^~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:408:25: error: use of undeclared type 'EVP_CIPHER'
var evp: UnsafePointer<EVP_CIPHER> {
^~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer?
^~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
^~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/Keys.swift:35:35: error: use of undeclared type 'EVP_PKEY'
init(_ key: UnsafeMutablePointer<EVP_PKEY>?) {
^~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/Keys.swift:31:33: error: use of undeclared type 'EVP_PKEY'
let pkey: UnsafeMutablePointer<EVP_PKEY>?
^~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/Keys.swift:35:35: error: use of undeclared type 'EVP_PKEY'
init(_ key: UnsafeMutablePointer<EVP_PKEY>?) {
^~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/Keys.swift:71:32: error: use of undeclared type 'EVP_PKEY'
init(kp: UnsafeMutablePointer<EVP_PKEY>?) {
^~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/Keys.swift:80:32: error: use of undeclared type 'EVP_PKEY'
var kp: UnsafeMutablePointer<EVP_PKEY>? = nil
^~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:64:45: error: use of undeclared type 'BIO'
typealias BIOPointer = UnsafeMutablePointer?
^~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/Keys.swift:198:32: error: use of undeclared type 'EVP_PKEY'
var kp: UnsafeMutablePointer<EVP_PKEY>?
^~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/ByteIO.swift:78:48: error: use of undeclared type 'BIO_METHOD'
fileprivate init(method: UnsafeMutablePointer<BIO_METHOD>?) {
^~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:32:3: error: use of unresolved identifier 'ERR_load_crypto_strings'
ERR_load_crypto_strings()
^~~~~~~~~~~~~~~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:34:3: error: use of unresolved identifier 'OPENSSL_add_all_algorithms_conf'
OPENSSL_add_all_algorithms_conf()
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:36:20: error: use of unresolved identifier 'CRYPTO_num_locks'; did you mean 'CRYPTO_dynlock'?
for i in 0..<Int(CRYPTO_num_locks()) {
^~~~~~~~~~~~~~~~
CRYPTO_dynlock
COpenSSL.CRYPTO_dynlock:1:15: note: 'CRYPTO_dynlock' declared here
public struct CRYPTO_dynlock {
^
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:49:3: error: use of unresolved identifier 'CRYPTO_set_locking_callback'
CRYPTO_set_locking_callback(lockingCallback)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:59:3: error: use of unresolved identifier 'CRYPTO_set_id_callback'
CRYPTO_set_id_callback(threadIdCallback)
^~~~~~~~~~~~~~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:275:30: error: use of undeclared type 'BIO'
func bio() -> UnsafePointer? {
^~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:281:25: error: use of undeclared type 'EVP_MD'
var evp: UnsafePointer<EVP_MD> {
^~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:408:25: error: use of undeclared type 'EVP_CIPHER'
var evp: UnsafePointer<EVP_CIPHER> {
^~~~~~~~~~
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:304:19: error: use of unresolved identifier 'EVP_MD_CTX_create'
guard let ctx = EVP_MD_CTX_create() else {
^~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_free:1:13: note: did you mean 'EVP_MD_CTX_free'?
public func EVP_MD_CTX_free(_ ctx: OpaquePointer!)
^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
^
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:348:19: error: use of unresolved identifier 'EVP_MD_CTX_create'
guard let ctx = EVP_MD_CTX_create() else {
^~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_free:1:13: note: did you mean 'EVP_MD_CTX_free'?
public func EVP_MD_CTX_free(_ ctx: OpaquePointer!)
^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
^
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:308:4: error: use of unresolved identifier 'EVP_MD_CTX_destroy'
EVP_MD_CTX_destroy(ctx)
^~~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_ctrl:1:13: note: did you mean 'EVP_MD_CTX_ctrl'?
public func EVP_MD_CTX_ctrl(_ ctx: OpaquePointer!, _ cmd: Int32, _ p1: Int32, _ p2: UnsafeMutableRawPointer!) -> Int32
^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
^
/home/tan/桌面/pfubuntu/PerfectTemplate/.build/checkouts/Perfect-Crypto/Sources/PerfectCrypto/OpenSSLInternal.swift:352:4: error: use of unresolved identifier 'EVP_MD_CTX_destroy'
EVP_MD_CTX_destroy(ctx)
^~~~~~~~~~~~~~~~~~
COpenSSL.EVP_MD_CTX_ctrl:1:13: note: did you mean 'EVP_MD_CTX_ctrl'?
public func EVP_MD_CTX_ctrl(_ ctx: OpaquePointer!, _ cmd: Int32, _ p1: Int32, _ p2: UnsafeMutableRawPointer!) -> Int32
^
COpenSSL.EVP_MD_CTX_reset:1:13: note: did you mean 'EVP_MD_CTX_reset'?
public func EVP_MD_CTX_reset(_ ctx: OpaquePointer!) -> Int32
^

No such module 'libpq'

Hello, I cloned PerfectTemplate and added the Perfect-PostgreSQL connector to Package.swift. After I ran swift build and generated the .xcodeproj file, when I try to compile it in Xcode, Xcode complains that there is no such module 'libpq.' It compiles when I build it without the PostgreSQL connector.

Thanks!

No such module 'OpenSSL'

Hello,

This example work with "swift build" but if I use it with Xcode by using "swift package generate-xcodepro", then I get the error of "No such module OpenSSL".

I also did install OpenSSL on my Mac.

See attached file.
2016-07-17_00-39-32

Thanks,
Bao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.