Before we dive into writing transformations, let's get the computo
command-line interface (CLI) tool built and running on your local machine. Because Computo depends on the Permuto library, we will follow a two-stage process: first building and installing Permuto, then building Computo itself.
This guide uses a standard C++/CMake build process that will be familiar to most developers.
You will need a C++17 compatible compiler, CMake, and Git. The development headers for the nlohmann/json
library are also required.
nlohmann/json
development files.On a Debian/Ubuntu-based system, you can install the necessary dependencies with:
sudo apt-get update
sudo apt-get install build-essential cmake git nlohmann-json3-dev
Computo uses Permuto for its powerful templating capabilities, so we must install it first.
git clone https://github.com/your-username/permuto.git
cd permuto
(Note: Replace your-username/permuto.git
with the actual repository URL.)
We'll create a Release
build for optimal performance.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
This will compile the Permuto library and its own CLI tool.
Now, install the library to a standard system location (typically /usr/local/lib
and /usr/local/include
). This step makes it discoverable by other projects, like Computo.
# From within the 'permuto' directory
sudo cmake --install build
With Permuto installed, your system is now ready to build Computo.
Now we'll repeat a similar process for the computo
project.
If you are still in the permuto
directory, navigate out of it first (cd ..
).
git clone https://github.com/your-username/computo.git
cd computo
CMake will now automatically find the Permuto library and headers you installed in the previous step.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
This command compiles the Computo library and the computo
CLI tool. The final executable will be placed in the build/
directory.
For convenience, install the computo
CLI tool to a standard system location so you can run it from anywhere without specifying the full path.
# From within the 'computo' directory
sudo cmake --install build
Alternatively, for a stripped (smaller) binary:
sudo cmake --install build --strip
This installs the computo
executable to /usr/local/bin
(or your system's standard binary location), making it available system-wide.
You can verify that everything works by running the CLI tool or its test suite.
To check the CLI: If you installed computo system-wide, you can now run it from anywhere. Try running it with no arguments to see the usage message.
computo
If you haven't installed it yet, you can still test it from the build directory:
./build/computo
To run the test suite: The project includes a comprehensive set of tests. Running them confirms that Computo, Permuto, and all operators are working correctly together on your system.
# From within the 'computo' directory
cd build
ctest --verbose
You should see output indicating that all 153 tests have passed.
You are now ready to start writing transformations. Your typical workflow will involve:
script.json
file containing your Computo logic.input.json
file with the data you want to transform.Running the transformation from anywhere on your system (assuming you installed computo):
```bash
computo script.json input.json
computo --pretty=2 script.json input.json ```
In the next chapter, we will write our first Computo script and explore its fundamental concepts.