Skip to content

Commit

Permalink
Merge branch 'develop-build-tool-depends' into develop. Close #149.
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
ivanperez-keera committed Feb 2, 2025
2 parents fa68616 + ede7dda commit 1b5f86e
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- name: Install dependencies
run: |
cabal v1-install alex happy
cabal v1-install BNFC
- name: Install ogma
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/repo-ghc-8.6-cabal-2.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- name: Install dependencies
run: |
cabal v1-install alex happy
cabal v1-install BNFC
- name: Install ogma
run: |
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
*/
1 change: 1 addition & 0 deletions ogma-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

## [1.6.0] - 2025-01-21

Expand Down
12 changes: 6 additions & 6 deletions ogma-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ Once GHC and cabal are installed, the simplest way to install Ogma is with:
```sh
$ git clone https://github.com/nasa/ogma.git
$ cd ogma
$ export PATH="$HOME/.cabal/bin/:$PATH"
$ cabal v1-update
$ cabal v1-install alex happy
$ cabal v1-install BNFC copilot
$ cabal v1-install ogma-*/
$ export PATH="$HOME/.local/bin/:$PATH"
$ cabal update
$ cabal install --lib copilot copilot-c99 copilot-language copilot-theorem \
copilot-libraries copilot-interpreter
$ cabal install ogma-cli:ogma
```

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

# Usage
<sup>[(Back to top)](#table-of-contents)</sup>
Expand Down
1 change: 1 addition & 0 deletions ogma-language-c/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [1.X.Y] - 2025-02-01
* Bump upper version constraint on Cabal (#213).
* Remove extraneous EOL character (#224).
* Specify tools needed using build-tool-depends (#149).

## [1.6.0] - 2025-01-21

Expand Down
7 changes: 5 additions & 2 deletions ogma-language-c/ogma-language-c.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

cabal-version: 2.0
build-type: Custom

name: ogma-language-c
version: 1.6.0
homepage: https://github.com/nasa/ogma
Expand Down Expand Up @@ -72,7 +71,6 @@ custom-setup
base >= 4.11.0.0 && < 5
, Cabal >= 2.0 && < 3.15
, process >= 1.6 && < 1.7
, BNFC >= 2.9.1 && < 2.10

library

Expand All @@ -93,6 +91,11 @@ library
base >= 4.11.0.0 && < 5
, array >= 0.5.2.0 && < 0.6

build-tool-depends:
alex:alex >= 3
, BNFC:bnfc >= 2.9.4
, happy:happy >= 1.19

hs-source-dirs:
src

Expand Down
1 change: 1 addition & 0 deletions ogma-language-cocospec/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Remove references to old design of Ogma from documentation (#220).
* Bump upper version constraint on Cabal (#213).
* Remove extraneous EOL character (#224).
* Specify tools needed using build-tool-depends (#149).

## [1.6.0] - 2025-01-21

Expand Down
7 changes: 5 additions & 2 deletions ogma-language-cocospec/ogma-language-cocospec.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

cabal-version: 2.0
build-type: Custom

name: ogma-language-cocospec
version: 1.6.0
homepage: https://github.com/nasa/ogma
Expand Down Expand Up @@ -72,7 +71,6 @@ custom-setup
base >= 4.11.0.0 && < 5
, Cabal >= 2.0 && < 3.15
, process >= 1.6 && < 1.7
, BNFC >= 2.9.1 && < 2.10

library

Expand All @@ -93,6 +91,11 @@ library
base >= 4.11.0.0 && < 5
, array >= 0.5.2.0 && < 0.6

build-tool-depends:
alex:alex >= 3
, BNFC:bnfc >= 2.9.4
, happy:happy >= 1.19

hs-source-dirs:
src

Expand Down
1 change: 1 addition & 0 deletions ogma-language-smv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Remove references to old design of Ogma from documentation (#220).
* Bump upper version constraint on Cabal (#213).
* Remove extraneous EOL character (#224).
* Specify tools needed using build-tool-depends (#149).

## [1.6.0] - 2025-01-21

Expand Down
7 changes: 5 additions & 2 deletions ogma-language-smv/ogma-language-smv.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

cabal-version: 2.0
build-type: Custom

name: ogma-language-smv
version: 1.6.0
homepage: https://github.com/nasa/ogma
Expand Down Expand Up @@ -72,7 +71,6 @@ custom-setup
base >= 4.11.0.0 && < 5
, Cabal >= 2.0 && < 3.15
, process >= 1.6 && < 1.7
, BNFC >= 2.9.1 && < 2.10

library

Expand All @@ -94,6 +92,11 @@ library
base >= 4.11.0.0 && < 5
, array >= 0.5.2.0 && < 0.6

build-tool-depends:
alex:alex >= 3
, BNFC:bnfc >= 2.9.4
, happy:happy >= 1.19

hs-source-dirs:
src

Expand Down

0 comments on commit 1b5f86e

Please sign in to comment.