Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Contributing to Swift

Ayaka Nonaka
November 08, 2016

Contributing to Swift

A few months ago, I somehow ended up contributing a non-trivial diff to the Swift compiler without much prior experience with C++ and absolutely zero with compilers, and a lot of people have been asking me how I managed to pull that off. This talk will go over how to get up and running with the Swift compiler and how you can contribute too even if it feels completely new and scary!

Ayaka Nonaka

November 08, 2016
Tweet

More Decks by Ayaka Nonaka

Other Decks in Technology

Transcript

  1. 1. Clone the repo 1.mkdir swift-source (or wherever) 2.cd into

    swift-source & clone repo 3../swift/utils/update-checkout --clone
  2. ImportDecl.cpp Decl * VisitObjCCompatibleAliasDecl(const clang::ObjCCompatibleAliasDecl *decl) { // Like C++

    using declarations, name lookup simply looks through // Objective-C compatibility aliases. They are not imported directly. return nullptr; }
  3. !?

  4. !

  5. 1.Write some Objective-C code. 2.Import it from Swift. 3.Make some

    assertions based on what you would expect.
  6. 1.Write some Objective-C code. ✅ 2.Import it from Swift. 3.Make

    some assertions based on what you would expect.
  7. 1.Write some Objective-C code. ✅ 2.Import it from Swift. ✅

    3.Make some assertions based on what you would expect.
  8. // RUN: rm -rf %t // RUN: mkdir -p %t

    // RUN: %build-clang-importer-objc-overlays // RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk-nosource) -I %t -I %S/Inputs/custom-modules // -print-module -source-filename %s -module-to-print=CompatibilityAlias > %t.printed.CompatibilityAlias.txt // RUN: FileCheck %s -check-prefix=PRINT -strict-whitespace < %t.printed.CompatibilityAlias.txt // RUN: %target-parse-verify-swift -sdk %clang-importer-sdk -I %S/Inputs/custom-modules -I %t %s // REQUIRES: objc_interop // PRINT: typealias StringCheese = NSString import CompatibilityAlias func dontMove(cheese: StringCheese) -> StringCheese { return cheese }
  9. // RUN: rm -rf %t // RUN: mkdir -p %t

    // RUN: %build-clang-importer-objc-overlays // RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk-nosource) -I %t -I %S/Inputs/custom-modules // -print-module -source-filename %s -module-to-print=CompatibilityAlias > %t.printed.CompatibilityAlias.txt // RUN: FileCheck %s -check-prefix=PRINT -strict-whitespace < %t.printed.CompatibilityAlias.txt // RUN: %target-parse-verify-swift -sdk %clang-importer-sdk -I %S/Inputs/custom-modules -I %t %s // REQUIRES: objc_interop // PRINT: typealias StringCheese = NSString
  10. lldb -- /Users/ayanonagon/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc -frontend -target x86_64-apple-macosx10.9 -module-cache-path '/var/folders/g9/jwhqvm3x1rx65dtfhdrb00dc0000gn/T/swift-testsuite-clang-module-cacheK6GoT_' -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk

    -parse -verify -disable-objc-attr-requires-foundation-module /Users/ayanonagon/swift-source/swift/test/IDE/compatibility_alias.swift -sdk -enable-source-import -sdk '/Users/ayanonagon/swift-source/swift/test'/Inputs/clang-importer-sdk -I '/Users/ayanonagon/swift-source/swift/test'/Inputs/clang-importer-sdk/swift-modules -I /Users/ayanonagon/swift-source/swift/test/IDE/Inputs/custom-modules -I /Users/ayanonagon/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/IDE/Output/compatibility_alias.swift.tmp /Users/ayanonagon/swift-source/swift/test/IDE/compatibility_alias.swift
  11. !

  12. » The secret life of types in Swift by Slava

    Pestov » Porting the Swift Runtime to Android by Brian Gesiak » Contributing to Open Source Swift by Jesse Squires » Contributing to Swift by Russ Bishop
  13. » The secret life of types in Swift by Slava

    Pestov » Porting the Swift Runtime to Android by Brian Gesiak » Contributing to Open Source Swift by Jesse Squires » Contributing to Swift by Russ Bishop » Contributing to Swift by YOU <3