Skip to content
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

fix: lake: make package extraDep intransitive #5641

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading