Skip to content

Commit 1b5f86e

Browse files
Merge branch 'develop-build-tool-depends' into develop. Close #149.
**Description** The Cabal packages in Ogma were written for an older version of Cabal. Currently, they only state a dependency on BNFC as part of a `custom-setup` section. However, this is sub-ideal because `alex` and `happy` are also needed, and Cabal fails to detect that requirement, and also fails to install BNFC and make it available before it tries to compile Ogma. This makes the installation instructions overly complicated (all three of those packages need to be installed by hand first), and makes Hackage report that Ogma as a whole cannot be built, resulting in the following message in the build log: ``` /bin/sh: 1: bnfc: not found ``` **Type** - Management: Update Cabal packages to specify tool dependencies in a way that makes Cabal install them automatically. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** Not applicable (not a bug). **Expected result** Ogma can be installed from command-line without having to manually specify that `alex`, `happy` or `bnfc` need to be installed first. The following dockerfile checks that it is possible to install Ogma using a simple cabal install command without having to first install `alex`, `happy` or `bnfc`, after which it prints the message "Success": ``` FROM ubuntu:focal ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install --yes \ curl g++ gcc git libgmp3-dev libz-dev make pkg-config RUN mkdir -p $HOME/.local/bin ENV PATH=$PATH:/root/.local/bin/ RUN curl https://downloads.haskell.org/~ghcup/0.1.17.7/x86_64-linux-ghcup-0.1.17.7 -o $HOME/.local/bin/ghcup RUN chmod a+x $HOME/.local/bin/ghcup ENV PATH=$PATH:/root/.ghcup/bin/ RUN ghcup install ghc 9.10 RUN ghcup install cabal 3.12 RUN ghcup set ghc 9.10.1 RUN cabal update SHELL ["/bin/bash", "-c"] CMD git clone $REPO \ && cd $NAME \ && git checkout $COMMIT \ && cabal install ogma-cli:ogma \ && echo "Success" ``` Command (substitute variables based on new path after merge): ```sh $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e "COMMIT=<HASH>" -it ogma-verify-149 ``` **Solution implemented** Modify Cabal packages to add `BNFC:bnfc`, `alex:alex` and `happy:happy` in the `build-tool-depends` in the libraries that use it. Adjust Github Actions workflows to install bnfc manually, as installation with v1-install now requires this extra step. Adjust README to reflect new installation instructions, without having to install BNFC manually. Add a cabal.project file at the top level, which is needed by new versions of Cabal. **Further notes** None.
2 parents fa68616 + ede7dda commit 1b5f86e

File tree

11 files changed

+29
-12
lines changed

11 files changed

+29
-12
lines changed

.github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- name: Install dependencies
4141
run: |
4242
cabal v1-install alex happy
43+
cabal v1-install BNFC
4344
4445
- name: Install ogma
4546
run: |

.github/workflows/repo-ghc-8.6-cabal-2.4.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- name: Install dependencies
4141
run: |
4242
cabal v1-install alex happy
43+
cabal v1-install BNFC
4344
4445
- name: Install ogma
4546
run: |

cabal.project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
*/

ogma-cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Add all auxiliary test files to distributable Cabal package (#216).
66
* Remove extraneous EOL character (#224).
7+
* Update installation instructions to use cabal install (#149).
78

89
## [1.6.0] - 2025-01-21
910

ogma-cli/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ Once GHC and cabal are installed, the simplest way to install Ogma is with:
8383
```sh
8484
$ git clone https://github.com/nasa/ogma.git
8585
$ cd ogma
86-
$ export PATH="$HOME/.cabal/bin/:$PATH"
87-
$ cabal v1-update
88-
$ cabal v1-install alex happy
89-
$ cabal v1-install BNFC copilot
90-
$ cabal v1-install ogma-*/
86+
$ export PATH="$HOME/.local/bin/:$PATH"
87+
$ cabal update
88+
$ cabal install --lib copilot copilot-c99 copilot-language copilot-theorem \
89+
copilot-libraries copilot-interpreter
90+
$ cabal install ogma-cli:ogma
9191
```
9292

9393
After that, the `ogma` executable will be placed in the directory
94-
`$HOME/.cabal/bin/`, where `$HOME` represents your user's home directory.
94+
`$HOME/.local/bin/`, where `$HOME` represents your user's home directory.
9595

9696
# Usage
9797
<sup>[(Back to top)](#table-of-contents)</sup>

ogma-language-c/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [1.X.Y] - 2025-02-01
44
* Bump upper version constraint on Cabal (#213).
55
* Remove extraneous EOL character (#224).
6+
* Specify tools needed using build-tool-depends (#149).
67

78
## [1.6.0] - 2025-01-21
89

ogma-language-c/ogma-language-c.cabal

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
cabal-version: 2.0
3232
build-type: Custom
33-
3433
name: ogma-language-c
3534
version: 1.6.0
3635
homepage: https://github.com/nasa/ogma
@@ -72,7 +71,6 @@ custom-setup
7271
base >= 4.11.0.0 && < 5
7372
, Cabal >= 2.0 && < 3.15
7473
, process >= 1.6 && < 1.7
75-
, BNFC >= 2.9.1 && < 2.10
7674

7775
library
7876

@@ -93,6 +91,11 @@ library
9391
base >= 4.11.0.0 && < 5
9492
, array >= 0.5.2.0 && < 0.6
9593

94+
build-tool-depends:
95+
alex:alex >= 3
96+
, BNFC:bnfc >= 2.9.4
97+
, happy:happy >= 1.19
98+
9699
hs-source-dirs:
97100
src
98101

ogma-language-cocospec/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Remove references to old design of Ogma from documentation (#220).
66
* Bump upper version constraint on Cabal (#213).
77
* Remove extraneous EOL character (#224).
8+
* Specify tools needed using build-tool-depends (#149).
89

910
## [1.6.0] - 2025-01-21
1011

ogma-language-cocospec/ogma-language-cocospec.cabal

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
cabal-version: 2.0
3232
build-type: Custom
33-
3433
name: ogma-language-cocospec
3534
version: 1.6.0
3635
homepage: https://github.com/nasa/ogma
@@ -72,7 +71,6 @@ custom-setup
7271
base >= 4.11.0.0 && < 5
7372
, Cabal >= 2.0 && < 3.15
7473
, process >= 1.6 && < 1.7
75-
, BNFC >= 2.9.1 && < 2.10
7674

7775
library
7876

@@ -93,6 +91,11 @@ library
9391
base >= 4.11.0.0 && < 5
9492
, array >= 0.5.2.0 && < 0.6
9593

94+
build-tool-depends:
95+
alex:alex >= 3
96+
, BNFC:bnfc >= 2.9.4
97+
, happy:happy >= 1.19
98+
9699
hs-source-dirs:
97100
src
98101

ogma-language-smv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Remove references to old design of Ogma from documentation (#220).
66
* Bump upper version constraint on Cabal (#213).
77
* Remove extraneous EOL character (#224).
8+
* Specify tools needed using build-tool-depends (#149).
89

910
## [1.6.0] - 2025-01-21
1011

0 commit comments

Comments
 (0)