Skip to content

Commit

Permalink
Merge pull request #8 from lean-dojo/dev
Browse files Browse the repository at this point in the history
fix "build/ir" bug in ExtractData.lean
  • Loading branch information
Kaiyu Yang authored Jul 6, 2023
2 parents 2be4c2e + 9daed2c commit 6fce7fe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lean_dojo/data_extraction/ExtractData.lean
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private def trim (path : FilePath) : FilePath :=
| _ => path


def toBuildDir (subDir: String) (path : FilePath) (ext : String) : Option FilePath :=
def toBuildDir (subDir : String) (path : FilePath) (ext : String) : Option FilePath :=
let path' := (trim path).withExtension ext
match relativeTo path' "lake-packages/lean4/src" with
| some p => some $ "lake-packages/lean4/lib" / p
Expand Down Expand Up @@ -179,6 +179,12 @@ def toSrcDir (path : FilePath) (ext : String) : Option FilePath :=
| _ => "invalid path"


-- Create all parent directories of `p` if they don't exist.
def makeParentDirs (p : FilePath) : IO Unit := do
let some parent := p.parent | throw $ IO.userError s!"Unable to get the parent of {p}"
IO.FS.createDirAll parent


end Path


Expand Down Expand Up @@ -285,6 +291,7 @@ unsafe def processFile (path : FilePath) : IO Unit := do
else
(Path.toBuildDir "ir" relativePath "ast.json").get!
)
Path.makeParentDirs json_path
IO.FS.writeFile json_path (toJson trace).pretty

-- Print imports, similar to `lean --deps` in Lean 3.
Expand Down Expand Up @@ -313,6 +320,7 @@ unsafe def processFile (path : FilePath) : IO Unit := do
else
(Path.toBuildDir "ir" relativePath "dep_paths").get!
)
Path.makeParentDirs dep_path
IO.FS.writeFile dep_path s.trim


Expand Down

0 comments on commit 6fce7fe

Please sign in to comment.