Skip to content

Commit 581ba68

Browse files
Merge branch 'develop-copilot-3.19' into develop. Close #231.
**Description** Copilot 3.19 changed the way that structs are generated. For example, the function `typename` was removed in favor of `typeName`. The code currently generated by Ogma requires Copilot < 3.19 to work. We need to update that. **Type** - Management: Update to work with new versions of dependencies. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** Not applicable (not a bug). **Expected result** The code generated by the struct generator compiles with Copilot 4.2, the current version as of the time of this writing. The following dockerfile installs Copilot 4.2 and Ogma, and uses the structs command to generate a Copilot struct definition, and uses Copilot to check that the code generated compiles, 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 --lib copilot copilot-c99 copilot-language \ copilot-theorem copilot-libraries copilot-interpreter \ && cabal install ogma-cli:ogma \ && echo '{-# LANGUAGE DataKinds #-}' >> Point.hs \ && echo 'module Point where' >> Point.hs \ && echo 'import Language.Copilot' >> Point.hs \ && ogma structs --header-file-name ogma-cli/examples/point.h >> Point.hs \ && ghc -c Point.hs \ && 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-231 ``` **Solution implemented** Modify the code generated by the Copilot struct backend to use the class method `typeName` instead of the old name `typename`. Adjust local names in the Ogma code accordingly. **Further notes** None.
2 parents 5805a67 + 518b051 commit 581ba68

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ogma-core/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Revision history for ogma-core
22

3-
## [1.X.Y] - 2025-02-02
3+
## [1.X.Y] - 2025-02-03
44

55
* Import liftIO from Control.Monad.IO.Class (#215).
66
* Remove references to old design of Ogma from hlint files (#220).
77
* Bump upper version constraint on aeson, text (#225).
88
* Remove extraneous EOL character (#224).
99
* Make structured data available to cFS template (#229).
10+
* Update Copilot struct code generator to use new function names (#231).
1011

1112
## [1.6.0] - 2025-01-21
1213

ogma-core/src/Language/Trans/CStructs2Copilot.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ structInstance cstruct =
151151
instanceHead = "Struct" ++ " " ++ instanceName
152152
instanceName = cStructName2Haskell $ cStructName cstruct
153153

154-
instanceBody = [ instanceTypename, instanceToValues ]
154+
instanceBody = [ instanceTypeName, instanceToValues ]
155155

156-
instanceTypename = "typename" ++ " " ++ "_" ++ " = " ++ show (cStructName cstruct)
156+
instanceTypeName = "typeName" ++ " " ++ "_" ++ " = " ++ show (cStructName cstruct)
157157

158158
instanceToValues =
159159
"toValues" ++ " " ++ "v" ++ " = " ++ "[ " ++ intercalate ", " valueDecls ++ " ]"

0 commit comments

Comments
 (0)