[swift-build-dev] Proposal: dependency preheating

swizzlr me at swizzlr.co
Fri Jan 27 07:18:27 CST 2017


Sometimes it is desirable to run a sequence of commands and cache the output of those commands as a filesystem snapshot in CI. This is especially relevant to swift packages, where compilation times are relatively long, but the dependencies don’t change often.

In particular, Docker users will often do something like so (though this can be applied to Travis and other CI solutions).

FROM swift

WORKDIR /code

COPY Package.swift /code/
RUN swift build -c release # This fails because of point 2, below
# Changes to `Sources` will not trigger refetch or recompilation of dependencies
COPY ./Sources /code/Sources
RUN swift build -c release
EXPOSE 8000
CMD .build/release/App

Unfortunately, the above fails in certain scenarios:

1. `swift package fetch` will break if the target source layout doesn’t match. This bug is described in https://bugs.swift.org/browse/SR-3756 <https://bugs.swift.org/browse/SR-3756>
2. `swift build` will correctly fail if it cannot find sources matching the source layout described in Package.swift. This is a feature, not a bug.

I propose making this workflow easier with `swift package preheat` – a command which will fetch ONLY dependencies specified in Package.swift, and optionally (with the option —build) compile those dependencies, but not the main Package.

This would also be great for bootstrapping a project with a lot of dependencies, or with deps that have long compilation times.

This command should also support specifying a build configuration, so that we can cache both debug and release builds at the same time to accelerate development iteration.

Are there any comments, concerns, objections or +1s to this?

Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-build-dev/attachments/20170127/5277e061/attachment.html>


More information about the swift-build-dev mailing list