[dragonegg] r199994 - dragonegg: [CMake] Introduce CMake. It just works.
NAKAMURA Takumi
geek4civic at gmail.com
Fri Jan 24 04:52:49 PST 2014
Author: chapuni
Date: Fri Jan 24 06:52:49 2014
New Revision: 199994
URL: http://llvm.org/viewvc/llvm-project?rev=199994&view=rev
Log:
dragonegg: [CMake] Introduce CMake. It just works.
FIXME: check-all doesn't handle dragonegg test suites.
Added:
dragonegg/trunk/CMakeLists.txt
dragonegg/trunk/test/CMakeLists.txt
dragonegg/trunk/utils/CMakeLists.txt
Added: dragonegg/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/CMakeLists.txt?rev=199994&view=auto
==============================================================================
--- dragonegg/trunk/CMakeLists.txt (added)
+++ dragonegg/trunk/CMakeLists.txt Fri Jan 24 06:52:49 2014
@@ -0,0 +1,126 @@
+message(STATUS "Configuring DragonEgg...")
+
+add_definitions(-DIN_GCC)
+
+set(DRAGONEGG_TARGET_GCC ${CMAKE_C_COMPILER} CACHE PATH "plugin --print-file-name=plugin")
+message(STATUS "Target GCC is ${DRAGONEGG_TARGET_GCC}")
+
+function(get_gcc_prop prop OUTVAR)
+ execute_process(
+ COMMAND ${DRAGONEGG_TARGET_GCC} "-${prop}"
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ OUTPUT_VARIABLE gcc_prop
+ )
+ set(${OUTVAR} ${gcc_prop} PARENT_SCOPE)
+endfunction()
+
+function(get_gcc_version)
+ get_gcc_prop(dumpversion VER)
+ set(VER__ "${VER}.0.0")
+
+ string(REGEX MATCHALL "[0-9]+" VERS ${VER__})
+
+ list(GET VERS 0 V0)
+ set(GCC_MAJOR ${V0} PARENT_SCOPE)
+ list(GET VERS 1 V1)
+ set(GCC_MINOR ${V1} PARENT_SCOPE)
+ list(GET VERS 2 V2)
+ set(GCC_MICRO ${V2} PARENT_SCOPE)
+
+ message(STATUS "The version is ${VER} (major=${V0}, minor=${V1}, micro=${V2})")
+endfunction()
+
+function(add_backend_header FLAG FILE)
+ get_target_property(TARGET_UTIL TargetInfo LOCATION)
+ set(DST ${CMAKE_BINARY_DIR}/include/dragonegg/${FILE})
+ file(GLOB inc include/*/dragonegg/${FILE})
+ add_custom_command(
+ OUTPUT ${DST}
+ COMMAND mkdir -p ${CMAKE_BINARY_DIR}/include/dragonegg
+ COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/include/`${TARGET_UTIL} ${FLAG}`/dragonegg/${FILE} ${DST}
+ DEPENDS
+ ${inc}
+ ${TARGET_UTIL}
+ COMMENT "Updating include/dragonegg/${FILE}"
+ )
+ set_source_files_properties(${DST} PROPERTIES GENERATED 1)
+ add_file_dependencies(src/Backend.cpp ${DST})
+endfunction()
+
+function(add_target_source FILE)
+ get_target_property(TARGET_UTIL TargetInfo LOCATION)
+ set(DST ${CMAKE_CURRENT_BINARY_DIR}/${FILE})
+ file(GLOB src src/*/${FILE})
+ add_custom_command(
+ OUTPUT ${DST}
+ COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/src/`${TARGET_UTIL} -p`/${FILE} ${DST}
+ DEPENDS
+ ${src}
+ ${TARGET_UTIL}
+ COMMENT "Updating ${FILE}"
+ )
+ set_source_files_properties(${DST} PROPERTIES GENERATED 1)
+endfunction()
+
+get_gcc_prop("-print-file-name=plugin" GCC_PLUGIN_DIR)
+message(STATUS "GCC's plugin directory is ${GCC_PLUGIN_DIR}")
+include_directories(SYSTEM "${GCC_PLUGIN_DIR}/include")
+
+get_gcc_prop(dumpmachine TARGET_TRIPLE)
+message(STATUS "Target triple is ${TARGET_TRIPLE}")
+add_definitions(-DTARGET_TRIPLE="${TARGET_TRIPLE}")
+
+get_gcc_version()
+add_definitions(
+ -DGCC_MAJOR=${GCC_MAJOR}
+ -DGCC_MINOR=${GCC_MINOR}
+ -DGCC_MICRO=${GCC_MICRO}
+ )
+
+# TODO: Put appropriate version string.
+add_definitions(-DLLVM_VERSION="")
+
+include_directories(include)
+
+add_subdirectory(utils)
+
+add_backend_header(-o OS.h)
+
+# add_backend_header(-p Target.h)
+string(REGEX MATCH "^(i[3-6]86|x86_64)-" TARGET_X86 ${TARGET_TRIPLE})
+string(REGEX MATCH "^(arm|thumb)" TARGET_ARM ${TARGET_TRIPLE})
+if (TARGET_ARM)
+ set(TARGET_ARCH "ARM")
+elseif (TARGET_X86)
+ set(TARGET_ARCH "X86")
+else ()
+ message(FATAL_ERROR "Target architecture is unknown")
+endif ()
+
+message(STATUS "Target architecture is ${TARGET_ARCH}")
+string(TOLOWER ${TARGET_ARCH} TARGET_arch_dir)
+include_directories("include/${TARGET_arch_dir}")
+
+file(GLOB SRC src/*.cpp)
+set(LLVM_LINK_COMPONENTS ipo scalaropts X86)
+
+add_llvm_loadable_module(
+ dragonegg
+ src/Aliasing.cpp
+ src/Backend.cpp
+ src/bits_and_bobs.cpp
+ src/Cache.cpp
+ src/ConstantConversion.cpp
+ src/Convert.cpp
+ src/Debug.cpp
+ src/DefaultABI.cpp
+ src/Trees.cpp
+ src/TypeConversion.cpp
+ src/${TARGET_arch_dir}/Target.cpp
+ )
+
+add_dependencies(dragonegg
+ intrinsics_gen
+ )
+
+add_subdirectory(test)
Added: dragonegg/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/CMakeLists.txt?rev=199994&view=auto
==============================================================================
--- dragonegg/trunk/test/CMakeLists.txt (added)
+++ dragonegg/trunk/test/CMakeLists.txt Fri Jan 24 06:52:49 2014
@@ -0,0 +1,27 @@
+set(GCC ${DRAGONEGG_TARGET_GCC})
+set(TARGET_TRIPLE "${TARGET_TRIPLE}-gcc-${GCC_MAJOR}.${GCC_MINOR}")
+set(TEST_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Output")
+
+get_property(DRAGONEGG_PLUGIN TARGET dragonegg PROPERTY LOCATION)
+
+configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/dragonegg-lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/dragonegg-lit.site.cfg
+ )
+
+# Exclude a couple of tests below out of check-all.
+set(EXCLUDE_FROM_ALL ON)
+
+add_lit_testsuite(check-dragonegg-validator "Running the DragonEgg's validator tests"
+ ${CMAKE_CURRENT_SOURCE_DIR}/validator
+ --config-prefix=validator-lit
+ PARAMS site=${CMAKE_CURRENT_BINARY_DIR}/dragonegg-lit.site.cfg
+ DEPENDS dragonegg FileCheck
+ )
+
+add_lit_testsuite(check-dragonegg-compilator "Running the DragonEgg's compilator tests"
+ --config-prefix=compilator-lit
+ ${CMAKE_CURRENT_SOURCE_DIR}/compilator
+ PARAMS site=${CMAKE_CURRENT_BINARY_DIR}/dragonegg-lit.site.cfg
+ DEPENDS dragonegg FileCheck
+ )
Added: dragonegg/trunk/utils/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/utils/CMakeLists.txt?rev=199994&view=auto
==============================================================================
--- dragonegg/trunk/utils/CMakeLists.txt (added)
+++ dragonegg/trunk/utils/CMakeLists.txt Fri Jan 24 06:52:49 2014
@@ -0,0 +1,5 @@
+add_llvm_utility(TargetInfo
+ TargetInfo.cpp
+ )
+
+target_link_libraries(TargetInfo LLVMSupport)
More information about the llvm-commits
mailing list