Skip to content

Commit

Permalink
Rename project-file to cabalProject in hie.yaml (#407)
Browse files Browse the repository at this point in the history
This is consistent with the name 'stackYaml' for stack cradles.
Unfortunate naming, but consistency beats the potential generalisation.
  • Loading branch information
fendor authored Jun 18, 2023
1 parent 361c6f5 commit 78d0cd2
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,21 @@ cradle:
This way we specified which component needs to be compiled given a certain source file for our whole project.

Some projects have multiple `cabal.project` files for multiple versions of ghc or development options. In this case you
can specify an alternate relative file to use by using the `project-file` option. The path is relative to the
can specify an alternate relative file to use by using the `cabalProject` option. The path is relative to the
`hie.yaml`.

```yaml
cradle:
cabal:
project-file: "./cabal.project.dev"
cabalProject: "./cabal.project.dev"
```

We can combine the `project-file` field with `components`:
We can combine the `cabalProject` field with `components`:

```yaml
cradle:
cabal:
project-file: "./cabal.project.dev"
cabalProject: "./cabal.project.dev"
components:
- path: "./src"
component: "lib:hie-bios"
Expand Down
8 changes: 4 additions & 4 deletions src/HIE/Bios/Config/YAML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ data CabalConfig

instance FromJSON CabalConfig where
parseJSON v@(Array _) = CabalConfig Nothing . ManyComponents <$> parseJSON v
parseJSON v@(Object obj) = (checkObjectKeys ["project-file", "component", "components"] obj)
parseJSON v@(Object obj) = (checkObjectKeys ["cabalProject", "component", "components"] obj)
*> (CabalConfig
<$> obj .:? "project-file"
<$> obj .:? "cabalProject"
<*> parseJSON v)
parseJSON Null = pure $ CabalConfig Nothing NoComponent
parseJSON v = typeMismatch "CabalConfig" v
Expand All @@ -123,11 +123,11 @@ data CabalComponent

instance FromJSON CabalComponent where
parseJSON =
let parseCabalComponent obj = checkObjectKeys ["path", "component", "project-file"] obj
let parseCabalComponent obj = checkObjectKeys ["path", "component", "cabalProject"] obj
*> (CabalComponent
<$> obj .: "path"
<*> obj .: "component"
<*> obj .:? "project-file"
<*> obj .:? "cabalProject"
)
in withObject "CabalComponent" parseCabalComponent

Expand Down
4 changes: 2 additions & 2 deletions src/HIE/Bios/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -853,11 +853,11 @@ stackAction workDir mc syaml l _fp = do
-- Same wrapper works as with cabal
wrapper_fp <- withGhcWrapperTool l ghcProcArgs workDir
(ex1, _stdo, stde, [(_, maybeArgs)]) <-
readProcessWithOutputs [hie_bios_output] l workDir
readProcessWithOutputs [hie_bios_output] l workDir
$ stackProcess syaml
$ ["repl", "--no-nix-pure", "--with-ghc", wrapper_fp]
<> [ comp | Just comp <- [mc] ]

(ex2, pkg_args, stdr, _) <-
readProcessWithOutputs [hie_bios_output] l workDir
$ stackProcess syaml ["path", "--ghc-package-path"]
Expand Down
2 changes: 1 addition & 1 deletion tests/BiosTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ cabalTestCases extraGhcDep =
loadRuntimeGhcVersion
assertGhcVersionIs extraGhcVersion
]
, testGroup "Cabal project-file"
, testGroup "Cabal cabalProject"
[ testCaseSteps "cabal-with-project, options propagated" $ runTestEnv "cabal-with-project" $ do
opts <- cabalLoadOptions "src/MyLib.hs"
liftIO $ do
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/cabal-with-both.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cradle:
cabal:
project-file: "cabal.project.8.10.7"
cabalProject: "cabal.project.8.10.7"
component: "hie-bios:hie"
2 changes: 1 addition & 1 deletion tests/configs/cabal-with-project.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cradle:
cabal:
project-file: "cabal.project.8.10.7"
cabalProject: "cabal.project.8.10.7"
2 changes: 1 addition & 1 deletion tests/configs/multi-cabal-with-project.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cradle:
cabal:
project-file: "cabal.project.8.10.7"
cabalProject: "cabal.project.8.10.7"
components:
- path: "./src"
component: "lib:hie-bios"
Expand Down
2 changes: 1 addition & 1 deletion tests/projects/cabal-with-ghc-and-project/hie.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cradle:
cabal:
project-file: cabal.project.8.10.7
cabalProject: cabal.project.8.10.7
2 changes: 1 addition & 1 deletion tests/projects/cabal-with-project/hie.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cradle:
cabal:
project-file: cabal.project.8.10.7
cabalProject: cabal.project.8.10.7
4 changes: 2 additions & 2 deletions tests/projects/multi-cabal-with-project/hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ cradle:
cabal:
- path: appA/src
component: appA:lib
project-file: cabal.project.8.10.7
cabalProject: cabal.project.8.10.7
- path: "appB"
config:
cradle:
cabal:
- path: appB/src
component: appB:lib
project-file: cabal.project.8.10.7
cabalProject: cabal.project.8.10.7

0 comments on commit 78d0cd2

Please sign in to comment.