Commit 4bd9297
authored
[build] Don't use ls(1) to find JDK paths (#314)
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!
Update the `<JdkInfo/>` task so that in addition to probing a variety
of Windows-specific registry locations, it can now do `jdk.mk`-style
directory probing, allowing us to find the maximum installed JDK
version which is (optionally) less than `$(JI_MAX_JDK)`.
Additionally, further enhance `<JdkInfo/>` so that it will *also*
check `$JAVA_HOME` and execute the following command:
java -XshowSettings:properties -version 2>&1 | grep java.home
`$JAVA_HOME` is preferred, if specified and it fulfills the
requirements of `$(JI_MAX_JDK)`.
Additionally, drastically simplify `jdk.mk`. Instead of computing the
desired JDK directory *on every build*, instead generate a new
`bin/Build$(CONFIGURATION)/JdkInfo.mk` file which contains the JDK
informatino. The `make prepare` target will generate this file.
This approach simplifes `jdk.mk` -- trying to maintain it was
beginning to give me a headache, so as part of this we're dropping
support for 32-bit JVMs on macOS, as if anyone uses those -- and also
brings the macOS/Linux build closer-in-spirit to Windows, which was
already using the `<JdkInfo/>` task.1 parent 0418d22 commit 4bd9297
File tree
7 files changed
+305
-206
lines changed- build-tools/scripts
- src/Java.Interop.BootstrapTasks
- Java.Interop.BootstrapTasks
7 files changed
+305
-206
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| |||
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
68 | | - | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | | - | |
| 30 | + | |
33 | 31 | | |
| 32 | + | |
34 | 33 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 34 | + | |
44 | 35 | | |
45 | 36 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 37 | + | |
| 38 | + | |
114 | 39 | | |
115 | 40 | | |
| 41 | + | |
| 42 | + | |
116 | 43 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | | - | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
0 commit comments