feat: lake: relative paths for Lean build messages (#8539)
This PR changes Lake to use relative path for the Lean messages produced by a module build. This makes the message portable across different machines, which is useful for Mathlib's cache.
This commit is contained in:
parent
b7ec369863
commit
e68c6a38fb
3 changed files with 10 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ prelude
|
|||
import Lake.Config.Dynlib
|
||||
import Lake.Util.Proc
|
||||
import Lake.Util.NativeLib
|
||||
import Lake.Util.FilePath
|
||||
import Lake.Util.IO
|
||||
|
||||
/-! # Common Build Actions
|
||||
|
|
@ -19,7 +20,7 @@ open Lean hiding SearchPath
|
|||
namespace Lake
|
||||
|
||||
def compileLeanModule
|
||||
(leanFile : FilePath)
|
||||
(leanFile relLeanFile : FilePath)
|
||||
(oleanFile? ileanFile? cFile? bcFile?: Option FilePath)
|
||||
(leanPath : SearchPath := []) (rootDir : FilePath := ".")
|
||||
(dynlibs plugins : Array Dynlib := #[])
|
||||
|
|
@ -57,6 +58,7 @@ def compileLeanModule
|
|||
if let .ok (msg : SerialMessage) := Json.parse ln >>= fromJson? then
|
||||
unless txt.isEmpty do
|
||||
logInfo s!"stdout:\n{txt}"
|
||||
let msg := {msg with fileName := mkRelPathString relLeanFile}
|
||||
logSerialMessage msg
|
||||
return txt
|
||||
else if txt.isEmpty && ln.isEmpty then
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ def Module.recBuildLean (mod : Module) : FetchM (Job Unit) := do
|
|||
addTrace srcTrace
|
||||
setTraceCaption s!"{mod.name.toString}:leanArts"
|
||||
let upToDate ← buildUnlessUpToDate? (oldTrace := srcTrace.mtime) mod (← getTrace) mod.traceFile do
|
||||
compileLeanModule mod.leanFile mod.oleanFile mod.ileanFile mod.cFile mod.bcFile?
|
||||
compileLeanModule mod.leanFile mod.relLeanFile mod.oleanFile mod.ileanFile mod.cFile mod.bcFile?
|
||||
(← getLeanPath) mod.rootDir dynlibs plugins
|
||||
(mod.weakLeanArgs ++ mod.leanArgs) (← getLean)
|
||||
mod.clearOutputHashes
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@ abbrev pkg (self : Module) : Package :=
|
|||
@[inline] def leanFile (self : Module) : FilePath :=
|
||||
self.srcPath "lean"
|
||||
|
||||
@[inline] def relLeanFile (self : Module) : FilePath :=
|
||||
if let some relPath := self.leanFile.toString.dropPrefix? self.pkg.dir.toString then
|
||||
FilePath.mk (relPath.drop 1).toString -- remove leading `/`
|
||||
else
|
||||
self.leanFile
|
||||
|
||||
@[inline] def leanLibPath (ext : String) (self : Module) : FilePath :=
|
||||
self.filePath self.pkg.leanLibDir ext
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue