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

Expose an option that prints the cached build directory? #180

Open
frypf opened this issue Sep 22, 2022 · 2 comments
Open

Expose an option that prints the cached build directory? #180

frypf opened this issue Sep 22, 2022 · 2 comments

Comments

@frypf
Copy link

frypf commented Sep 22, 2022

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 🙏!

@mxcl
Copy link
Owner

mxcl commented Sep 22, 2022

sure, PR welcome

wti added a commit to wti/swift-sh that referenced this issue Dec 9, 2022
…cl#180

This change affects users who manage the hashed path directly,
but it should make it easier for them to find script executables.

This updates clean(), which also reads the script build directory.
The unit test only checks mode parsing. Tested clean and show manually.

It's likely --show-script-cache is sufficient on its own,
and changing the directory name might affect users needlessly.

On my machine, scripts now fail to terminate (IO stalling?).
@frypf
Copy link
Author

frypf commented Feb 11, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants