@@ -2,7 +2,7 @@ module Precompilation
22
33using Base: PkgId, UUID, SHA1, parsed_toml, project_file_name_uuid, project_names,
44 project_file_manifest_path, get_deps, preferences_names, isaccessibledir, isfile_casesensitive,
5- base_project
5+ base_project, isdefined
66
77# This is currently only used for pkgprecompile but the plan is to use this in code loading in the future
88# see the `kc/codeloading2.0` branch
@@ -1031,14 +1031,16 @@ end
10311031
10321032# Can be merged with `maybe_cachefile_lock` in loading?
10331033function precompile_pkgs_maybe_cachefile_lock (f, io:: IO , print_lock:: ReentrantLock , fancyprint:: Bool , pkg_config, pkgspidlocked, hascolor)
1034+ if ! (isdefined (Base, :mkpidlock_hook ) && isdefined (Base, :trymkpidlock_hook ) && Base. isdefined (Base, :parse_pidfile_hook ))
1035+ return f ()
1036+ end
10341037 pkg, config = pkg_config
10351038 flags, cacheflags = config
1036- FileWatching = Base. loaded_modules[Base. PkgId (Base. UUID (" 7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" ), " FileWatching" )]
10371039 stale_age = Base. compilecache_pidlock_stale_age
10381040 pidfile = Base. compilecache_pidfile_path (pkg, flags= cacheflags)
1039- cachefile = FileWatching . trymkpidlock (f, pidfile; stale_age)
1041+ cachefile = @invokelatest Base . trymkpidlock_hook (f, pidfile; stale_age)
10401042 if cachefile === false
1041- pid, hostname, age = FileWatching . Pidfile . parse_pidfile (pidfile)
1043+ pid, hostname, age = @invokelatest Base . parse_pidfile_hook (pidfile)
10421044 pkgspidlocked[pkg_config] = if isempty (hostname) || hostname == gethostname ()
10431045 if pid == getpid ()
10441046 " an async task in this process (pidfile: $pidfile )"
@@ -1052,15 +1054,16 @@ function precompile_pkgs_maybe_cachefile_lock(f, io::IO, print_lock::ReentrantLo
10521054 println (io, " " , pkg. name, _color_string (" Being precompiled by $(pkgspidlocked[pkg_config]) " , Base. info_color (), hascolor))
10531055 end
10541056 # wait until the lock is available
1055- FileWatching. mkpidlock (pidfile; stale_age) do
1056- # double-check in case the other process crashed or the lock expired
1057- if Base. isprecompiled (pkg; ignore_loaded= true , flags= cacheflags) # don't use caches for this as the env state will have changed
1058- return nothing # returning nothing indicates a process waited for another
1059- else
1060- delete! (pkgspidlocked, pkg_config)
1061- return f () # precompile
1062- end
1063- end
1057+ @invokelatest Base. mkpidlock_hook (() -> begin
1058+ # double-check in case the other process crashed or the lock expired
1059+ if Base. isprecompiled (pkg; ignore_loaded= true , flags= cacheflags) # don't use caches for this as the env state will have changed
1060+ return nothing # returning nothing indicates a process waited for another
1061+ else
1062+ delete! (pkgspidlocked, pkg_config)
1063+ return f () # precompile
1064+ end
1065+ end ,
1066+ pidfile; stale_age)
10641067 end
10651068 return cachefile
10661069end
0 commit comments