External Dependencies


Following is the list of dependencies you'll need to build the project from the source code.

LLVM 7.0.1

In addition to the dependencies mentioned above, you'll need GCC (version 7 or above) CMake, Python3, and Pip to be able to build the binaries from the source code. LLVM also has its own dependencies like zlib and valgrind for example that you might need to install manually. You'll also need libssl-dev to be able to use https in the Standard Runtime Library.
To install the build tools in Ubuntu use the following command:
$ sudo apt-get install gcc g++ cmake python3 python3-pip zlib1g-dev libssl-dev
For other distros you'll need to check their documentation on how to install these tools. Notice that the build script assumes that the Python executable is named `python3` in the system, which is the case on Ubuntu systems. If you are on other distros you might need to create some sym links or update the `build.sh` script.


Building Using Shell Script


This is the simpler and the recommended method to build.
  • Install build tools as explained in the previous section.
  • Install python3 which is needed by build.sh.
  • cd into the Tools directory and execute build.sh. This script will automatically download the dependencies and build LLVM. Preparing the dependencies will take a long time but this will only occur the first time the script is executed. Running it again will skip that part and jump directly to building Alusus.
    $ cd <path-to-Alusus>
    $ ./Tools/build.sh --bloc . --iloc .
Inside build.sh there are some variables that can be modified. Among those is MAKE_THREAD_COUNT which defines the number of threads to use when building LLVM and Alusus. This is preset to 8 to speed up the build process, but you can lower it if you face problems or if your computer is not capable of handling that much threads efficiently.
If you face problems during the build of LLVM you might need to modify the cmake command inside build.sh by giving it extra arguments, like -DLLVM_TARGET_ARCH.

Building Manually


  • Install build tools as explained in the previous section.
  • Download the source code for the versions mentioned above of LLVM, Boost, and CATCH, and extract their files.
  • Build and install LLVM:
    • Create a build folder with any name. For example: llvm.build.
    • CD into the build folder you created and execute the following command:
      $ cmake <path-to-LLVM-source> -DCMAKE_INSTALL_PREFIX=<path-to-install-dest>
      You might also need to manually specify your architecture by setting a value for LLVM_TARGET_ARCH. For example, to specify the architecture under a 32 bit environment use the following command instead of the one above:
      $ cmake <path-to-LLVM-source> -DCMAKE_INSTALL_PREFIX=<path-to-install-dest> -DLLVM_TARGET_ARCH=i386
      and to specify it for a 64 bit environment use the following:
      $ cmake <path-to-LLVM-source> -DCMAKE_INSTALL_PREFIX=<path-to-install-dest> -DLLVM_TARGET_ARCH=x86_64
    • Complete the build and install:
      $ make
      $ make install
  • Build Alusus:
    • Created a build folder and name it anything. For example, Builds.
    • CD into that folder and complete the build:
      $ cd <path-to-Builds>
      $ cmake <path-to-Alusus-root>/Sources -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=<path-to-Alusus-root> -DLLVM_PATH=<path-to-LLVM-install>
      $ make
      $ make install
      The last statement (make install) will install the build results into folders Bin, Lib, and Include under Alusus' root folder, which is mentioned above in CMAKE_INSTALL_PREFIX cmake parameter, and not to the operating system's paths. You can choose a different folder as an installation target like /opt/Alusus by changing the value for CMAKE_INSTALL_PREFIX. The above cmake command prepares for a debug build. To change to a release build replace the value of CMAKE_BUILD_TYPE with release instead of debug.

Executing Automated Tests


Executing the automated tests is simple. All you need to do is to run the following command inside the Alusus' build folder (Builds in the example above) after the build is complete:
$ make test

Using Alusus


After the build is complete you'll have the executable under Bin and the libraries will go under Lib. You'll be able to run the examples as follows:
$ export PATH=<path-to-Alusus>/Bin:$PATH
$ cd <path-to-Alusus>/Examples
$ alusus hello_world.alusus
The Core's executalbe's name when building in debug mode will be alusus.dbg. If the build is in release mode the name will be alusus, i.e. without the dbg extension.

If the Core is built in debug mode logging can be enabled using the --log command line argument, which accepts a number representing the details level of the log as in the following example:

$ alusus helloworld.alusus --log 16
The details level is determined through binary flags representing each different details level with the least significant bit representing the lowest level. A value of 1 for each level means details for that level will be logged to the screen. The following table explains the different levels:
Lexer, low level = 1
Lexer, mid level = 2
Lexer, high level = 4
Parser, low level = 8
Parser, mid level = 16
Parser, high level = 32
The flags can be combined to display more than one level at the same time. For example, a value of 7 means logging all levels for the lexer.