Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribute a binary built with swiftpm for 0 dependencies #1395

Closed
keith opened this issue Mar 26, 2017 · 4 comments
Closed

Distribute a binary built with swiftpm for 0 dependencies #1395

keith opened this issue Mar 26, 2017 · 4 comments
Labels
enhancement Ideas for improvements of existing features and rules.

Comments

@keith
Copy link
Collaborator

keith commented Mar 26, 2017

I noticed that there is now a portable_swiftlint.zip with each new release. I'm wondering if, either along side or instead of this zip, it would make sense to distribute a binary built with swiftpm so that it could be entirely self contained. This would be nice for being able to easily use the single binary without having to worry at all about relative paths for the dependencies. Since swiftpm is already supported here, this would be pretty reasonable to do:

% swift build --configuration release -Xswiftc -static-stdlib
Compile CYaml src/writer.c
Compile CYaml src/reader.c
Compile CYaml src/scanner.c
Compile CYaml src/parser.c
Compile CYaml src/loader.c
Compile CYaml src/emitter.c
Compile CYaml src/dumper.c
Compile CYaml src/api.c
Compile Swift Module 'SwiftyTextTable' (1 sources)
Compile Swift Module 'Yaml' (6 sources)
Compile Swift Module 'SWXMLHash' (2 sources)
Compile Swift Module 'Result' (2 sources)
Linking CYaml
Compile Swift Module 'Yams' (2 sources)
Compile Swift Module 'Commandant' (9 sources)
Compile Swift Module 'SourceKittenFramework' (33 sources)
Compile Swift Module 'sourcekitten' (10 sources)
Compile Swift Module 'SwiftLintFramework' (147 sources)
Linking ./.build/release/sourcekitten
Compile Swift Module 'swiftlint' (10 sources)
Linking ./.build/release/swiftlint
% otool -L ./.build/release/swiftlint
./.build/release/swiftlint:
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1348.28.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1349.25.0)
        /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1070.13.0)
        /Users/ksmiley/dev/SwiftLint/.build/release/libCYaml.dylib (compatibility version 0.0.0, current version 0.0.0)
% du -sh ./.build/release/swiftlint
13M     ./.build/release/swiftlint

This binary could easily be dropped in to a CI machine, or a local machine, without having to worry about any dependency conflicts, or installations with sudo.

Thoughts?

@norio-nomura
Copy link
Collaborator

libCYaml.dylib is dynamically linked.
For statically linking that will need to use SE-0146: Package Manager Product Definitions.
We can not use that officially on Swift 3.1.

@keith
Copy link
Collaborator Author

keith commented Mar 26, 2017

Ah yes, sorry I missed that library in the output.

@keith
Copy link
Collaborator Author

keith commented Mar 29, 2017

This actually seems to "just work" with the current master builds of swiftpm. The only change that has to be made is upgrading sourcekitten to master for this fix

@norio-nomura
Copy link
Collaborator

Since #1951 has been merged to master, now brew install swiftlint --HEAD installs statically linked swiftlint:

$ brew install swiftlint --HEAD
==> Cloning https://github.com/realm/SwiftLint.git
Cloning into '/Users/norio/Library/Caches/Homebrew/swiftlint--git'...
remote: Counting objects: 364, done.
remote: Compressing objects: 100% (347/347), done.
remote: Total 364 (delta 63), reused 61 (delta 6), pack-reused 0
Receiving objects: 100% (364/364), 695.56 KiB | 953.00 KiB/s, done.
Resolving deltas: 100% (63/63), done.
==> Checking out branch master
==> make prefix_install PREFIX=/usr/local/Cellar/swiftlint/HEAD-9f3154e TEMPORARY_FOLDER=/private/tmp/swiftlint-20171121-97808-1j3adiq/SwiftLint.dst
🍺  /usr/local/Cellar/swiftlint/HEAD-9f3154e: 6 files, 15.4MB, built in 4 minutes 23 seconds
brew install swiftlint --HEAD  240.89s user 52.24s system 103% cpu 4:42.15 total
$ otool -L `which swiftlint`
/usr/local/bin/swiftlint:
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1445.12.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1443.14.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1125.3.4)
	/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 59.1.0)

@jpsim jpsim closed this as completed Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

4 participants