-
Notifications
You must be signed in to change notification settings - Fork 60
Cache project config on demand #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
04b940b
9f4cb47
850ab05
ea2c9c1
cdb85f7
33b47fc
856a5da
dac8ae6
1561e59
ab59b54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,23 @@ let main () = | |
path line col | ||
in | ||
match args with | ||
| [_; "cache-project"; rootPath] -> ( | ||
Cfg.useProjectConfigCache := false; | ||
let uri = Uri.fromPath rootPath in | ||
match Packages.getPackage ~uri with | ||
| Some package -> Cache.cacheProject package | ||
| None -> print_endline "\"ERR\"") | ||
| [_; "cache-delete"; rootPath] -> ( | ||
Cfg.useProjectConfigCache := false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem to be used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I meant to say the line |
||
let uri = Uri.fromPath rootPath in | ||
match Packages.findRoot ~uri (Hashtbl.create 0) with | ||
| Some (`Bs rootPath) -> ( | ||
match BuildSystem.getLibBs rootPath with | ||
| None -> print_endline "\"ERR\"" | ||
| Some libBs -> | ||
Cache.deleteCache (Cache.targetFileFromLibBs libBs); | ||
print_endline "\"OK\"") | ||
| _ -> print_endline "\"ERR: Did not find root \"") | ||
| [_; "completion"; path; line; col; currentFile] -> | ||
printHeaderInfo path line col; | ||
Commands.completion ~debug ~path | ||
|
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.useProjectConfigCache && 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\"" |
Uh oh!
There was an error while loading. Please reload this page.