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

Feature/linux #160

Merged
merged 3 commits into from
Jul 14, 2020
Merged

Feature/linux #160

merged 3 commits into from
Jul 14, 2020

Conversation

phimage
Copy link
Member

@phimage phimage commented May 9, 2020

  • fix import
  • change project to decode Xcode Project
    • a lot faster, 0.2s become 0.03s using native plist decoder
      • and could be better if activate a compile flag LAZY to have read only structure with lazy loading of fields
    • the code could be imported instead of making dependencies if we do want all the project feature (but with this change a lot of code has been removed PathKit, AEXML, ...)
  • add missing linux main for test

There is still an issue with sha1 in LintCache

@phimage
Copy link
Member Author

phimage commented May 9, 2020

I make a version with CryptoKit on recent macOS, fallback to commonCrypto
then on linux by importing https://github.com/apple/swift-crypto
but again this a mess, not same name, need to specify the name in Package.swift...
I do not want to import on macOS, so that's I have no committed yet

#if os(Linux)
import Crypto
#else
import CommonCrypto
private extension Data {
    func sha1_common() -> Data {
        return withUnsafeBytes { [count] ptr in
            var hash = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))
            if let bytes = ptr.baseAddress?.assumingMemoryBound(to: UInt8.self) {
                CC_SHA1(bytes, CC_LONG(count), &hash)
            }
            return Data(hash)
        }
    }
}
#if canImport(CryptoKit)
import CryptoKit
#endif
#endif

private extension Data {
    func sha1() -> Data {
        #if os(Linux)
        return Data(Insecure.SHA1.hash(data: self))
        #else
        #if canImport(CryptoKit)
        if #available(OSX 10.15, *) {
            return Data(Insecure.SHA1.hash(data: self))
        } else {
            return sha1_common()
        }
        #else
        return sha1_common()
        #endif
        #endif
    }
}

@phimage phimage changed the title WIP: Feature/linux Feature/linux May 10, 2020
@phimage
Copy link
Member Author

phimage commented May 10, 2020

Screenshot 2020-05-10 at 22 07 20

I keep legacy sha1 using commonCrypto on Mac and find a way to add only for linux the swift-crypto package

package swift file is 5.0; if updated to 5.2 some change must done "use .product() for dependencies"

It's ready for review

@phimage phimage requested review from kateinoigakukun and giginet and removed request for kateinoigakukun May 10, 2020 20:11
@kateinoigakukun
Copy link
Collaborator

Sorry for late response 🙇

@kateinoigakukun kateinoigakukun merged commit 206d3e5 into master Jul 14, 2020
@kateinoigakukun kateinoigakukun deleted the feature/linux branch September 26, 2020 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants