From 6e20935a1bd9104caf22ee4f9a1c171650490dbe Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Tue, 10 Mar 2015 01:28:43 +0100 Subject: [PATCH] Grouping source files under src/ directory. --- CMakeLists.txt | 68 +-------------- BitcodeEmitter.cpp => src/BitcodeEmitter.cpp | 0 BitcodeEmitter.hpp => src/BitcodeEmitter.hpp | 0 src/CMakeLists.txt | 87 ++++++++++++++++++++ CppEmitter.cpp => src/CppEmitter.cpp | 0 CppEmitter.hpp => src/CppEmitter.hpp | 0 Emitter.hpp => src/Emitter.hpp | 0 ModuleLoader.cpp => src/ModuleLoader.cpp | 0 ModuleLoader.hpp => src/ModuleLoader.hpp | 0 ModuleRegistry.cpp => src/ModuleRegistry.cpp | 0 ModuleRegistry.hpp => src/ModuleRegistry.hpp | 0 Monicelli.lpp => src/Monicelli.lpp | 0 Monicelli.ypp => src/Monicelli.ypp | 0 Nodes.cpp => src/Nodes.cpp | 0 Nodes.hpp => src/Nodes.hpp | 0 Pointers.hpp => src/Pointers.hpp | 0 Runtime.c => src/Runtime.c | 0 Runtime.h => src/Runtime.h | 0 Scanner.hpp => src/Scanner.hpp | 0 Scope.hpp => src/Scope.hpp | 0 main.cpp => src/main.cpp | 0 21 files changed, 89 insertions(+), 66 deletions(-) rename BitcodeEmitter.cpp => src/BitcodeEmitter.cpp (100%) rename BitcodeEmitter.hpp => src/BitcodeEmitter.hpp (100%) create mode 100644 src/CMakeLists.txt rename CppEmitter.cpp => src/CppEmitter.cpp (100%) rename CppEmitter.hpp => src/CppEmitter.hpp (100%) rename Emitter.hpp => src/Emitter.hpp (100%) rename ModuleLoader.cpp => src/ModuleLoader.cpp (100%) rename ModuleLoader.hpp => src/ModuleLoader.hpp (100%) rename ModuleRegistry.cpp => src/ModuleRegistry.cpp (100%) rename ModuleRegistry.hpp => src/ModuleRegistry.hpp (100%) rename Monicelli.lpp => src/Monicelli.lpp (100%) rename Monicelli.ypp => src/Monicelli.ypp (100%) rename Nodes.cpp => src/Nodes.cpp (100%) rename Nodes.hpp => src/Nodes.hpp (100%) rename Pointers.hpp => src/Pointers.hpp (100%) rename Runtime.c => src/Runtime.c (100%) rename Runtime.h => src/Runtime.h (100%) rename Scanner.hpp => src/Scanner.hpp (100%) rename Scope.hpp => src/Scope.hpp (100%) rename main.cpp => src/main.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d6c2b6..5542c51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,71 +55,7 @@ if (execution_results MATCHES FAILED_TO_RUN) ) endif() -## 2. Find Flex and Bison +## 2. Build Monicelli! -find_package(BISON REQUIRED) -find_package(FLEX 2.5 REQUIRED) - -if (BISON_VERSION VERSION_LESS 2.5) - message(FATAL_ERROR "At least Bison 2.5 is required.") -elseif(BISON_VERSION VERSION_LESS 3.0) - message("== Bison 2.5 was found. You have to apply cmake/bison2.patch...") -endif() - -## 3. External components - -find_package(Boost 1.48 REQUIRED regex system filesystem) -find_package(LLVM REQUIRED CONFIG) - -find_library(YAML_LIBRARIES yaml-cpp) -find_path(YAML_INCLUDE_DIRS yaml.h /usr/include/yaml-cpp/) - -add_definitions( - ${Boost_DEFINITIONS} - ${LLVM_DEFINITIONS} -) - -include_directories( - ${Boost_INCLUDE_DIRS} - ${LLVM_INCLUDE_DIRS} - ${YAML_INCLUDE_DIRS} -) - -## 4. Build - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) - -bison_target(Parser Monicelli.ypp ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp) -flex_target(Scanner Monicelli.lpp ${CMAKE_CURRENT_BINARY_DIR}/Lexer.cpp) -add_flex_bison_dependency(Scanner Parser) - -add_executable(mcc - main.cpp Nodes.cpp - ModuleRegistry.cpp ModuleLoader.cpp - ${BISON_Parser_OUTPUTS} ${FLEX_Scanner_OUTPUTS} - CppEmitter.cpp BitcodeEmitter.cpp -) - -target_compile_options(mcc PRIVATE - ${LLVM_CXXFLAGS} ${Boost_CXXFLAGS} - -Wall -Wextra -Werror -Wno-unused-parameter -Wno-deprecated-register - -std=c++0x -DYYDEBUG=0 -) - -llvm_map_components_to_libnames(LLVM_LIBRARIES - support core native bitwriter -) - -target_link_libraries(mcc - ${Boost_LIBRARIES} - ${LLVM_LIBRARIES} - ${YAML_LIBRARIES} -) - -## 6. Build the runtime library too - -add_library(mcrt STATIC Runtime.c) +add_subdirectory(src) diff --git a/BitcodeEmitter.cpp b/src/BitcodeEmitter.cpp similarity index 100% rename from BitcodeEmitter.cpp rename to src/BitcodeEmitter.cpp diff --git a/BitcodeEmitter.hpp b/src/BitcodeEmitter.hpp similarity index 100% rename from BitcodeEmitter.hpp rename to src/BitcodeEmitter.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..ddf96be --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,87 @@ +# +# Monicelli: an esoteric language compiler +# +# Copyright (C) 2014 Stefano Sanfilippo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +## 1. Find Flex and Bison + +find_package(BISON REQUIRED) +find_package(FLEX 2.5 REQUIRED) + +if (BISON_VERSION VERSION_LESS 2.5) + message(FATAL_ERROR "At least Bison 2.5 is required.") +elseif(BISON_VERSION VERSION_LESS 3.0) + message("== Bison 2.5 was found. You have to apply cmake/bison2.patch...") +endif() + +## 2. External components + +find_package(Boost 1.48 REQUIRED regex system filesystem) +find_package(LLVM REQUIRED CONFIG) + +find_library(YAML_LIBRARIES yaml-cpp) +find_path(YAML_INCLUDE_DIRS yaml.h /usr/include/yaml-cpp/) + +add_definitions( + ${Boost_DEFINITIONS} + ${LLVM_DEFINITIONS} +) + +include_directories( + ${Boost_INCLUDE_DIRS} + ${LLVM_INCLUDE_DIRS} + ${YAML_INCLUDE_DIRS} +) + +## 3. Build + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +bison_target(Parser Monicelli.ypp ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp) +flex_target(Scanner Monicelli.lpp ${CMAKE_CURRENT_BINARY_DIR}/Lexer.cpp) +add_flex_bison_dependency(Scanner Parser) + +add_executable(mcc + main.cpp Nodes.cpp + ModuleRegistry.cpp ModuleLoader.cpp + ${BISON_Parser_OUTPUTS} ${FLEX_Scanner_OUTPUTS} + CppEmitter.cpp BitcodeEmitter.cpp +) + +target_compile_options(mcc PRIVATE + ${LLVM_CXXFLAGS} ${Boost_CXXFLAGS} + -Wall -Wextra -Werror -Wno-unused-parameter -Wno-deprecated-register + -std=c++0x -DYYDEBUG=0 +) + +llvm_map_components_to_libnames(LLVM_LIBRARIES + support core native bitwriter +) + +target_link_libraries(mcc + ${Boost_LIBRARIES} + ${LLVM_LIBRARIES} + ${YAML_LIBRARIES} +) + +## 5. Build the runtime library too + +add_library(mcrt STATIC Runtime.c) + diff --git a/CppEmitter.cpp b/src/CppEmitter.cpp similarity index 100% rename from CppEmitter.cpp rename to src/CppEmitter.cpp diff --git a/CppEmitter.hpp b/src/CppEmitter.hpp similarity index 100% rename from CppEmitter.hpp rename to src/CppEmitter.hpp diff --git a/Emitter.hpp b/src/Emitter.hpp similarity index 100% rename from Emitter.hpp rename to src/Emitter.hpp diff --git a/ModuleLoader.cpp b/src/ModuleLoader.cpp similarity index 100% rename from ModuleLoader.cpp rename to src/ModuleLoader.cpp diff --git a/ModuleLoader.hpp b/src/ModuleLoader.hpp similarity index 100% rename from ModuleLoader.hpp rename to src/ModuleLoader.hpp diff --git a/ModuleRegistry.cpp b/src/ModuleRegistry.cpp similarity index 100% rename from ModuleRegistry.cpp rename to src/ModuleRegistry.cpp diff --git a/ModuleRegistry.hpp b/src/ModuleRegistry.hpp similarity index 100% rename from ModuleRegistry.hpp rename to src/ModuleRegistry.hpp diff --git a/Monicelli.lpp b/src/Monicelli.lpp similarity index 100% rename from Monicelli.lpp rename to src/Monicelli.lpp diff --git a/Monicelli.ypp b/src/Monicelli.ypp similarity index 100% rename from Monicelli.ypp rename to src/Monicelli.ypp diff --git a/Nodes.cpp b/src/Nodes.cpp similarity index 100% rename from Nodes.cpp rename to src/Nodes.cpp diff --git a/Nodes.hpp b/src/Nodes.hpp similarity index 100% rename from Nodes.hpp rename to src/Nodes.hpp diff --git a/Pointers.hpp b/src/Pointers.hpp similarity index 100% rename from Pointers.hpp rename to src/Pointers.hpp diff --git a/Runtime.c b/src/Runtime.c similarity index 100% rename from Runtime.c rename to src/Runtime.c diff --git a/Runtime.h b/src/Runtime.h similarity index 100% rename from Runtime.h rename to src/Runtime.h diff --git a/Scanner.hpp b/src/Scanner.hpp similarity index 100% rename from Scanner.hpp rename to src/Scanner.hpp diff --git a/Scope.hpp b/src/Scope.hpp similarity index 100% rename from Scope.hpp rename to src/Scope.hpp diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp