diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 057b6aa..6e76e5e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,91 +1,108 @@
name: Continuous Integration
on:
- push:
- branches:
- - master
+ push:
+ branches:
+ - master
- pull_request:
- branches:
- - master
+ pull_request:
+ branches:
+ - master
jobs:
- lint:
- runs-on: ubuntu-22.04
-
- steps:
- - uses: actions/checkout@v3
-
- - uses: actions/setup-python@v4
- with: { python-version: '3.8' }
-
- - name: Install codespell
- run: pip3 install codespell
-
- - name: Lint
- run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
-
- - name: Spell check
- if: always()
- run: cmake -P cmake/spell.cmake
- sanitize:
- needs: [lint]
-
- runs-on: ubuntu-22.04
-
- env: { CXX: clang++-14 }
-
- steps:
- - uses: actions/checkout@v3
-
- - name: Install Deps
- run: sudo apt-get update -q
- && sudo apt-get install ninja-build libfmt-dev -q -y
-
- - name: Configure
- run: cmake --preset=ci-sanitize -GNinja
-
- - name: Build
- run: cmake --build build/sanitize -j 2
-
- - name: Test
- env:
- ASAN_OPTIONS: "strict_string_checks=1:\
- detect_stack_use_after_return=1:\
- check_initialization_order=1:\
- strict_init_order=1:\
- detect_leaks=1"
- UBSAN_OPTIONS: print_stacktrace=1
- working-directory: build/sanitize
- run: ctest --output-on-failure --no-tests=error
- test:
- needs: [lint]
-
- strategy:
- matrix:
- os: [ubuntu-22.04]
-
- runs-on: ${{ matrix.os }}
-
- steps:
- - uses: actions/checkout@v3
-
- - name: Install static analyzers and dependencies
- if: matrix.os == 'ubuntu-22.04'
- run: >-
- sudo apt-get update -q
-
- sudo apt-get install clang-tidy-14 cppcheck ninja-build libfmt-dev -y -q
-
- sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 140
-
- - name: Configure
- shell: pwsh
- run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])" -GNinja
-
- - name: Build
- run: cmake --build build --config Release -j 2
-
- - name: Test
- working-directory: build
- run: ctest --output-on-failure --no-tests=error -j 2
+ lint:
+ runs-on: ubuntu-22.04
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/setup-python@v4
+ with: { python-version: "3.8" }
+
+ - name: Install codespell
+ run: pip3 install codespell
+
+ - name: Lint
+ run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
+
+ - name: Spell check
+ if: always()
+ run: cmake -P cmake/spell.cmake
+ sanitize:
+ needs: [lint]
+
+ runs-on: ubuntu-22.04
+
+ env: { CXX: clang++-15 }
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install Deps
+ run: |
+ sudo apt-get update -q
+ sudo apt-get install ninja-build clang-15 -q -y
+
+ - name: Configure
+ run: >-
+ cmake
+ -DCMAKE_BUILD_TYPE=Sanitize
+ -DCMAKE_CXX_FLAGS_SANITIZE="-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common"
+ -GNinja -S .
+ -B ../build/sanitize
+
+ - name: Build
+ run: cmake --build ../build/sanitize -j 2
+
+ - name: Test
+ env:
+ ASAN_OPTIONS: "strict_string_checks=1:\
+ detect_stack_use_after_return=1:\
+ check_initialization_order=1:\
+ strict_init_order=1:\
+ detect_leaks=1"
+ UBSAN_OPTIONS: print_stacktrace=1
+ working-directory: ../build/sanitize
+ run: ctest --output-on-failure --no-tests=error
+ test:
+ needs: [lint]
+
+ strategy:
+ matrix:
+ os: [ubuntu-22.04]
+
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install static analyzers and dependencies
+ if: matrix.os == 'ubuntu-22.04'
+ run: |
+ sudo apt-get update -q
+ sudo apt-get install clang-tidy-15 cppcheck ninja-build -y -q
+ sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 150
+
+ - name: Configure
+ run: >-
+ cmake
+ -GNinja
+ -DCMAKE_BUILD_TYPE=Release
+ -DCMAKE_CXX_FLAGS="-fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow=compatible-local -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast"
+ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now"
+ -DCMAKE_SHARED_LINKER_FLAGS="-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now"
+ -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--header-filter=^/home/runner/work/monkey/monkey"
+ -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON
+ -DCMAKE_CXX_CPPCHECK="cppcheck;--inline-suppr;--library=/home/runner/work/monkey/monkey/cppcheck/monkey.cfg"
+ -DCMAKE_CXX_EXTENSIONS=OFF
+ -DCMAKE_CXX_STANDARD=20
+ -DCMAKE_CXX_STANDARD_REQUIRED=ON
+ -S .
+ -B ../build/Release
+
+ - name: Build
+ run: cmake --build ../build/Release -j 2
+
+ - name: Test
+ working-directory: ../build/Release
+ run: ctest --output-on-failure --no-tests=error -j 2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ccef595..6b386f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,11 @@ project(
HOMEPAGE_URL "https://github.com/hrzlgnm/monkey"
LANGUAGES CXX)
-find_package(fmt REQUIRED)
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/fmt.cmake)
# ---- Declare library ----
add_library(
@@ -70,11 +74,8 @@ target_link_libraries(monkey_lib PRIVATE fmt::fmt doctest::doctest doctest::dll)
add_executable(monkey_exe source/main.cpp)
add_executable(monkey::exe ALIAS monkey_exe)
target_compile_definitions(monkey_exe PRIVATE DOCTEST_CONFIG_DISABLE)
-
set_property(TARGET monkey_exe PROPERTY OUTPUT_NAME monkey)
-
target_compile_features(monkey_exe PRIVATE cxx_std_20)
-
-target_link_libraries(monkey_exe PRIVATE monkey_lib)
+target_link_libraries(monkey_exe PRIVATE fmt::fmt monkey_lib)
include(cmake/dev-mode.cmake)
diff --git a/CMakePresets.json b/CMakePresets.json
deleted file mode 100644
index f0741d8..0000000
--- a/CMakePresets.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "version": 2,
- "cmakeMinimumRequired": {
- "major": 3,
- "minor": 14,
- "patch": 0
- },
- "configurePresets": [
- {
- "name": "cmake-pedantic",
- "hidden": true,
- "warnings": {
- "dev": true,
- "deprecated": true,
- "uninitialized": true,
- "unusedCli": true,
- "systemVars": false
- },
- "errors": {
- "dev": true,
- "deprecated": true
- }
- },
- {
- "name": "dev-mode",
- "hidden": true,
- "inherits": "cmake-pedantic",
- "cacheVariables": {
- "monkey_DEVELOPER_MODE": "ON"
- }
- },
- {
- "name": "cppcheck",
- "hidden": true,
- "cacheVariables": {
- "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr"
- }
- },
- {
- "name": "clang-tidy",
- "hidden": true,
- "cacheVariables": {
- "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/",
- "CMAKE_DISABLE_PRECOMPILE_HEADERS": "ON"
- }
- },
- {
- "name": "ci-std",
- "description": "This preset makes sure the project actually builds with at least the specified standard",
- "hidden": true,
- "cacheVariables": {
- "CMAKE_CXX_EXTENSIONS": "OFF",
- "CMAKE_CXX_STANDARD": "20",
- "CMAKE_CXX_STANDARD_REQUIRED": "ON"
- }
- },
- {
- "name": "flags-linux",
- "hidden": true,
- "cacheVariables": {
- "CMAKE_CXX_FLAGS": "-D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow-compatible-local -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast",
- "CMAKE_EXE_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now",
- "CMAKE_SHARED_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now"
- }
- },
- {
- "name": "ci-linux",
- "generator": "Ninja",
- "hidden": true,
- "inherits": ["flags-linux", "ci-std"],
- "cacheVariables": {
- "CMAKE_BUILD_TYPE": "Release"
- }
- },
- {
- "name": "ci-sanitize",
- "binaryDir": "${sourceDir}/build/sanitize",
- "inherits": ["ci-linux", "dev-mode"],
- "cacheVariables": {
- "CMAKE_BUILD_TYPE": "Sanitize",
- "CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common"
- }
- },
- {
- "name": "ci-build",
- "binaryDir": "${sourceDir}/build",
- "hidden": true
- },
- {
- "name": "dev-linux",
- "binaryDir": "${sourceDir}/build/dev-linux",
- "inherits": ["ci-linux"],
- "cacheVariables": {
- "CMAKE_BUILD_TYPE": "Debug",
- "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
- }
- },
- {
- "name": "ci-ubuntu",
- "inherits": [
- "ci-build",
- "ci-linux",
- "clang-tidy",
- "cppcheck",
- "dev-mode"
- ]
- },
- {
- "name": "dev",
- "binaryDir": "${sourceDir}/build/dev",
- "inherits": "dev-linux"
- }
- ],
- "buildPresets": [
- {
- "name": "dev",
- "configurePreset": "dev",
- "configuration": "Debug",
- "jobs": 12
- }
- ]
-}
diff --git a/cmake/fmt.cmake b/cmake/fmt.cmake
new file mode 100644
index 0000000..2e325cc
--- /dev/null
+++ b/cmake/fmt.cmake
@@ -0,0 +1,14 @@
+include(FetchContent)
+
+FetchContent_Declare(fmt
+ GIT_REPOSITORY https://github.com/fmtlib/fmt.git
+ GIT_TAG 8.1.1
+)
+
+FetchContent_MakeAvailable(fmt)
+
+# HACK(hrzgnm): disable analyzer checks on fmt library
+set_target_properties(fmt PROPERTIES
+ CXX_CLANG_TIDY ""
+ CXX_CPPCHECK "")
+
diff --git a/cppcheck/monkey.cfg b/cppcheck/monkey.cfg
new file mode 100644
index 0000000..782bfc2
--- /dev/null
+++ b/cppcheck/monkey.cfg
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/source/compiler/symbol_table.hpp b/source/compiler/symbol_table.hpp
index e414898..4b71af4 100644
--- a/source/compiler/symbol_table.hpp
+++ b/source/compiler/symbol_table.hpp
@@ -7,6 +7,8 @@
#include
#include
+#include
+
template
using string_map = std::map>;
diff --git a/source/main.cpp b/source/main.cpp
index e37b13a..f8019f2 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -41,7 +41,7 @@ auto monkey_business()
auto print_parse_errors(const std::vector& errors)
{
monkey_business();
- std::cerr << " parser errorrs: \n";
+ std::cerr << " parser errors: \n";
for (const auto& error : errors) {
std::cerr << "\t" << error << "\n";
}
diff --git a/test/doctest/CMakeLists.txt b/test/doctest/CMakeLists.txt
index 1f21f2b..4cf2476 100644
--- a/test/doctest/CMakeLists.txt
+++ b/test/doctest/CMakeLists.txt
@@ -1,20 +1,28 @@
add_library(doctest INTERFACE)
add_library(doctest::doctest ALIAS doctest)
-
-# note SYSTEM is only used to exclude the doctest single header from clang-tidy
-target_include_directories(doctest SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(doctest INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
add_library(doctest_dll dll.cpp)
add_library(doctest::dll ALIAS doctest_dll)
target_link_libraries(doctest_dll PRIVATE doctest::doctest)
-
add_executable(doctest_exe main.cpp)
+
target_precompile_headers(doctest_exe REUSE_FROM monkey_lib)
target_link_libraries(doctest_exe PRIVATE doctest::doctest doctest::dll
fmt::fmt monkey::lib)
add_executable(doctest::exe ALIAS doctest_exe)
-
set_property(TARGET doctest_exe PROPERTY OUTPUT_NAME doctest)
target_compile_features(doctest_exe PRIVATE cxx_std_20)
add_test(NAME doctest COMMAND $ --no-version)
+
+# HACK(hrzgnm): disable analyzer checks on doctest targets
+set_target_properties(doctest_exe PROPERTIES
+ CXX_CLANG_TIDY ""
+ CXX_CPPCHECK "")
+set_target_properties(doctest_dll PROPERTIES
+ CXX_CLANG_TIDY ""
+ CXX_CPPCHECK "")
+set_target_properties(doctest PROPERTIES
+ CXX_CLANG_TIDY ""
+ CXX_CPPCHECK "")