Skip to content

Commit

Permalink
fix: lake: make package extraDep intransitive (#5641)
Browse files Browse the repository at this point in the history
A Lake build of target within a a package will no longer build a
package's dependencies package-level extra targets dependencies. At the
technical level, a package's `extraDep` facet no longer transitively
builds its dependencies' `extraDep` facet.

Closes #5633.

(cherry picked from commit 7942b9e)
  • Loading branch information
tydeu authored and github-actions[bot] committed Oct 19, 2024
1 parent 64b8127 commit d585f52
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/lake/Lake/Build/Package.lean
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,12 @@ def Package.maybeFetchBuildCacheWithWarning (self : Package) := do
def Package.fetchOptRelease := @maybeFetchBuildCacheWithWarning

/--
Build the `extraDepTargets` for the package and its transitive dependencies.
Also fetch pre-built releases for the package's' dependencies.
Build the `extraDepTargets` for the package.
Also, if the package is a dependency, maybe fetch its build cache.
-/
def Package.recBuildExtraDepTargets (self : Package) : FetchM (BuildJob Unit) :=
withRegisterJob s!"{self.name}:extraDep" do
let mut job := BuildJob.nil
-- Build dependencies' extra dep targets
for dep in self.deps do
job := job.mix <| ← dep.extraDep.fetch
-- Fetch build cache if this package is a dependency
if self.name ≠ (← getWorkspace).root.name then
job := job.add <| ← self.maybeFetchBuildCacheWithWarning
Expand Down
1 change: 1 addition & 0 deletions src/lake/tests/noRelease/Test.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Dep
Empty file.
2 changes: 2 additions & 0 deletions src/lake/tests/noRelease/dep/lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ package dep where
preferReleaseBuild := true
releaseRepo := "https://example.com"
buildArchive := "release.tgz"

lean_lib Dep
7 changes: 4 additions & 3 deletions src/lake/tests/noRelease/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ EOF

# Test that an indirect fetch on the release does not cause the build to fail
$LAKE build Test | diff -u --strip-trailing-cr <(cat << EOF
⚠ [2/5] Ran dep:extraDep
⚠ [3/6] Ran dep:extraDep
warning: building from source; failed to fetch GitHub release (run with '-v' for details)
✔ [4/5] Built Test
✔ [4/6] Built Dep
✔ [5/6] Built Test
Build completed successfully.
EOF
) -
Expand All @@ -56,7 +57,7 @@ mkdir -p .lake/packages/dep/.lake/build
$LAKE -d .lake/packages/dep pack 2>&1 | grep --color "packing"
test -f .lake/packages/dep/.lake/release.tgz
echo 4225503363911572621 > .lake/packages/dep/.lake/release.tgz.trace
rmdir .lake/packages/dep/.lake/build
rm -rf .lake/packages/dep/.lake/build
$LAKE build dep:release -v | grep --color "tar"
test -d .lake/packages/dep/.lake/build

Expand Down
3 changes: 3 additions & 0 deletions src/lake/tests/online/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $LAKE -v -f git.toml build @Cli:extraDep |

./clean.sh
$LAKE -f barrel.lean update
# Test that a barrel is not fetched for an unbuilt dependency
$LAKE -v -f barrel.lean build @test:extraDep |
grep --color "Cli:optBarrel" && exit 1 || true
# Test that barrels are not fetched after the build directory is created.
mkdir -p .lake/packages/Cli/.lake/build
($LAKE -v -f barrel.lean build @Cli:extraDep) |
Expand Down

0 comments on commit d585f52

Please sign in to comment.