forked from rescript-lang/rescript-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache project config on demand (rescript-lang#1000)
* cache project config on demand * e2e for the new cache mode * only look up project files etc when needed * comment * Revert "only look up project files etc when needed" This reverts commit bc71f76. * remove now irrelevant comment * changelog * conditionally * rename * replace instead of add
- Loading branch information
Showing
11 changed files
with
307 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
open SharedTypes | ||
|
||
type cached = { | ||
projectFiles: FileSet.t; | ||
dependenciesFiles: FileSet.t; | ||
pathsForModule: (file, paths) Hashtbl.t; | ||
} | ||
|
||
let writeCache filename (data : cached) = | ||
let oc = open_out_bin filename in | ||
Marshal.to_channel oc data []; | ||
close_out oc | ||
|
||
let readCache filename = | ||
if !Cfg.readProjectConfigCache && Sys.file_exists filename then | ||
try | ||
let ic = open_in_bin filename in | ||
let data : cached = Marshal.from_channel ic in | ||
close_in ic; | ||
Some data | ||
with _ -> None | ||
else None | ||
|
||
let deleteCache filename = try Sys.remove filename with _ -> () | ||
|
||
let targetFileFromLibBs libBs = Filename.concat libBs ".project-files-cache" | ||
|
||
let cacheProject (package : package) = | ||
let cached = | ||
{ | ||
projectFiles = package.projectFiles; | ||
dependenciesFiles = package.dependenciesFiles; | ||
pathsForModule = package.pathsForModule; | ||
} | ||
in | ||
match BuildSystem.getLibBs package.rootPath with | ||
| None -> print_endline "\"ERR\"" | ||
| Some libBs -> | ||
let targetFile = targetFileFromLibBs libBs in | ||
writeCache targetFile cached; | ||
print_endline "\"OK\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.