Build and install custom toolchain?


(Lily Ballard) #1

Is there an easy way to build and install my own toolchain into /Library/Developer/Toolchains? I assume there must be some automated way to construct the package installer, but nothing immediately leaps out at me. It looks like build-script can create a root, but that seems to be for BNI, which isn't helpful.

The reason for doing this here is I have a Vim plugin that lets me execute Swift scripts from vim buffers, and it supports using the swift from any given Xcode. I want to teach it how to find swift in /Library/Developer/Toolchains instead, which requires that I actually install a toolchain there (teaching it how to use the build folder from my swift checkout is doable, but that's not very portable).

-Kevin Ballard


(Mish Awadah) #2

Hi Kevin,

Here’s what I’ve done in the past to build a toolchain using the build script.

function build_osx_package() {

    YEAR=$(date +"%Y")
    MONTH=$(date +"%m")
    DAY=$(date +"%d")
    TOOLCHAIN_VERSION="swift-SNAPSHOT-${YEAR}-${MONTH}-${DAY}-a"
    ARCHIVE_DIR="${TOOLCHAIN_VERSION}-${BUILD_NUMBER}"
    ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
    SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
    BUNDLE_IDENTIFIER="org.swift.${YEAR}${MONTH}${DAY}"
    DISPLAY_NAME="Swift Development Snapshot"
    TOOLCHAIN_NAME="${TOOLCHAIN_VERSION}"

    SWIFT_SOURCE_ROOT="${SRC_DIR}"
    SWIFT_BUILD_ROOT="${SRC_DIR}/build"
    SWIFT_INSTALLABLE_PACKAGE="${SRC_DIR}/${ARCHIVE}"
    SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
    SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
    SWIFT_TOOLCHAIN_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
    SYMBOLS_PACKAGE="${SRC_DIR}/${SYM_ARCHIVE}"

    ./swift/utils/build-script --preset="buildbot_osx_package" install_destdir="${SWIFT_INSTALL_DIR}" installable_package="${SWIFT_INSTALLABLE_PACKAGE}" install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" install_symroot="${SWIFT_INSTALL_SYMROOT}" symbols_package="${SYMBOLS_PACKAGE}" darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" darwin_toolchain_display_name="${DISPLAY_NAME}" darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" darwin_toolchain_version="${TOOLCHAIN_VERSION}"
}

HTH,
- mish

···

On Dec 9, 2015, at 2:32 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:

Is there an easy way to build and install my own toolchain into /Library/Developer/Toolchains? I assume there must be some automated way to construct the package installer, but nothing immediately leaps out at me. It looks like build-script can create a root, but that seems to be for BNI, which isn't helpful.

The reason for doing this here is I have a Vim plugin that lets me execute Swift scripts from vim buffers, and it supports using the swift from any given Xcode. I want to teach it how to find swift in /Library/Developer/Toolchains instead, which requires that I actually install a toolchain there (teaching it how to use the build folder from my swift checkout is doable, but that's not very portable).

-Kevin Ballard
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


(Lily Ballard) #3

It does help, thanks. I'm surprised there's no script (or option to build-script) to do this automatically. Seems like a reasonable thing to want to do upon occasion.

Also, I assume that those of us who aren't at Apple probably don't want to be using /Applications/Xcode.app/Contents/Developer/Toolchains/ as our install dir, but instead /Library/Developer/Toolchains/ like where the snapshot installs.

-Kevin Ballard

···

On Wed, Dec 9, 2015, at 04:18 PM, Mish Awadah wrote:

Hi Kevin,

Here’s what I’ve done in the past to build a toolchain using the build script.

function build_osx_package() {

    YEAR=$(date +"%Y")
    MONTH=$(date +"%m")
    DAY=$(date +"%d")
    TOOLCHAIN_VERSION="swift-SNAPSHOT-${YEAR}-${MONTH}-${DAY}-a"
    ARCHIVE_DIR="${TOOLCHAIN_VERSION}-${BUILD_NUMBER}"
    ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
    SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
    BUNDLE_IDENTIFIER="org.swift.${YEAR}${MONTH}${DAY}"
    DISPLAY_NAME="Swift Development Snapshot"
    TOOLCHAIN_NAME="${TOOLCHAIN_VERSION}"

    SWIFT_SOURCE_ROOT="${SRC_DIR}"
    SWIFT_BUILD_ROOT="${SRC_DIR}/build"
    SWIFT_INSTALLABLE_PACKAGE="${SRC_DIR}/${ARCHIVE}"
    SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
    SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
    SWIFT_TOOLCHAIN_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
    SYMBOLS_PACKAGE="${SRC_DIR}/${SYM_ARCHIVE}"

    ./swift/utils/build-script --preset="buildbot_osx_package" install_destdir="${SWIFT_INSTALL_DIR}" installable_package="${SWIFT_INSTALLABLE_PACKAGE}" install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" install_symroot="${SWIFT_INSTALL_SYMROOT}" symbols_package="${SYMBOLS_PACKAGE}" darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" darwin_toolchain_display_name="${DISPLAY_NAME}" darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" darwin_toolchain_version="${TOOLCHAIN_VERSION}"
}

HTH,
- mish

> On Dec 9, 2015, at 2:32 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:
>
> Is there an easy way to build and install my own toolchain into /Library/Developer/Toolchains? I assume there must be some automated way to construct the package installer, but nothing immediately leaps out at me. It looks like build-script can create a root, but that seems to be for BNI, which isn't helpful.
>
> The reason for doing this here is I have a Vim plugin that lets me execute Swift scripts from vim buffers, and it supports using the swift from any given Xcode. I want to teach it how to find swift in /Library/Developer/Toolchains instead, which requires that I actually install a toolchain there (teaching it how to use the build folder from my swift checkout is doable, but that's not very portable).
>
> -Kevin Ballard
> _______________________________________________
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev


(Daniel Dunbar) #4

Agreed, we should probably try and clean up the command line syntax (and --help) to direct people towards the options that make the most sense. Having just an "--install" option that did something sensible for your current platform + other options would make a lot of sense to me.

I'd recommend filing specific enhancement requests as bugs, since these should be easy things for people to cherry pick off. Ditto for the bug about the install path.

- Daniel

···

On Dec 9, 2015, at 9:34 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:

It does help, thanks. I'm surprised there's no script (or option to build-script) to do this automatically. Seems like a reasonable thing to want to do upon occasion.

Also, I assume that those of us who aren't at Apple probably don't want to be using /Applications/Xcode.app/Contents/Developer/Toolchains/ as our install dir, but instead /Library/Developer/Toolchains/ like where the snapshot installs.

-Kevin Ballard

On Wed, Dec 9, 2015, at 04:18 PM, Mish Awadah wrote:

Hi Kevin,

Here’s what I’ve done in the past to build a toolchain using the build script.

function build_osx_package() {

   YEAR=$(date +"%Y")
   MONTH=$(date +"%m")
   DAY=$(date +"%d")
   TOOLCHAIN_VERSION="swift-SNAPSHOT-${YEAR}-${MONTH}-${DAY}-a"
   ARCHIVE_DIR="${TOOLCHAIN_VERSION}-${BUILD_NUMBER}"
   ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
   SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
   BUNDLE_IDENTIFIER="org.swift.${YEAR}${MONTH}${DAY}"
   DISPLAY_NAME="Swift Development Snapshot"
   TOOLCHAIN_NAME="${TOOLCHAIN_VERSION}"

   SWIFT_SOURCE_ROOT="${SRC_DIR}"
   SWIFT_BUILD_ROOT="${SRC_DIR}/build"
   SWIFT_INSTALLABLE_PACKAGE="${SRC_DIR}/${ARCHIVE}"
   SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
   SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
   SWIFT_TOOLCHAIN_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
   SYMBOLS_PACKAGE="${SRC_DIR}/${SYM_ARCHIVE}"

   ./swift/utils/build-script --preset="buildbot_osx_package" install_destdir="${SWIFT_INSTALL_DIR}" installable_package="${SWIFT_INSTALLABLE_PACKAGE}" install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" install_symroot="${SWIFT_INSTALL_SYMROOT}" symbols_package="${SYMBOLS_PACKAGE}" darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" darwin_toolchain_display_name="${DISPLAY_NAME}" darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" darwin_toolchain_version="${TOOLCHAIN_VERSION}"
}

HTH,
- mish

On Dec 9, 2015, at 2:32 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:

Is there an easy way to build and install my own toolchain into /Library/Developer/Toolchains? I assume there must be some automated way to construct the package installer, but nothing immediately leaps out at me. It looks like build-script can create a root, but that seems to be for BNI, which isn't helpful.

The reason for doing this here is I have a Vim plugin that lets me execute Swift scripts from vim buffers, and it supports using the swift from any given Xcode. I want to teach it how to find swift in /Library/Developer/Toolchains instead, which requires that I actually install a toolchain there (teaching it how to use the build folder from my swift checkout is doable, but that's not very portable).

-Kevin Ballard
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


(Lily Ballard) #5

I filed a ticket for making such a script as https://bugs.swift.org/browse/SR-174.

I'm not filing one for the install path at the moment, since that appears to be configurable in the code you provided (your code is just hardcoding the install dir as inside of Xcode).

-Kevin

···

On Wed, Dec 9, 2015, at 09:37 PM, Daniel Dunbar wrote:

Agreed, we should probably try and clean up the command line syntax (and --help) to direct people towards the options that make the most sense. Having just an "--install" option that did something sensible for your current platform + other options would make a lot of sense to me.

I'd recommend filing specific enhancement requests as bugs, since these should be easy things for people to cherry pick off. Ditto for the bug about the install path.

- Daniel

> On Dec 9, 2015, at 9:34 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:
>
> It does help, thanks. I'm surprised there's no script (or option to build-script) to do this automatically. Seems like a reasonable thing to want to do upon occasion.
>
> Also, I assume that those of us who aren't at Apple probably don't want to be using /Applications/Xcode.app/Contents/Developer/Toolchains/ as our install dir, but instead /Library/Developer/Toolchains/ like where the snapshot installs.
>
> -Kevin Ballard
>
> On Wed, Dec 9, 2015, at 04:18 PM, Mish Awadah wrote:
>> Hi Kevin,
>>
>> Here’s what I’ve done in the past to build a toolchain using the build script.
>>
>> function build_osx_package() {
>>
>> YEAR=$(date +"%Y")
>> MONTH=$(date +"%m")
>> DAY=$(date +"%d")
>> TOOLCHAIN_VERSION="swift-SNAPSHOT-${YEAR}-${MONTH}-${DAY}-a"
>> ARCHIVE_DIR="${TOOLCHAIN_VERSION}-${BUILD_NUMBER}"
>> ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
>> SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
>> BUNDLE_IDENTIFIER="org.swift.${YEAR}${MONTH}${DAY}"
>> DISPLAY_NAME="Swift Development Snapshot"
>> TOOLCHAIN_NAME="${TOOLCHAIN_VERSION}"
>>
>> SWIFT_SOURCE_ROOT="${SRC_DIR}"
>> SWIFT_BUILD_ROOT="${SRC_DIR}/build"
>> SWIFT_INSTALLABLE_PACKAGE="${SRC_DIR}/${ARCHIVE}"
>> SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
>> SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
>> SWIFT_TOOLCHAIN_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
>> SYMBOLS_PACKAGE="${SRC_DIR}/${SYM_ARCHIVE}"
>>
>> ./swift/utils/build-script --preset="buildbot_osx_package" install_destdir="${SWIFT_INSTALL_DIR}" installable_package="${SWIFT_INSTALLABLE_PACKAGE}" install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" install_symroot="${SWIFT_INSTALL_SYMROOT}" symbols_package="${SYMBOLS_PACKAGE}" darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" darwin_toolchain_display_name="${DISPLAY_NAME}" darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" darwin_toolchain_version="${TOOLCHAIN_VERSION}"
>> }
>>
>> HTH,
>> - mish
>>
>>> On Dec 9, 2015, at 2:32 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:
>>>
>>> Is there an easy way to build and install my own toolchain into /Library/Developer/Toolchains? I assume there must be some automated way to construct the package installer, but nothing immediately leaps out at me. It looks like build-script can create a root, but that seems to be for BNI, which isn't helpful.
>>>
>>> The reason for doing this here is I have a Vim plugin that lets me execute Swift scripts from vim buffers, and it supports using the swift from any given Xcode. I want to teach it how to find swift in /Library/Developer/Toolchains instead, which requires that I actually install a toolchain there (teaching it how to use the build folder from my swift checkout is doable, but that's not very portable).
>>>
>>> -Kevin Ballard
>>> _______________________________________________
>>> swift-dev mailing list
>>> swift-dev@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-dev
>>
> _______________________________________________
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev


(Lily Ballard) #6

Oh I'm sorry, I meant in the code Mish provided.

-Kevin Ballard

···

On Wed, Dec 9, 2015, at 09:55 PM, Kevin Ballard wrote:

I filed a ticket for making such a script as https://bugs.swift.org/browse/SR-174.

I'm not filing one for the install path at the moment, since that appears to be configurable in the code you provided (your code is just hardcoding the install dir as inside of Xcode).

-Kevin

On Wed, Dec 9, 2015, at 09:37 PM, Daniel Dunbar wrote:
> Agreed, we should probably try and clean up the command line syntax (and --help) to direct people towards the options that make the most sense. Having just an "--install" option that did something sensible for your current platform + other options would make a lot of sense to me.
>
> I'd recommend filing specific enhancement requests as bugs, since these should be easy things for people to cherry pick off. Ditto for the bug about the install path.
>
> - Daniel
>
> > On Dec 9, 2015, at 9:34 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:
> >
> > It does help, thanks. I'm surprised there's no script (or option to build-script) to do this automatically. Seems like a reasonable thing to want to do upon occasion.
> >
> > Also, I assume that those of us who aren't at Apple probably don't want to be using /Applications/Xcode.app/Contents/Developer/Toolchains/ as our install dir, but instead /Library/Developer/Toolchains/ like where the snapshot installs.
> >
> > -Kevin Ballard
> >
> > On Wed, Dec 9, 2015, at 04:18 PM, Mish Awadah wrote:
> >> Hi Kevin,
> >>
> >> Here’s what I’ve done in the past to build a toolchain using the build script.
> >>
> >> function build_osx_package() {
> >>
> >> YEAR=$(date +"%Y")
> >> MONTH=$(date +"%m")
> >> DAY=$(date +"%d")
> >> TOOLCHAIN_VERSION="swift-SNAPSHOT-${YEAR}-${MONTH}-${DAY}-a"
> >> ARCHIVE_DIR="${TOOLCHAIN_VERSION}-${BUILD_NUMBER}"
> >> ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
> >> SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
> >> BUNDLE_IDENTIFIER="org.swift.${YEAR}${MONTH}${DAY}"
> >> DISPLAY_NAME="Swift Development Snapshot"
> >> TOOLCHAIN_NAME="${TOOLCHAIN_VERSION}"
> >>
> >> SWIFT_SOURCE_ROOT="${SRC_DIR}"
> >> SWIFT_BUILD_ROOT="${SRC_DIR}/build"
> >> SWIFT_INSTALLABLE_PACKAGE="${SRC_DIR}/${ARCHIVE}"
> >> SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
> >> SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
> >> SWIFT_TOOLCHAIN_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
> >> SYMBOLS_PACKAGE="${SRC_DIR}/${SYM_ARCHIVE}"
> >>
> >> ./swift/utils/build-script --preset="buildbot_osx_package" install_destdir="${SWIFT_INSTALL_DIR}" installable_package="${SWIFT_INSTALLABLE_PACKAGE}" install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" install_symroot="${SWIFT_INSTALL_SYMROOT}" symbols_package="${SYMBOLS_PACKAGE}" darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" darwin_toolchain_display_name="${DISPLAY_NAME}" darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" darwin_toolchain_version="${TOOLCHAIN_VERSION}"
> >> }
> >>
> >> HTH,
> >> - mish
> >>
> >>> On Dec 9, 2015, at 2:32 PM, Kevin Ballard via swift-dev <swift-dev@swift.org> wrote:
> >>>
> >>> Is there an easy way to build and install my own toolchain into /Library/Developer/Toolchains? I assume there must be some automated way to construct the package installer, but nothing immediately leaps out at me. It looks like build-script can create a root, but that seems to be for BNI, which isn't helpful.
> >>>
> >>> The reason for doing this here is I have a Vim plugin that lets me execute Swift scripts from vim buffers, and it supports using the swift from any given Xcode. I want to teach it how to find swift in /Library/Developer/Toolchains instead, which requires that I actually install a toolchain there (teaching it how to use the build folder from my swift checkout is doable, but that's not very portable).
> >>>
> >>> -Kevin Ballard
> >>> _______________________________________________
> >>> swift-dev mailing list
> >>> swift-dev@swift.org
> >>> https://lists.swift.org/mailman/listinfo/swift-dev
> >>
> > _______________________________________________
> > swift-dev mailing list
> > swift-dev@swift.org
> > https://lists.swift.org/mailman/listinfo/swift-dev
>