@@ -204,13 +204,11 @@ function build_JuliaInterface()
204204
205205 jipath = joinpath (@__DIR__ , " .." , " pkg" , " JuliaInterface" )
206206 gaproot = gaproot_for_building ()
207- Pidfile. mkpidlock (" $jipath .lock" ; stale_age= 300 ) do
208- cd (jipath) do
209- withenv (" CFLAGS" => JULIA_CFLAGS,
210- " LDFLAGS" => JULIA_LDFLAGS * " " * JULIA_LIBS) do
211- run (pipeline (` ./configure $(gaproot) ` , stdout = " build.log" ))
212- run (pipeline (` make V=1 -j$(Sys. CPU_THREADS) ` , stdout = " build.log" , append= true ))
213- end
207+ cd (jipath) do
208+ withenv (" CFLAGS" => JULIA_CFLAGS,
209+ " LDFLAGS" => JULIA_LDFLAGS * " " * JULIA_LIBS) do
210+ run (pipeline (` ./configure $(gaproot) ` , stdout = " build.log" ))
211+ run (pipeline (` make V=1 -j$(Sys. CPU_THREADS) ` , stdout = " build.log" , append= true ))
214212 end
215213 end
216214
@@ -223,15 +221,39 @@ function locate_JuliaInterface_so()
223221 jll = GAP_pkg_juliainterface_jll. find_artifact_dir ()
224222 jll_hash = tree_hash (joinpath (jll, " src" ))
225223 bundled = joinpath (@__DIR__ , " .." , " pkg" , " JuliaInterface" )
226- bundled_hash = tree_hash (joinpath (bundled, " src" ))
227- if jll_hash == bundled_hash && get (ENV , " FORCE_JULIAINTERFACE_COMPILATION" , " false" ) != " true"
228- # if the tree hashes match then we can use JuliaInterface.so from the JLL
229- @debug " Use JuliaInterface.so from GAP_pkg_juliainterface_jll"
230- path = joinpath (jll, " lib" , " gap" )
231- else
232- # tree hashes differ: we must compile the bundled sources (or requested re-compilation via ENV)
224+ path = Pidfile. mkpidlock (" $bundled .lock" ; stale_age= 300 ) do
225+ bundled_hash = tree_hash (joinpath (bundled, " src" ))
226+
227+ # requested re-compilation via ENV -> re-compile
228+ if get (ENV , " FORCE_JULIAINTERFACE_COMPILATION" , " false" ) == " true"
229+ @debug " FORCE_JULIAINTERFACE_COMPILATION is set -> recompile JuliaInterface"
230+ path = build_JuliaInterface ()
231+ @debug " Use JuliaInterface.so from $(path) "
232+ return path
233+ end
234+
235+ # tree hashes of bundled C sources and GAP_pkg_juliainterface_jll match -> use JuliaInterface.so from the JLL
236+ if jll_hash == bundled_hash
237+ @debug " Use JuliaInterface.so from GAP_pkg_juliainterface_jll"
238+ return joinpath (jll, " lib" , " gap" )
239+ end
240+
241+ # tree hashes of bundled C sources and previously compiled version match -> use that
242+ prev_hash_file = normpath (joinpath (bundled, " bin" , GAP. sysinfo[" GAParch" ], " .src_tree_hash" ))
243+ if isfile (prev_hash_file)
244+ prev_hash = read (prev_hash_file)
245+ if prev_hash == bundled_hash
246+ path = dirname (prev_hash_file)
247+ @debug " Use previously compiled JuliaInterface.so from $(path) "
248+ return path
249+ end
250+ end
251+
252+ # fall-back case -> re-compile
233253 path = build_JuliaInterface ()
254+ write (joinpath (path, " .src_tree_hash" ), bundled_hash)
234255 @debug " Use JuliaInterface.so from $(path) "
256+ return path
235257 end
236258 return joinpath (path, " JuliaInterface.so" )
237259end
0 commit comments