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

Generate ANTLR parsers at build time #42

Open
gipert opened this issue Jul 2, 2023 · 1 comment
Open

Generate ANTLR parsers at build time #42

gipert opened this issue Jul 2, 2023 · 1 comment
Assignees
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request

Comments

@gipert
Copy link
Member

gipert commented Jul 2, 2023

Instead of generating these files manually once in a while and fixing antlr4-python3-runtime to that version in pyproject.toml, we could let CMake do that automatically at build (actually configure) time. This could be achieved by:

  1. add antlr4-tools to build-system.requires in pyproject.toml
  2. write a shell script that produces the files and moves them to a certain location, for example:
    #!/bin/sh
    
    for f in *.g4; do
        antlr4 "$f" -Werror -Dlanguage=Python3 -visitor || exit 1
    done
    
    mv *.py "$1" || exit 1
    in cmake/tools/antlr
  3. remove everything from the various *Expression folders and just leave a CMakeLists.txt there listing, for example:
    message(STATUS "Generating parser for fluka/RegionExpression")
    
    execute_process(COMMAND
      ${CMAKE_SOURCE_DIR}/cmake/tools/path/to/script.sh ${CMAKE_CURRENT_SOURCE_DIR}
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/tools/RegionExpression
      COMMAND_ERROR_IS_FATAL ANY
    )
    and add the directory in src/pyg4ometry/CMakeLists.txt
  4. set a loose version bound to antlr4-python3-runtime in proyect.dependencies (pyproject.toml)
@gipert gipert added enhancement New feature or request dependencies Pull requests that update a dependency file labels Jul 2, 2023
@stewartboogert
Copy link
Member

I have realised there is another antler generation required for FLUKA as well as GDML. Did you notice this @gipert?

@gipert gipert self-assigned this Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants