Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ogma-core: Update Copilot struct code generator to use new function names. Refs #231. #232

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

ivanperez-keera
Copy link
Member

This commit updates the Copilot struct code generator to use the new function name typeName as typename has been removed, as prescribed in the solution proposed for #231.

…ames. Refs nasa#231.

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.

This commit updates the code generator of Copilot structs to use `typeName`
instead. That is the only function affected by that change in Copilot that Ogma
currently uses in this backend.
@ivanperez-keera
Copy link
Member Author

ivanperez-keera commented Feb 3, 2025

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles and passes all tests. Details:
    • The solution proposed produces the expected result. Details:
      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):
      $ docker run -e "REPO=https://github.com/ivanperez-keera/ogma" -e "NAME=ogma" -e "COMMIT=518b05133d0e38185d9f890eeaf37e84de0971f7" -it ogma-verify-231
      
  • Implementation is documented. Details:
    No updates needed; the change is to an internal function.
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No updates needed; the change is to an internal function.
  • Author is internal or has provided signed CLA.
  • Required version bumps are evaluated. Details:
    Bump needed; Ogma now generates code valid only for a modern version of Copilot (>= 3.19).

@ivanperez-keera ivanperez-keera merged commit 581ba68 into nasa:develop Feb 3, 2025
2 checks passed
@ivanperez-keera ivanperez-keera deleted the develop-copilot-3.19 branch February 3, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant