Skip to content

Commit

Permalink
Include the juvix version in the build directory path (#3069)
Browse files Browse the repository at this point in the history
For example, by default the build directory would now be:

```
.juvix-build/0.6.6
```

It is necessary to separate the build files by compiler version because
the structure of jvo files may be incompatible between compiler
releases.

* Closes #3019
  • Loading branch information
paulcadman authored Sep 30, 2024
1 parent 625d5e0 commit 6e58aad
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Pipeline/Package/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ instance FromJSON RawPackage where

resolveBuildDir :: BuildDir -> SomeBase Dir
resolveBuildDir = \case
DefaultBuildDir -> Rel (relBuildDir)
DefaultBuildDir -> Rel relBuildDir
CustomBuildDir d -> d

resolveAbsBuildDir :: Path Abs Dir -> BuildDir -> Path Abs Dir
Expand Down
3 changes: 2 additions & 1 deletion src/Juvix/Extra/Paths/Base.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Juvix.Extra.Paths.Base where

import Data.FileEmbed qualified as FE
import Juvix.Extra.Version
import Juvix.Prelude.Base
import Juvix.Prelude.Path
import Language.Haskell.TH.Syntax
Expand Down Expand Up @@ -60,7 +61,7 @@ packageFilePath :: Path Rel File
packageFilePath = $(mkRelFile "Package.juvix")

relBuildDir :: Path Rel Dir
relBuildDir = $(mkRelDir ".juvix-build")
relBuildDir = $(mkRelDir ".juvix-build") <//> versionDir

relStdlibDir :: Path Rel Dir
relStdlibDir = $(mkRelDir "stdlib")
Expand Down
2 changes: 1 addition & 1 deletion tests/positive/Dependencies/.libs/Extra/Package.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ package : Package :=
defaultPackage@?{
name := "extra";
version := mkVersion 1 0 0;
dependencies := [path ".juvix-build/stdlib"; path "../Base"]
dependencies := [defaultStdlib; path "../Base"]
};
51 changes: 27 additions & 24 deletions tests/smoke/Commands/compile-dependencies-package-juvix.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -104,7 +104,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -172,7 +172,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -217,7 +217,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -277,7 +277,7 @@ tests:
defaultPackage@?{name := "Dep1";
version := mkVersion 0 1 0;
dependencies :=
[path ".juvix-build/stdlib/";
[defaultStdlib;
git "dep2" "$temp/dep2" "main"]};
EOF
Expand All @@ -300,32 +300,33 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib/";
[defaultStdlib;
git "dep1" "$temp/dep1" "main"];
main := just "HelloWorld.juvix"};
EOF
checksum=$(sha256sum Package.juvix | cut -d " " -f 1)
version=$(juvix --numeric-version)
cat <<-EOF > juvix.lock.yaml
version: 2
checksum: $checksum
dependencies:
- path: .juvix-build/stdlib/
- path: .juvix-build/$version/stdlib/
dependencies: []
- git:
url: $temp/dep1
ref: $dep1hash
name: dep1
dependencies:
- path: .juvix-build/stdlib/
- path: .juvix-build/$version/stdlib/
dependencies: []
- git:
url: $temp/dep2
ref: $dep2hash
name: dep2
dependencies:
- path: .juvix-build/stdlib/
- path: .juvix-build/$version/stdlib/
dependencies: []
EOF
Expand Down Expand Up @@ -414,7 +415,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "main"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -507,7 +508,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash1"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -538,7 +539,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash2"];
main := just "HelloWorld.juvix"};
EOF
Expand All @@ -561,6 +562,8 @@ tests:
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
version=$(juvix --numeric-version)
# create dependency2
mkdir $temp/dep2
cd $temp/dep2
Expand Down Expand Up @@ -611,20 +614,20 @@ tests:
defaultPackage@?{name := "Dep1";
version := mkVersion 0 1 0;
dependencies :=
[path ".juvix-build/stdlib/";
[defaultStdlib;
git "dep2" "$temp/dep2" "main"]};
EOF
cat <<-EOF > juvix.lock.yaml
dependencies:
- path: .juvix-build/stdlib/
- path: .juvix-build/$version/stdlib/
dependencies: []
- git:
url: $temp/dep2
ref: $dep2hash
name: dep2
dependencies:
- path: .juvix-build/stdlib/
- path: .juvix-build/$version/stdlib/
dependencies: []
EOF
Expand All @@ -647,7 +650,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib/";
[defaultStdlib;
git "dep1" "$temp/dep1" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -721,7 +724,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash1"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -757,7 +760,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash2"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -806,7 +809,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "invalid-ref"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -851,7 +854,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "main"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -896,7 +899,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "main"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -966,7 +969,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down Expand Up @@ -1017,7 +1020,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep1" "main";
git "dep1" "$temp/dep2" "main"];
main := just "HelloWorld.juvix"};
Expand Down Expand Up @@ -1080,7 +1083,7 @@ tests:
defaultPackage@?{name := "HelloWorld";
version := mkVersion 0 0 1;
dependencies :=
[path ".juvix-build/stdlib";
[defaultStdlib;
git "dep1" "$temp/dep" "$dep1hash"];
main := just "HelloWorld.juvix"};
EOF
Expand Down
Loading

0 comments on commit 6e58aad

Please sign in to comment.