Build scripts depends on GIT tags to determine the version number. If you copy the source files outside the GIT repository and build from there you'll get a version number of 0.0.0-DEV.
You can build Alusus on Linux or macOS. For Linux any distro can be used as long as it includes version 7 or higher of GCC. For macOS we tested building on macOS 10.13 with Xcode 9.3. It might be possible to build on older versions, but we haven't tested that.
External Dependencies
You'll need GCC (version 7 or above) CMake, Python3, Pip, and vcpkg to be able to build the binaries from the source code.
To install the build tools in Ubuntu use the following command:
$ sudo apt-get install cmake build-essential python3 python3-pip pkg-config
For other distros you'll need to check their documentation on how to install these tools.
To install vcpkg follow these steps:
$ git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
$ cd "$HOME/vcpkg"
$ chmod +x bootstrap-vcpkg.sh
$ ./bootstrap-vcpkg.sh
You can install vcpkg in any location and not necessarily "$HOME/vcpkg". After installing vcpkg you'll need to define an environment variable named ALUSUS_VCPKG_REPO_PATH containing the path to vcpkg:
$ export ALUSUS_VCPKG_REPO_PATH="$HOME/vcpkg"
If you also want to generate install packages you'll need to install
fpm, as well as 7zip. On Ubuntu:
$ sudo apt install p7zip-full ruby rpm libarchive-tools
$ sudo gem install --no-document fpm
You'll need GCC version 7 or newer. You won't be able to build Alusus code with older versions. You also need version 3.20 or higher of cmake.
Starting the Build
After installing the dependencies all you need to do is to launch
build.sh, which will do the following:
- Download and build LLVM, if not already built.
- Download and build libcurl, if not already built.
- Download and build kubazip, if not already built.
- Build Alusus.
- Generate install package(s) if requested.
Running the build script for the first time will take a long time to build all the dependencies (especially LLVM), but subsequent builds will not need to rebuild dependencies and therefore will be much faster. Launching the build script can be done as follows:
$ cd <path-to-Alusus>
$ ./Tools/build.sh
You can pass different options to build.sh to control the build like deciding build type, build location, requesting instlal packages, etc. You can pass the --help option to view all available options. For example, to make a release build with install packages:
$ cd <path-to-Alusus>
$ ./Tools/build.sh --build-type release --build-packages
Executing Automated Tests
Executing the automated tests is simple. All you need to do is to run the following command inside Alusus' build folder (AlususBuild/Intermediate/x64-linux-release in the example above) after the build is complete:
$ cd <path-to-Alusus>/AlususBuild/Intermediate/x64-linux-release
$ ctest
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 Alusus 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.dbg --log 16 helloworld.alusus
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
Preprocessing = 64
Code generation = 128
Generating LLVM IR = 256
LLVM diagnostics = 512
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.