feat: lake: hoist compiled configurations (#13683)

This PR moves the compiled Lake configurations (e.g., `lakefile.olean`)
from the package's `.lake/config` directory to the workspace's
`.lake/config`. This removes a potential source contention between
workspaces sharing a dependency.
This commit is contained in:
Mac Malone 2026-05-08 14:00:37 -04:00 committed by GitHub
parent 819f4549d9
commit 41ecccec6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 2 deletions

View file

@ -78,3 +78,7 @@ namespace LoadConfig
/-- The package's Lake directory (for Lake temporary files). -/ /-- The package's Lake directory (for Lake temporary files). -/
@[inline] public def lakeDir (cfg : LoadConfig) : FilePath := @[inline] public def lakeDir (cfg : LoadConfig) : FilePath :=
cfg.pkgDir / defaultLakeDir cfg.pkgDir / defaultLakeDir
/-- The absolute path where compiled configurations are stored. -/
@[inline] public def configDir (cfg : LoadConfig) : FilePath :=
cfg.wsDir / defaultLakeDir / "config" / toString cfg.pkgIdx

View file

@ -180,8 +180,7 @@ toolchain). Otherwise, elaborate the configuration and save it to the `.olean`.
public def importConfigFile (cfg : LoadConfig) : LogIO Environment := do public def importConfigFile (cfg : LoadConfig) : LogIO Environment := do
let some configName := FilePath.mk <$> cfg.configFile.fileName let some configName := FilePath.mk <$> cfg.configFile.fileName
| error "invalid configuration file name" | error "invalid configuration file name"
let pkgName := cfg.pkgName.toString (escape := false) let configDir := cfg.configDir
let configDir := cfg.lakeDir / "config" / pkgName
IO.FS.createDirAll configDir IO.FS.createDirAll configDir
let olean := configDir / configName.withExtension "olean" let olean := configDir / configName.withExtension "olean"
let traceFile := configDir / configName.withExtension "olean.trace" let traceFile := configDir / configName.withExtension "olean.trace"

View file

@ -16,6 +16,19 @@ $LAKE -d foo build --update
./foo/.lake/build/bin/foo ./foo/.lake/build/bin/foo
./bar/.lake/build/bin/bar ./bar/.lake/build/bin/bar
# Test compiled configurations are hoisted
test -d foo/.lake/config/0
test -d foo/.lake/config/1
test -d foo/.lake/config/2
test -d foo/.lake/config/3
test ! -d foo/.lake/config/4
test -d bar/.lake/config/0
test -d bar/.lake/config/1
test -d bar/.lake/config/2
test -d bar/.lake/config/3
test -d bar/.lake/config/4
test ! -d bar/.lake/config/5
# Test setup-file works (i.e., does not error) # Test setup-file works (i.e., does not error)
$LAKE -d foo setup-file ./foo/Foo.lean $LAKE -d foo setup-file ./foo/Foo.lean
@ -39,3 +52,17 @@ $LAKE -d foo -f lakefile.toml build --update
./foo/.lake/build/bin/foo ./foo/.lake/build/bin/foo
./bar/.lake/build/bin/bar ./bar/.lake/build/bin/bar
# Test compiled configurations are hoisted
# and that the TOML configuration produces none
test ! -d foo/.lake/config/0
test -d foo/.lake/config/1
test -d foo/.lake/config/2
test -d foo/.lake/config/3
test ! -d foo/.lake/config/4
test ! -d bar/.lake/config/0
test -d bar/.lake/config/1
test -d bar/.lake/config/2
test -d bar/.lake/config/3
test -d bar/.lake/config/4
test ! -d bar/.lake/config/5