Skip to content

Commit

Permalink
Rename project-file to cabalProject in hie.yaml
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 committed Jun 16, 2023
1 parent 3d4fadf commit 3c45b52
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
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
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
6 changes: 3 additions & 3 deletions src/HIE/Bios/Cradle.hs
Expand Up @@ -426,7 +426,7 @@ callableToProcess (Program path) file = do
------------------------------------------------------------------------

projectFileProcessArgs :: CradleProjectConfig -> [String]
projectFileProcessArgs (ExplicitConfig prjFile) = ["--project-file", prjFile]
projectFileProcessArgs (ExplicitConfig prjFile) = ["--cabalProject", prjFile]
projectFileProcessArgs NoExplicitConfig = []

projectLocationOrDefault :: CradleProjectConfig -> [FilePath]
Expand Down 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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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 3c45b52

Please sign in to comment.