Xcode.prefix and Xcode.installed? use slightly different heuristics to
find Xcode. In fact, .installed? basically duplicates a portion of the
.prefix logic. In practice, the methods results are usually consistent,
but .installed? does not handle non-standard prefixes if mdfind cannot
locate Xcode (for example, if the user has disabled Spotlight indexing).
Since .installed? is essentially a subset of the .prefix logic, we can
rely on the result from .prefix instead.
FixesHomebrew/homebrew#16790.
We support three configurations: Xcode-only, CLT-only, and Xcode with
CLT. Our configuration output should correctly reflect this.
While MacOS::Xcode.version has to continue to return a guess if Xcode is
not installed in order to maintain backwards compatibility, this is an
implementation detail that we don't need to expose to the user. And it
makes `brew --config` output confusing.
So let's only print the "Xcode" line when an actual Xcode installation
is present. This makes it easy to quickly figure out which of the three
possible configurations the user is running.
Addresses Homebrew/homebrew#14941, more or less.
Now we should get an sdk_path, but tools like xcodebuild, xcode-select and xcrun will still error out. But at least more of Homebrew will work.
Also putting the Xcode 3 path finder last. We get bug reports because newer Xcodes are installed in parallel to older Xcodes. We want to find and use the newer Xcode's first. Xcode.prefix is pretty smart about that.
Refs Homebrew/homebrew#14558.
I managed to remove a return while fixing this yesterday. The whitespace changes made the diff unreadable so I missed this regression.
Why does this sort of thing still happen?
The short-circuit returns would cause the caching ||= syntax to be skipped. For me on my CLT-less install, this was noticeably slowing down brew for some operations due to the frequent calls to xcodebuild.
In order to better support Xcode-only systems, where X11 libs and
executables live under /usr/X11 but headers live in the SDK, move the
x11_* helper methods into a new module.
This allows us to keep some of the CLT/Xcode-only and Apple X11/XQuartz
logic hidden from outside code, like ENV.x11.
Since Apple's X11 is actually XQuartz, name the module "MacOS::XQuartz".