Created
March 30, 2014 15:32
-
-
Save motonacciu/9874489 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| set(FlexTemplFile ${CMAKE_SOURCE_DIR}/lexer.ll.in) | |
| set(FlexSpecFile ${TMP_DIR}/lexer.ll) | |
| # Initialize the file opcodes.ll.cpp with the X-Macro code which extracts lexing rules | |
| # from the opcodes contained in the opcodes.def file (file is generated when cmake is executred) | |
| file(WRITE ${TMP_DIR}/opcodes.ll.cpp | |
| "\#define OPERATOR(NAME, ...) NAME { return OP_##NAME; }\n" | |
| "\#include \"opcodes.def\"\n") | |
| # A rule which runs the preprocessor of the opcodes.ll.cpp file and gives the content to a | |
| # script which replaces the regexp (-r) with the content streaming from stdin into a template | |
| # file (-t). | |
| add_custom_command( | |
| OUTPUT ${FlexSpecFile} | |
| DEPENDS ${CMAKE_SOURCE_DIR}/patcher.py | |
| ${CMAKE_SOURCE_DIR}/opcodes.def | |
| ${FlexTemplFile} ${TMP_DIR}/opcodes.ll.cpp | |
| COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXXFLAGS} -I. -E ${TMP_DIR}/opcodes.ll.cpp | |
| | ${CMAKE_SOURCE_DIR}/patcher.py -t ${FlexTemplFile} -r \"@@{{OPCODES}}@@\" -o ${FlexSpecFile}) | |
| # add a target to set an explicit dependency with the flex generation comand | |
| add_custom_target(gen_lexer_spec DEPENDS ${FlexSpecFile}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment