-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CMake integration of NMODL generation.
The code for the code-generator NMODL is itself generated from Jinja templates. This requires CMake integration to ensure it happens automatically. The following has been changed about the integration: * The CMake code needs a list of the generated files. This list is stored in a CMake file and included. This file must exist before running `code_generator.py` to generate the NMODL code, because the command to generate the files needs to know which file it will be generating. Therefore, we split the script into two phases: one to generate the list of generated files, and another to generate the files. * The list of generated files depends on the build flags. Therefore, this file (`code_generator.cmake`) can't be checked into the Git repo. The `code_generator.cmake` is created during the configure phase, and now lives in the build directory. * CMake code was lifted from `src/language/CMakeLists.txt` to the top-level `CMakeLists.txt` to avoid any scoping issues for the lists of generated files. * Removed pattern of yielding tasks while creating a list tasks in favour of returning the list of tasks directly.
- Loading branch information
Showing
8 changed files
with
102 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1 @@ | ||
# ============================================================================= | ||
# Command to generate AST/Visitor classes from language definition | ||
# ============================================================================= | ||
set_source_files_properties(${NMODL_GENERATED_SOURCES} PROPERTIES GENERATED TRUE) | ||
|
||
# clang-format is handled by the HPC coding conventions scripts, which also handle generating the | ||
# .clang-format configuration file. It's important that we only try to format code if formatting was | ||
# enabled and NMODL's .clang-format exists, otherwise clang-format will search too far up the | ||
# directory tree and find the wrong configuration file. This can break compilation. | ||
if(NMODL_CLANG_FORMAT OR NMODL_FORMATTING) | ||
set(CODE_GENERATOR_OPTS -v --clang-format=${ClangFormat_EXECUTABLE}) | ||
foreach(clang_format_opt ${NMODL_ClangFormat_OPTIONS} --style=file) | ||
list(APPEND CODE_GENERATOR_OPTS --clang-format-opts=${clang_format_opt}) | ||
endforeach() | ||
endif() | ||
|
||
if(NOT NMODL_ENABLE_PYTHON_BINDINGS) | ||
list(APPEND CODE_GENERATOR_OPTS "--disable-pybind") | ||
endif() | ||
|
||
add_custom_command( | ||
OUTPUT ${NMODL_GENERATED_SOURCES} | ||
COMMAND ${PYTHON_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/code_generator.py | ||
${CODE_GENERATOR_OPTS} --base-dir ${PROJECT_BINARY_DIR}/src | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DEPENDS ${CODE_GENERATOR_PY_FILES} | ||
DEPENDS ${CODE_GENERATOR_YAML_FILES} | ||
DEPENDS ${CODE_GENERATOR_JINJA_FILES} | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/templates/code_generator.cmake | ||
COMMENT "-- NMODL : GENERATING AST CLASSES WITH PYTHON GENERATOR! --") | ||
unset(CODE_GENERATOR_OPTS) | ||
|
||
# ============================================================================= | ||
# Target to propagate dependencies properly to lexer | ||
# ============================================================================= | ||
add_custom_target(pyastgen DEPENDS ${PROJECT_BINARY_DIR}/src/ast/ast.cpp) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.