This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8ee8b1
commit c613b36
Showing
28 changed files
with
2,758 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/macos,swift,swiftpm,xcode,objective-c | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,swift,swiftpm,xcode,objective-c | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Objective-C ### | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) | ||
*.xcscmblueprint | ||
*.xccheckout | ||
|
||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) | ||
build/ | ||
DerivedData/ | ||
*.moved-aside | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
||
## App packaging | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
# CocoaPods | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# Pods/ | ||
# Add this line if you want to avoid checking in source code from the Xcode workspace | ||
# *.xcworkspace | ||
|
||
# Carthage | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build/ | ||
|
||
# fastlane | ||
# It is recommended to not store the screenshots in the git repo. | ||
# Instead, use fastlane to re-generate the screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output | ||
|
||
# Code Injection | ||
# After new code Injection tools there's a generated folder /iOSInjectionProject | ||
# https://github.com/johnno1962/injectionforxcode | ||
|
||
iOSInjectionProject/ | ||
|
||
### Objective-C Patch ### | ||
|
||
### Swift ### | ||
# Xcode | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
|
||
|
||
|
||
|
||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
# Package.resolved | ||
# *.xcodeproj | ||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata | ||
# hence it is not needed unless you have added a package configuration file to your project | ||
# .swiftpm | ||
|
||
.build/ | ||
|
||
# CocoaPods | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# Pods/ | ||
# Add this line if you want to avoid checking in source code from the Xcode workspace | ||
# *.xcworkspace | ||
|
||
# Carthage | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
|
||
# Accio dependency management | ||
Dependencies/ | ||
.accio/ | ||
|
||
# fastlane | ||
# It is recommended to not store the screenshots in the git repo. | ||
# Instead, use fastlane to re-generate the screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
|
||
# Code Injection | ||
# After new code Injection tools there's a generated folder /iOSInjectionProject | ||
# https://github.com/johnno1962/injectionforxcode | ||
|
||
|
||
### SwiftPM ### | ||
Packages | ||
xcuserdata | ||
*.xcodeproj | ||
|
||
|
||
### Xcode ### | ||
|
||
## Xcode 8 and earlier | ||
|
||
### Xcode Patch ### | ||
*.xcodeproj/* | ||
!*.xcodeproj/project.pbxproj | ||
!*.xcodeproj/xcshareddata/ | ||
!*.xcworkspace/contents.xcworkspacedata | ||
/*.gcno | ||
**/xcshareddata/WorkspaceSettings.xcsettings | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/macos,swift,swiftpm,xcode,objective-c |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "swift-argument-parser", | ||
"repositoryURL": "https://github.com/apple/swift-argument-parser", | ||
"state": { | ||
"branch": null, | ||
"revision": "e1465042f195f374b94f915ba8ca49de24300a0d", | ||
"version": "1.0.2" | ||
} | ||
}, | ||
{ | ||
"package": "swift-tools-support-core", | ||
"repositoryURL": "https://github.com/apple/swift-tools-support-core", | ||
"state": { | ||
"branch": null, | ||
"revision": "f9bbd6b80d67408021576adf6247e17c2e957d92", | ||
"version": "0.2.4" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// swift-tools-version:5.5 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "swift-ton", | ||
platforms: [ | ||
.macOS(.v12), | ||
], | ||
products: [ | ||
.executable( | ||
name: "builder", | ||
targets: ["builder"] | ||
), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/apple/swift-tools-support-core", .upToNextMajor(from: "0.2.4")), | ||
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMajor(from: "1.0.0")), | ||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "builder", | ||
dependencies: [ | ||
.product( | ||
name: "ArgumentParser", | ||
package: "swift-argument-parser" | ||
), | ||
.product( | ||
name: "SwiftToolsSupport-auto", | ||
package: "swift-tools-support-core" | ||
), | ||
], | ||
path: "Sources/Builder", | ||
swiftSettings: [ | ||
.define("DEBUG", .when(configuration: .debug)), | ||
] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# ton-swift | ||
## Swift builder for [tonlib](https://github.com/labraburn/ton/tree/labraburn) repository | ||
|
||
This is package helps to build **TON.xcframework** and **OpenSSL.xcframework** | ||
|
||
## Requirements | ||
|
||
- **Xcode** 13.2 + | ||
- **CMake** 3 + | ||
- **Swift** 5.6+ | ||
|
||
## Supported platfroms | ||
|
||
- macOS/simulator/arm64 | ||
- iOS/simulator | ||
- macCatalyst/simulator | ||
- watchOS/simulator | ||
- tvOS/simulator | ||
|
||
## Usage | ||
|
||
Go to repository directory and run: | ||
|
||
```sh | ||
swift run builder --output ./build --clean | ||
``` | ||
|
||
|
||
## Notes | ||
- Should be builded with Rosetta on M1 chip | ||
- Default version of OpenSSL used here is 1.1.1i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// Created by Anton Spivak. | ||
// | ||
|
||
import Foundation | ||
|
||
enum BuildLibrary: String, CaseIterable { | ||
|
||
case openssl | ||
case ton | ||
|
||
var libraryName: String { | ||
switch self { | ||
case .openssl: | ||
return "libopenssl.a" | ||
case .ton: | ||
return "libton.a" | ||
} | ||
} | ||
|
||
var xcframeworkName: String { | ||
switch self { | ||
case .openssl: | ||
return "OpenSSL.xcframework" | ||
case .ton: | ||
return "TON.xcframework" | ||
} | ||
} | ||
|
||
func outputURL(createIfNeeded: Bool = false) throws -> URL { | ||
let fileManager = FileManager.default | ||
|
||
var path = "" | ||
switch self { | ||
case .openssl: | ||
path = "/build/openssl/ouput" | ||
case .ton: | ||
path = "/build/ton/ouput" | ||
} | ||
|
||
return try fileManager.cacheURL( | ||
withPath: path, | ||
createIfNeeded: createIfNeeded | ||
) | ||
} | ||
|
||
func buildCommand() -> AwaitingParsableCommand.Type { | ||
switch self { | ||
case .openssl: | ||
return OpenSSL.self | ||
case .ton: | ||
return TON.self | ||
} | ||
} | ||
|
||
func buildExists() throws -> Bool { | ||
let fileManager = FileManager.default | ||
let outputURL = try outputURL() | ||
|
||
if fileManager.directoryExists(atPath: outputURL.relativePath) { | ||
return !(try fileManager.contentsOfDirectory(atPath: outputURL.relativePath)).isEmpty | ||
} | ||
|
||
return false | ||
} | ||
|
||
func buildExists(for platform: BuildPlatform) throws -> Bool { | ||
let fileManager = FileManager.default | ||
let outputURL = (try outputURL()).appendingPathComponent(platform.buildURLPathComponent()) | ||
|
||
if fileManager.directoryExists(atPath: outputURL.relativePath) { | ||
return !(try fileManager.contentsOfDirectory(atPath: outputURL.relativePath)).isEmpty | ||
} | ||
|
||
return false | ||
} | ||
|
||
func buildIncludeURL(for platform: BuildPlatform) throws -> Foundation.URL { | ||
let outputURL = (try outputURL()).appendingPathComponent(platform.buildURLPathComponent()) | ||
let includeURL = outputURL.appendingPathComponent("include") | ||
return includeURL | ||
} | ||
|
||
func buildLibURL(for platform: BuildPlatform) throws -> Foundation.URL { | ||
let outputURL = (try outputURL()).appendingPathComponent(platform.buildURLPathComponent()) | ||
let includeURL = outputURL.appendingPathComponent("lib/\(libraryName)") | ||
return includeURL | ||
} | ||
} | ||
|
||
fileprivate enum BuildLibraryError: LocalizedError { | ||
|
||
case dosntHaveAnyBuildedLibrary(url: URL) | ||
|
||
var errorDescription: String? { | ||
switch self { | ||
case let .dosntHaveAnyBuildedLibrary(url): | ||
return "Can't locate builded libraries at \(url.relativePath)" | ||
} | ||
} | ||
} |
Oops, something went wrong.