Skip to content

Latest commit

 

History

History
133 lines (85 loc) · 2.4 KB

File metadata and controls

133 lines (85 loc) · 2.4 KB

Installing Cx

This guide will help you build and install the Cx compiler from source.

Prerequisites

To build Cx, you need the following tools installed on your system:

  1. LDC2 (The LLVM D Compiler)
  2. DUB (The D package manager)
  3. A C Compiler (GCC or Clang, used by Cx to compile the final output)

Installing Prerequisites

Ubuntu / Debian:

sudo apt update
sudo apt install ldc dub gcc

Arch Linux:

sudo pacman -S ldc dub gcc

Fedora:

sudo dnf in ldc dub gcc

Quick Installation

The repository includes an automated build script that handles dependency checking, compilation, and installation.

  1. Clone the repository:
git clone https://github.com/FernandoTheDev/cx.git
cd cx
  1. Run the build script:
./build.sh

This script will:

  • Verify that ldc2 and dub are installed.
  • Build the compiler in release mode.
  • Copy the cx binary to ~/.local/bin/.
  • Install the standard library to ~/.cx/std/.
  1. Add ~/.local/bin to your PATH (if not already added):
  • Bash: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
  • Zsh: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
  • Fish: fish_add_path $HOME/.local/bin
  1. Verify the installation:
cx -v

Expected output: Cx Compiler - Version (0.x.x)


Manual Installation (Advanced)

If you prefer not to use the automated script, you can build and install manually:

  1. Build the release binary:
dub build --compiler=ldc2 --build=release
  1. Move the binary to your local bin directory:
mkdir -p ~/.local/bin
cp ./cx ~/.local/bin/
  1. Copy the standard library:
mkdir -p ~/.cx
cp -r ./std ~/.cx/std

Updating Cx

Cx has a built-in update mechanism. To check for and install the latest version, simply run:

cx update

Running Tests

To ensure everything is working correctly on your machine, you can run the compiler's test suite:

rdmd tests/unit.d

This will compile and execute all examples in the examples/ directory, verifying both the exit codes and the standard output.


Uninstalling

To completely remove Cx from your system:

rm ~/.local/bin/cx
rm -rf ~/.cx

(Don't forget to remove the PATH export from your ~/.bashrc or ~/.zshrc if you added it).