You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes: dotnet/android#1493
On some machines, `make prepare` fails:
build-tools/scripts/jdk.mk:130: *** missing separator. Stop.
make: *** [prepare-external] Error 2
Eventually, we "found" the "cause": This make fragment:
$(shell ls -dtr $(_DARWIN_JDK_FALLBACK_DIRS) | sort | tail -1)
was dying a terrible horrible no good death:
_DARWIN_JDK_ROOT=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkin/sh: 49m: command not found
[Turns Out™][0], **ls**(1) should be *avoided*, as its output is
*unsafe* (I'm not sure *why*, and I'm not able to repro the above
failure on my machine, but it's *clearly* bad).
[0]: http://mywiki.wooledge.org/ParsingLs
Why are we using **ls**(1)? To sort by timestamp, via `ls -dtr`.
What's the recommended replacement?
> If you truly need a list of all the files in a directory in order
> by mtime so that you can process them in sequence, switch to perl,
> and have your perl program do its own directory opening and sorting
LOL?
Which brings us to the solution: we don't want to use Perl -- we
*want* something plausibly cross-platform -- so let's use our existing
cross-platform dependency: MSBuild!
Add a new `<JdkDirectoryFinder/>` task, to which we provide a
"JDKs Root" directory -- the directory which contains JDKs -- and the
`<JdkDirectoryFinder/>` task will open that directory, sort the
contents, skip the "out of version range" JDK versions
(`$(JI_JDK_MAX); commit 55c56f7), and return the "best" JDK root
directory from those available.
0 commit comments