artifact: add path/binary/isInstalled static helpers#1169
Conversation
Give zig, rust, go_win and go_xcaddy a small consistent surface for locating the install directory and a binary inside it: - path(): install/extract root for the artifact - binary($name = '<default>'): full path to a binary under that root, picking the artifact's natural layout (top-level for zig, bin/ for rust and the go toolchains) - isInstalled(): is the default binary present on disk Callers that previously concatenated PKG_ROOT_PATH . '/zig/zig' (and the equivalents for the other artifacts) by hand can call the helpers instead, and any later code that needs to ask "is this toolchain available" can use isInstalled() without rebuilding the path.
crazywhalecc
left a comment
There was a problem hiding this comment.
I'll leave this tomorrow. Look for a better way if possible.
I prefer setting them in config and using |
|
This is something where I don't really see an advantage to describing it in a config. The function definitions are at least as short as and more ergonomic to use. I'm not terribly concerned with it though, so if you want to change it, I don't object. |
I just thought that we should keep constant things in config, and dynamic things written in PHP functions. I don't see your parts containing dynamic codes so that I prefer defining in config. Also we could define dynamic things in another parts as you like. |
Give zig, rust, go_win and go_xcaddy a small consistent surface for locating the install directory and a binary inside it:
Callers that previously concatenated PKG_ROOT_PATH . '/zig/zig' (and the equivalents for the other artifacts) by hand can call the helpers instead, and any later code that needs to ask "is this toolchain available" can use isInstalled() without rebuilding the path.
What does this PR do?
Checklist before merging
*.phpor*.yml, run them locally to ensure your changes are valid:composer cs-fixcomposer analysecomposer testbin/spc dev:lint-config