Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-organize compiler modules into a compiler directory #101

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.13
- uses: DoozyX/clang-format-lint-action@v0.17
with:
source: '.'
exclude: './thirdparty ./docs'
source: './compiler'
extensions: 'hpp,cpp'
clangFormatVersion: 12
clangFormatVersion: 17

build-gcc:
name: Build on Ubuntu GCC
runs-on: ubuntu-latest
needs: code-style-check
container:
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:1710845516
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest
options: --user root
credentials:
username: ${{ github.actor }}
Expand All @@ -48,7 +47,7 @@ jobs:
submodules: true
- name: Build
run: |
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_IR_GENERATOR=OFF
cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_IR_GENERATOR=OFF
ninja -C build
- name: Archive binaries
run: tar cf binaries.tar -C build bin
Expand All @@ -63,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
needs: build-gcc
container:
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:1710845516
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest
options: --user root
credentials:
username: ${{ github.actor }}
Expand Down
22 changes: 0 additions & 22 deletions ast/CMakeLists.txt

This file was deleted.

23 changes: 0 additions & 23 deletions backend/CMakeLists.txt

This file was deleted.

31 changes: 0 additions & 31 deletions cli/CMakeLists.txt

This file was deleted.

26 changes: 11 additions & 15 deletions CMakeLists.txt → compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.22)

project(Compiler LANGUAGES CXX)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

option(ENABLE_IR_GENERATOR "Enables LLVM-based IR generation backend" ON)
set(COMPILER_CMAKE_DIR ${CMAKE_SOURCE_DIR}/cmake)
set(COMPILER_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(COMPILER_LIB_DIR ${CMAKE_SOURCE_DIR}/lib)

option(ENABLE_CODEGEN "Enables LLVM IR generation backend" OFF)
option(ENABLE_CLI "Enables command-line interface application" ON)
option(ENABLE_TESTS "Enables tests for components" ON)

Expand All @@ -22,19 +27,10 @@ if(WIN32)
option(gtest_force_shared_crt "" TRUE)
endif()

add_subdirectory(utils)
add_subdirectory(ast)
add_subdirectory(backend)
add_subdirectory(thirdparty)

if(ENABLE_IR_GENERATOR)
add_subdirectory(ir_generator)
add_compile_definitions("ENABLE_IR_GENERATOR")
endif()
include(${COMPILER_CMAKE_DIR}/utils.cmake)

if(ENABLE_CLI)
add_subdirectory(cli)
endif()
add_subdirectory(../thirdparty thirdparty)
add_subdirectory(lib)

if(ENABLE_TESTS)
enable_testing()
Expand Down
5 changes: 5 additions & 0 deletions compiler/cmake/utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.22)

macro(set_target_include_dir TARGET_NAME)
set(TARGET_INCLUDE_DIR "${COMPILER_INCLUDE_DIR}/compiler/${TARGET_NAME}")
endmacro()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>
#include <vector>

#include "ast/types.hpp"
#include "compiler/ast/types.hpp"

namespace ast {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include <string>
#include <variant>

#include <utils/source_ref.hpp>
#include "compiler/utils/source_ref.hpp"

#include "ast/node_type.hpp"
#include "ast/variables_table.hpp"
#include "compiler/ast/node_type.hpp"
#include "compiler/ast/variables_table.hpp"

namespace ast {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <ostream>

#include "ast/functions_table.hpp"
#include "ast/node.hpp"
#include "compiler/ast/functions_table.hpp"
#include "compiler/ast/node.hpp"

namespace ast {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <map>
#include <string>

#include "ast/types.hpp"
#include "compiler/ast/types.hpp"

namespace ast {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <ast/syntax_tree.hpp>
#include <ast/types.hpp>
#include "compiler/ast/syntax_tree.hpp"
#include "compiler/ast/types.hpp"

#include "backend/optimizer/optimizer_options.hpp"
#include "compiler/backend/ast/optimizer/optimizer_options.hpp"

namespace optimizer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include <unordered_map>
#include <variant>

#include <ast/functions_table.hpp>
#include <ast/node.hpp>
#include <ast/variables_table.hpp>
#include "compiler/ast/functions_table.hpp"
#include "compiler/ast/node.hpp"
#include "compiler/ast/variables_table.hpp"

#include "backend/optimizer/optimizer_options.hpp"
#include "compiler/backend/ast/optimizer/optimizer_options.hpp"

namespace optimizer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <ast/syntax_tree.hpp>
#include <ast/types.hpp>
#include "compiler/ast/syntax_tree.hpp"
#include "compiler/ast/types.hpp"
#include "compiler/utils/error_buffer.hpp"

#include "error_buffer.hpp"
#include "semantizer_context.hpp"
#include "semantizer_error.hpp"
#include "compiler/backend/ast/semantizer/semantizer_context.hpp"
#include "compiler/backend/ast/semantizer/semantizer_error.hpp"

namespace semantizer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <list>

#include "error_buffer.hpp"
#include "semantizer_error.hpp"
#include "compiler/ast/functions_table.hpp"
#include "compiler/ast/node.hpp"
#include "compiler/ast/variables_table.hpp"
#include "compiler/utils/error_buffer.hpp"

#include <ast/functions_table.hpp>
#include <ast/node.hpp>
#include <ast/variables_table.hpp>
#include "compiler/backend/ast/semantizer/semantizer_error.hpp"

namespace semantizer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include <ast/node.hpp>

#include "base_error.hpp"
#include "compiler/ast/node.hpp"
#include "compiler/utils/base_error.hpp"

namespace semantizer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <string>

#include <backend/lexer/token.hpp>
#include <backend/stringvec.hpp>
#include "compiler/frontend/lexer/token.hpp"
#include "compiler/utils/stringvec.hpp"

namespace dumping {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <llvm/IR/Module.h>
#pragma warning(pop)

#include <ast/syntax_tree.hpp>
#include "compiler/ast/syntax_tree.hpp"

namespace ir_generator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <string>
#include <string_view>

#include <utils/source_files.hpp>
#include "compiler/utils/error_buffer.hpp"
#include "compiler/utils/source_files.hpp"

#include "error_buffer.hpp"
#include "lexer/token.hpp"
#include "compiler/frontend/lexer/token.hpp"

namespace lexer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "base_error.hpp"
#include "compiler/utils/base_error.hpp"

namespace lexer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>
#include <variant>

#include <utils/source_ref.hpp>
#include "compiler/utils/source_ref.hpp"

namespace lexer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <ast/syntax_tree.hpp>
#include "compiler/ast/syntax_tree.hpp"

#include "lexer/token.hpp"
#include "compiler/frontend/lexer/token.hpp"

namespace parser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <stack>
#include <unordered_map>

#include <ast/node.hpp>
#include <ast/types.hpp>
#include <utils/source_ref.hpp>
#include "compiler/ast/node.hpp"
#include "compiler/ast/types.hpp"
#include "compiler/utils/error_buffer.hpp"
#include "compiler/utils/source_ref.hpp"

#include "error_buffer.hpp"
#include "lexer/token.hpp"
#include "lexer/token_types.hpp"
#include "parser/parser_error.hpp"
#include "compiler/frontend/lexer/token.hpp"
#include "compiler/frontend/lexer/token_types.hpp"
#include "compiler/frontend/parser/parser_error.hpp"

namespace parser {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "base_error.hpp"
#include "compiler/utils/base_error.hpp"

#include "lexer/token.hpp"

namespace parser {
Expand Down
Loading