The compiler inserts code that imports the exports of used packages.
It's important that we don't do this for the exports of used
debugOnly and prodOnly packages, because the inserted code will
fail at runtime if the packages are not linked in because we aren't
in dev mode or aren't in prod mode.
Fixes 3 issues:
- The error detection code in linker.fullLink was buggy.The goal of this
code was to convert an error from findAssignedGlobals into empty
linked output. But buildmessage.jobHasMessages() wasn't precise
enough; if a much larger job had any errors, linker.fullLink would
incorrectly return empty linked output here. (Worse, it got cached in
memory, so the incorrect result would recur on future links!) The fix
is to make the scope of the error detection more targeted.
- OK, now it's OK to cache error outputs from linker.fullLink, because
they're at least only occuring on real errors, right? Wrong... we
shouldn't cache the error return value without also caching the *error
itself*. In this case, we just change the cache to not cache erroneous
outputs at all (though we could have instead saved the error and
rethrown it if we got it again).
- When mutating the File to pretend it was empty, we should keep the
sourceHash up to date. (This doesn't seem to be directly causing any
bugs but can't hurt.)
Fixes#4591.
The exact borderline between "Isobuild" and "the tool" is a little hazy,
but the idea is that "Isobuild" is the part that you could imagine being
embedded in a non-command-line build tool. It's not about commands or
UI, but just about building packages and apps.
A next step could be moving things that are strictly "the command-line
tool" into their own subdir, and leaving the top directory mostly just
for shared utilities like buildmessage. (Which could even go in a utils
subdir?)