diff --git a/coco/gen-grammar b/coco/gen-grammar index 66a5acd..1c4b079 100755 --- a/coco/gen-grammar +++ b/coco/gen-grammar @@ -1,4 +1,5 @@ -COCO_PATH=/opt/coco-cpp/ +COCO_EXECUTABLE= $1 || "cococpp" echo "Run coco generator: " -$COCO_PATH/Coco ./xreate.ATG -frames $COCO_PATH +$COCO_EXECUTABLE ./xreate.ATG + #-frames $COCO_PATH diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index fb7d51b..d98c03e 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -1,216 +1,218 @@ cmake_minimum_required(VERSION 2.8.11) project(xreate) cmake_policy(SET CMP0022 NEW) # LLVM #====================== #FIND_PACKAGE (LLVM REQUIRED CONFIG PATHS PATH-TO-CMAKE-DIR NO_DEFAULT_PATH) FIND_PACKAGE (LLVM REQUIRED) set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-tools") #include(PCH_GCC4_v2) set(LLVM_VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}) message ("LLVM LIB PATH:" ${LLVM_LIBRARY_DIRS}) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) message ("MPATH:" ${CMAKE_MODULE_PATH}) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") message(STATUS "INCLUDE DIR: ${LLVM_INCLUDE_DIRS}") INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIRS}) message("LLVM defs: " ${LLVM_DEFINITIONS}) add_definitions(${LLVM_DEFINITIONS}) llvm_map_components_to_libnames(LLVM_LIBS core nativecodegen native executionengine mcjit support) message("LLVM libs: " ${LLVM_LIBS}) # CLANG #====================== set(CLANG_LIBS ${LLVM_LIBRARY_DIRS}/libclangCodeGen.so ${LLVM_LIBRARY_DIRS}/libclangASTMatchers.so ${LLVM_LIBRARY_DIRS}/libclangQuery.so ${LLVM_LIBRARY_DIRS}/libclangTooling.so ${LLVM_LIBRARY_DIRS}/libclangFrontend.so ${LLVM_LIBRARY_DIRS}/libclangSerialization.so ${LLVM_LIBRARY_DIRS}/libclangDriver.so ${LLVM_LIBRARY_DIRS}/libclangParse.so ${LLVM_LIBRARY_DIRS}/libclangSema.so ${LLVM_LIBRARY_DIRS}/libclangAnalysis.so ${LLVM_LIBRARY_DIRS}/libclangAST.so ${LLVM_LIBRARY_DIRS}/libclangEdit.so ${LLVM_LIBRARY_DIRS}/libclangLex.so ${LLVM_LIBRARY_DIRS}/libclangBasic.so ) #find_package(Clang REQUIRED clangTooling libClang) message(STATUS "CLANG LIBS: " ${CLANG_LIBS}) # POTASSCO #====================== set(POTASSCO_PATH "/opt/potassco/clingo" CACHE PATH "Path to potassco sources") set(POTASSCO_INCLUDE_PATH ${POTASSCO_PATH}/libgringo ${POTASSCO_PATH}/libclasp ${POTASSCO_PATH}/libclingo ${POTASSCO_PATH}/libprogram_opts ${POTASSCO_PATH}/liblp ) INCLUDE_DIRECTORIES(${POTASSCO_INCLUDE_PATH}) set (LIBCLASP_PATH ${POTASSCO_PATH}/build/debug) set(LIBCLASP_LIBS clingo clasp gringo program_opts reify lp ) message(STATUS "CLASP LIBS: " ${LIBCLASP_LIBS}) link_directories(${LIBCLASP_PATH}) # OTHER DEPENDENCIES #=========================== set(JEAYESON_INCLUDE_PATH ${CMAKE_HOME_DIRECTORY}/../vendors/jeayeson/include/ ) INCLUDE_DIRECTORIES(${JEAYESON_INCLUDE_PATH}) # COCO #=========================== -set(COCO_PATH ${CMAKE_HOME_DIRECTORY}/../coco/) +set(COCO_EXECUTABLE "" CACHE PATH "Path to coco executable") + +set(COCO_GRAMMAR_PATH ${CMAKE_HOME_DIRECTORY}/../coco/) set(COCO_SOURCE_FILES - ${COCO_PATH}/Parser.cpp - ${COCO_PATH}/Scanner.cpp) -INCLUDE_DIRECTORIES(${COCO_PATH}) + ${COCO_GRAMMAR_PATH}/Parser.cpp + ${COCO_GRAMMAR_PATH}/Scanner.cpp) +INCLUDE_DIRECTORIES(${COCO_GRAMMAR_PATH}) add_custom_command(OUTPUT ${COCO_SOURCE_FILES} - COMMAND ${COCO_PATH}/gen-grammar - WORKING_DIRECTORY ${COCO_PATH} - MAIN_DEPENDENCY ${COCO_PATH}/xreate.ATG + COMMAND ${COCO_GRAMMAR_PATH}/gen-grammar ${COCO_EXECUTABLE} + WORKING_DIRECTORY ${COCO_GRAMMAR_PATH} + MAIN_DEPENDENCY ${COCO_GRAMMAR_PATH}/xreate.ATG ) message(STATUS "COCO GRAMMAR BUILD STATUS:" ${COCO_OUTPUT}) # XREATE #====================== set(SOURCE_FILES pass/compilepass.cpp pass/interpretationpass.cpp compilation/targetinterpretation.cpp ast.cpp ExternLayer.cpp attachments.cpp analysis/cfagraph.cpp analysis/dfagraph.cpp analysis/aux.cpp compilation/containers.cpp compilation/advanced.cpp compilation/transformations.cpp analysis/DominatorsTreeAnalysisProvider.cpp clasplayer.cpp compilation/latecontextcompiler2.cpp query/context.cpp #compilation/latecontextcompiler.cpp serialization/expressionserializer.cpp serialization/expressionserializer2.cpp llvmlayer.cpp utils.cpp passmanager.cpp pass/abstractpass.cpp pass/dfapass.cpp pass/cfapass.cpp pass/loggerpass.cpp pass/adhocpass.cpp query/containers.cpp contextrule.cpp #query/ptrvalid.cpp #pass/rulespass.cpp # ) set(XREATE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ ) INCLUDE_DIRECTORIES(${XREATE_INCLUDE_DIRS}) set(XREATE_PRIVATE_INCLUDE_DIRS ${XREATE_INCLUDE_DIRS} - ${COCO_PATH} + ${COCO_GRAMMAR_PATH} ${JEAYESON_INCLUDE_PATH} ${LLVM_INCLUDE_DIRS} ${POTASSCO_INCLUDE_PATH} ) add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${COCO_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} ${LIBCLASP_LIBS}) target_include_directories(${PROJECT_NAME} INTERFACE ${XREATE_INCLUDE_DIRS} - ${COCO_PATH} + ${COCO_GRAMMAR_PATH} ${JEAYESON_INCLUDE_PATH} ${LLVM_INCLUDE_DIRS} ${POTASSCO_INCLUDE_PATH} ) get_directory_property(DEFINITIONS_ALL DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) message("definitions all: " ${DEFINITIONS_ALL}) target_compile_definitions(${PROJECT_NAME} INTERFACE ${DEFINITIONS_ALL}) get_directory_property(COMPILATION_OPTIONS_ALL DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) message("compilations all: " ${COMPILATION_OPTIONS_ALL}) target_compile_options(${PROJECT_NAME} INTERFACE ${COMPILATION_OPTIONS_ALL}) SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LLVM_LIBS} ${CLANG_LIBS} tbb ) #set (LINK_INTERFACE_LIBRARIES "") # FUNCTION(PREPEND var prefix) # SET(listVar "") # FOREACH(f ${ARGN}) # LIST(APPEND listVar "${prefix}/${f}") # ENDFOREACH(f) # SET(${var} "${listVar}" PARENT_SCOPE) # ENDFUNCTION(PREPEND) #set(COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "-j4") #cotire(xreate) # MACRO (ADD_PCH_RULE _header_filename _src_list) # SET(_gch_filename "${_header_filename}.gch") # LIST(APPEND ${_src_list} ${_gch_filename}) # SET (_args ${CMAKE_CXX_FLAGS}) # LIST(APPEND _args -c ${_header_filename} -o ${_gch_filename}) # GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) # foreach (_inc ${DIRINC}) # LIST(APPEND _args "-I" ${_inc}) # endforeach(_inc ${DIRINC}) # SEPARATE_ARGUMENTS(_args) # add_custom_command(OUTPUT ${_gch_filename} # COMMAND rm -f ${_gch_filename} # COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args} # DEPENDS ${_header_filename}) # ENDMACRO(ADD_PCH_RULE _header_filename _src_list) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/ast.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/llvmlayer.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/clasplayer.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/pass/abstractpass.h SOURCE_FILES)