diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 1c12f2e..4d5f6c6 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,16 +1,34 @@ cmake_minimum_required(VERSION 2.8.11) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall -fprofile-arcs -ftest-coverage -O0") set(CMAKE_BUILD_TYPE Debug) +# BUILD OPTIONS +#====================== +set(XREATE_DEFINITIONS + -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DWITH_THREADS=1 +) + +add_definitions(${XREATE_DEFINITIONS}) +add_compile_options(-Winvalid-pch -fPIC) + + +# XREATE +#====================== add_subdirectory(src) + +# XREATE-TESTS +#====================== if (BUILD_XREATE_TESTS) message ("Building xreate tests") add_subdirectory(tests) endif () + +# XREATE-SERVER +#====================== if (BUILD_XREATE_SERVER) message ("Building xreate server") add_subdirectory(../tools/execution-server execution-server) endif () diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index b10e64a..fb7d51b 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -1,226 +1,216 @@ cmake_minimum_required(VERSION 2.8.11) project(xreate) cmake_policy(SET CMP0022 NEW) -# BUILD OPTIONS -#====================== -set(XREATE_DEFINITIONS - -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DWITH_THREADS=1 -) - -add_definitions(${XREATE_DEFINITIONS}) -add_compile_options(-Winvalid-pch -std=c++14 -fPIC) - - - # 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_SOURCE_FILES ${COCO_PATH}/Parser.cpp ${COCO_PATH}/Scanner.cpp) INCLUDE_DIRECTORIES(${COCO_PATH}) add_custom_command(OUTPUT ${COCO_SOURCE_FILES} COMMAND ${COCO_PATH}/gen-grammar WORKING_DIRECTORY ${COCO_PATH} MAIN_DEPENDENCY ${COCO_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 - #pass/rulespass.cpp # query/containers.cpp - query/ptrvalid.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} ${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} ${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) diff --git a/installation/docker/Dockerfile b/installation/docker/Dockerfile index 7c0ad16..a2a388a 100644 --- a/installation/docker/Dockerfile +++ b/installation/docker/Dockerfile @@ -1,35 +1,41 @@ FROM opensuse-tumbleweed MAINTAINER Melnychenko Volodymyr ARG CLANG_VERSION=3_8 ARG BOOST_VERSION=_1_61 ARG CLASP_VERSION=a363d9 RUN zypper in -y \ - boost$BOOST_VERSION-devel clang$CLANG_VERSION-devel gcc6-c++ \ + boost$BOOST_VERSION-devel clang$CLANG_VERSION-devel llvm$CLANG_VERSION-gold gcc6-c++ \ tbb-devel cmake git bison re2c scons unzip libgtest0 googletest-devel libxml2-devel wget ## COCO WORKDIR /opt/coco-cpp RUN wget http://www.ssw.uni-linz.ac.at/Coco/CPP/CocoSourcesCPP.zip &&\ unzip ./CocoSourcesCPP.zip &&\ g++-6 *.cpp -o Coco -g -Wall # POTASSCO WORKDIR /opt/potassco/clingo/ RUN git clone https://github.com/potassco/clingo.git ./ &&\ git reset --hard $CLASP_VERSION ADD patches/potassco-patch-$CLASP_VERSION . RUN git apply potassco-patch-$CLASP_VERSION &&\ scons configure --build-dir=debug &&\ sed -i "s/CXXFLAGS = \[\(.*\)\]/CXXFLAGS = \['-fPIC', \1\]/" build/debug.py &&\ sed -i "s/CXX = 'c++'/CXX = 'g++-6'/" build/debug.py &&\ sed -i "s/WITH_LUA = 'auto'/WITH_LUA = None/" build/debug.py &&\ sed -i "s/WITH_PYTHON = 'auto'/WITH_PYTHON = None/" build/debug.py &&\ cat build/debug.py &&\ scons --build-dir=debug - # sed -i "s/'-std=c++11'/'-std=c++14'/" build/debug.py - + +# XREATE +WORKDIR /opt/xreate +RUN git clone https://pgess@bitbucket.org/pgess/xreate.git ./ + +WORKDIR /opt/xreate/build +RUN cmake -DBUILD_XREATE_TESTS=1 ../cpp &&\ + make -j4