Commit 33480518 authored by Drew's avatar Drew

Support OSX framework building

parents
*xcuserdata*
*.atllbuild
bin
external
;; Anarchy Tools Package Manager lock file
;;
;; If you want to pin a package to a git commit add a ':pin-commit'
;; line to that package definition. This will override all version
;; information the build files specify.
;;
;; You may override the repository URL for a package by specifying
;; it in an ':override-url' line. This is very handy if you develop
;; the dependency in parallel to the package that uses it
(lock-file
:packages [
{
:url "https://github.com/AnarchyTools/atfoundation.git"
:used-commit "79d1549a9868328c755d6c5ddb346592091d0a44"
}
]
)
(package
:name "PackageFramework"
:external-packages [
{
:url "https://github.com/AnarchyTools/atfoundation.git"
:branch "master"
}]
:import-packages ["tests/osx/build.atpkg"]
:tasks {
:default {
:tool "atllbuild"
:sources ["src/**.swift"]
:output-type "executable"
:name "package_framework"
:dependencies ["atfoundation.atfoundation"]
:link-with ["atfoundation.a"]
:compile-options ["-g"]
:executable-name "package-framework"
}
:check {
:dependencies ["default" "osxframework.check"]
:tool "nop"
}
}
)
\ No newline at end of file
import atfoundation
private enum ModuleMapType: String {
case Synthesized = "synthesized"
}
private enum Options: String {
case InfoPlist = "info-plist"
case Name = "name"
}
func env(_ feature: String) -> String? {
let env = getenv(feature)
guard let e = env else { return nil }
return String(validatingUTF8: e)
}
func arg(_ larg: String) -> String? {
for (x, arg) in Process.arguments.enumerated() {
if arg == "--\(larg)" { return Process.arguments[x+1] }
}
return nil
}
class PackageFramework {
func run() {
guard let platform = env("ATBUILD_PLATFORM") else {
fatalError("Set $ATBUILD_PLATFORM")
}
let architecture: String
switch (platform) {
case "osx":
architecture = "x86_64"
default:
fatalError("Unsupported platform \(platform)")
}
guard let name = arg(Options.Name.rawValue) else {
fatalError("Specify a \(Options.Name.rawValue)")
}
guard let infoPlist = arg(Options.InfoPlist.rawValue) else {
fatalError("Specify a \(Options.InfoPlist.rawValue)")
}
var resources: [String] = [infoPlist]
//rm framework if it exists
let frameworkPath = Path("bin/\(name).framework")
let _ = try? FS.removeItem(path: frameworkPath, recursive: true)
let _ = try? FS.createDirectory(path: frameworkPath)
//'a' version
let relativeAVersionPath = Path("Versions/A")
let AVersionPath = frameworkPath + relativeAVersionPath
try! FS.createDirectory(path: AVersionPath, intermediate: true)
//'current' (produces code signing failures if absent)
try! FS.symlinkItem(from: Path("A"), to: frameworkPath + "Versions/Current")
//copy payload
//atbin path
let atbinPath = Path("bin").appending("\(name).atbin")
let payloadPath = atbinPath.appending(name + ".dylib")
try! FS.copyItem(from: payloadPath, to: AVersionPath.appending(name))
try! FS.symlinkItem(from: relativeAVersionPath.appending(name), to: frameworkPath.appending(name))
//copy modules
let modulePath = AVersionPath.appending("Modules").appending(name + ".swiftmodule")
try! FS.createDirectory(path: modulePath, intermediate: true)
let swiftModulePath = atbinPath.appending("\(platform).swiftmodule")
if FS.fileExists(path: swiftModulePath) {
try! FS.copyItem(from: swiftModulePath, to: modulePath.appending("\(architecture).swiftmodule"))
}
let swiftDocPath = atbinPath.appending("\(platform).swiftdoc")
if FS.fileExists(path: swiftDocPath) {
try! FS.copyItem(from: swiftDocPath, to: modulePath.appending("\(architecture).swiftdoc"))
}
try! FS.symlinkItem(from: relativeAVersionPath.appending("Modules"), to: frameworkPath.appending("Modules"))
//copy resources
let resourcesPath = AVersionPath.appending("Resources")
try! FS.createDirectory(path: resourcesPath, intermediate: true)
for resource in resources {
try! FS.copyItem(from: Path(resource), to: resourcesPath + resource)
}
try! FS.symlinkItem(from: relativeAVersionPath + "Resources", to: frameworkPath + "Resources")
//codesign
let cmd = "codesign --force --deep --sign - --timestamp=none '\(AVersionPath)'"
print(cmd)
if system(cmd) != 0 {
fatalError("Codesign failed.")
}
}
}
PackageFramework().run()
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Drew Crawford. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:UseOSXFramework.xcodeproj">
</FileRef>
</Workspace>
//
// AppDelegate.swift
// UseOSXFramework
//
// Created by Drew Crawford on 5/9/16.
// Copyright © 2016 Drew Crawford. All rights reserved.
//
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
// Insert code here to initialize your application
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
}
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Drew Crawford. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
//
// UseOSXFrameworkTests.swift
// UseOSXFrameworkTests
//
// Created by Drew Crawford on 5/9/16.
// Copyright © 2016 Drew Crawford. All rights reserved.
//
import XCTest
@testable import UseOSXFramework
import FooFramework
class UseOSXFrameworkTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
Foo()
}
}
Versions/A/FooFramework
\ No newline at end of file
Versions/A/Modules
\ No newline at end of file
Versions/A/Resources
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Drew Crawford. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict/>
<key>files2</key>
<dict>
<key>FooFramework</key>
<dict>
<key>cdhash</key>
<data>
VfTS+lM5Ww8vBEdtE8aNoXYLVZA=
</data>
<key>requirement</key>
<string>cdhash H"f78670fd4e46a8e4ce92699eccb946d1b89263b8" or cdhash H"55f4d2fa53395b0f2f04476d13c68da1760b5590"</string>
</dict>
<key>Modules/FooFramework.swiftmodule/x86_64.swiftdoc</key>
<dict>
<key>hash</key>
<data>
1RmlH0UAhDJ6T5BXZusdV5iBdgw=
</data>
<key>hash2</key>
<data>
8vD5i8H1KiIGQ6ysi2/GxkMchlONlwpm2U0KRsjdCN4=
</data>
</dict>
<key>Modules/FooFramework.swiftmodule/x86_64.swiftmodule</key>
<dict>
<key>hash</key>
<data>
O9CTrcPojCk40qBlFOuPJV4hPQc=
</data>
<key>hash2</key>
<data>
C7kfqwwquysaJ66XUGrTS0l0XpTqH76PpoOpmT9kEG8=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
(package
:name "osxframework"
:tasks {
:default {
:tool "atllbuild"
:output-type "dynamic-library"
:sources ["src/**.swift"]
:name "FooFramework"
:framework true
}
:packageatbin {
:tool "packageatbin"
:name "FooFramework"
:platforms ["all"]
:atllbuild-task "default"
}
:package {
:tool "shell"
:script "../../.atllbuild/products/package-framework --name FooFramework --info-plist Info.plist"
:dependencies ["packageatbin"]
}
:check {
:tool "shell"
:script "xcodebuild -scheme UseOSXFramework test"
:dependencies ["package"]
}
}
)
\ No newline at end of file
public class Foo { public init() { }}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment