From 0b7f40d7158662f1de63b21d1c7ac659e1060a88 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 13 Apr 2021 10:39:13 +0100 Subject: [PATCH] Update the readme file --- README.org | 71 ++++++++++++++++++-- builder | 9 +-- tests/serenetests.cpp | 1 + tests/{utils.cpp.inc => utils_tests.cpp.inc} | 5 ++ 4 files changed, 74 insertions(+), 12 deletions(-) rename tests/{utils.cpp.inc => utils_tests.cpp.inc} (93%) diff --git a/README.org b/README.org index b646208..ccffef7 100644 --- a/README.org +++ b/README.org @@ -1,11 +1,72 @@ * Serene lang + ** Setup development environment Setup the githook and install dependencies using the following commands: -#+BEGIN_EXAMPLE bash -./builder deps -./builder setup -#+END_SRC + #+BEGIN_SRC bash + ./builder setup + #+END_SRC + +*** Dependencies + You would need the following dependencies to start get started with *Serene* development + + - LLVM ( LLVM Instructions coming up.) + - cmake + - ninja + - doxygen (If you want to build the docs as well) + - Valgrind + - CCache (If you want faster builds specially with the LLVM) + +** LLVM Installation + MLIR is a part of the [[https://llvm.org][LLVM]] project and in order to build it we need to build the LLVM itself as well. + Here is a quick guide to build the latest version of the LLVM and MLIR. + + #+BEGIN_SRC bash + ## YES we're using the development version of MLIR + git clone https://github.com/llvm/llvm-project.git + + mkdir llvm-project/build + cd llvm-project/build + + cmake -G Ninja ../llvm \ + -DCMAKE_INSTALL_PREFIX=/your/target/path \ + -DLLVM_PARALLEL_COMPILE_JOBS=7 \ + -DLLVM_PARALLEL_LINK_JOBS=1 \ + -DLLVM_BUILD_EXAMPLES=ON \ + -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_CCACHE_BUILD=ON \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;compiler-rt' \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DLLVM_ENABLE_LLD=ON + + cmake --build . --target check-mlir + + cmake -DCMAKE_INSTALL_PREFIX=/your/target/location -P cmake_install.cmake + #+END_SRC + + You need to have =clang= and =lld= installed to compile the LLVM with the above command. Also if you + are not using =ccache= just remove the option related to it from the above command. *** Emacs -Install the dependencies including ~clangd~ and just run ~lsp~ + If you're using Emacs as your development environment just install =clangd= and =lsp=. + + + +* How to build +In order to build for development (Debug mode) just use =./builder build= to setup the build and build +the project once and then you can just use =./builder compile= to build the changed files only. + +Check out the =builder= script for more subcommands and details. + +* Get Help + If you need help or you just want to hangout, you can find us at: + + - *IRC*: *#serene-lang* on the freenode server + + - *Matrix Network*: https://matrix.to/#/#serene:matrix.org?via=matrix.org&via=gitter.im + + - *MailingList*: https://www.freelists.org/list/serene diff --git a/builder b/builder index cfca919..698d4dd 100755 --- a/builder +++ b/builder @@ -84,15 +84,9 @@ function tests() { case "$command" in - # We need to fix this to have some instructions about how to build the dependencies - "deps") - echo "You need the following dependencies" - echo "sudo apt update" - echo "sudo apt install -y llvm-10 llvm-10-tools clang-10 clang-format-10 clang-tidy-10 clang-tools-10 valgrind cmake ninja-build doxygen" - ;; "setup") pushd ./scripts - ./scripts/git-pre-commit-format install + ./git-pre-commit-format install popd ;; "build") @@ -165,6 +159,7 @@ case "$command" in echo "build - Build Serene from scratch in DEBUG mode." echo "build-release - Build Serene from scratch in RELEASE mode." echo "compile - reCompiles the project using the already exist cmake configuration" + echo "compile-and-tests - reCompiles the project using the already exist cmake configuration and runs the tests" echo "run - Runs the serene executable" echo "scan-build - Compiles serene with static analyzer" echo "tests - Runs the test cases" diff --git a/tests/serenetests.cpp b/tests/serenetests.cpp index 9eea61a..9ddfc13 100644 --- a/tests/serenetests.cpp +++ b/tests/serenetests.cpp @@ -27,4 +27,5 @@ #include "./exprs/number_tests.cpp.inc" #include "./exprs/symbol_tests.cpp.inc" #include "./reader/reader_tests.cpp.inc" +#include "./utils_tests.cpp.inc" #include "catch2/catch.hpp" diff --git a/tests/utils.cpp.inc b/tests/utils_tests.cpp.inc similarity index 93% rename from tests/utils.cpp.inc rename to tests/utils_tests.cpp.inc index 2cee13c..32e407c 100644 --- a/tests/utils.cpp.inc +++ b/tests/utils_tests.cpp.inc @@ -30,5 +30,10 @@ TEST_CASE("Result Type", "[utils]") { REQUIRE(r == true); CHECK(r.getValue() == 4); + + auto r1 = Result::Error('c'); + + REQUIRE_FALSE(r1); + CHECK(r1.getError() == 'c'); }; } // namespace serene