swift-sh icon indicating copy to clipboard operation
swift-sh copied to clipboard

Expose an option that prints the cached build directory?

Open frypf opened this issue 3 years ago • 2 comments

I've been doing some swift scripting in VSCode rather than Xcode for a change and it would be really useful if there was some way of outputting the path of the build dir generated within ~/Library/Developer/swift-sh.cache. I had a quick look at Path+ResolvedHash.swift and hacked together a short script (obviously utilising the capabilities of swift-sh 😁) to access the generated md5 for a given file.

However, this involves a fair bit of overhead, as well as c. 138mb of generated data just to output a single piece of info that is already calculated internally within swift-sh. Would it be possible to add a --print-build-dir option (or similar) within swift-sh itself? Or maybe this info is already accessible and I've completely missed it!

Thanks for providing such a useful tool 🙏!

frypf avatar Sep 22 '22 10:09 frypf

sure, PR welcome

mxcl avatar Sep 22 '22 12:09 mxcl

Apologies for never coming back on this. I realised the other day that @wti had made some progress on it and trialled the above fork for a few days. The changes seemed to work for me, and I did find it useful being able to tell at a glance which script a particular cache folder relates to.

However, for my own limited use-case of running and manipulating swift-sh scripts from vscode, I've since discovered it seems possible to obtain the same byte-based md5 hash that swift-sh uses by using openssl: printf -- "${swift_file_path}" | openssl dgst -md5 Just thought I should put this up here in case anyone was searching for the same info. At least from my own point of view, being able to use existing shell functionality probably supersedes the need for an extra opt within swift-sh itself.

frypf avatar Feb 11 '23 10:02 frypf