Files
muscl/docs/compiling.md
h7x4 7445ed70b1
Some checks failed
Build and test / check-license (push) Successful in 1m51s
Build and test / check (push) Successful in 1m54s
Build and test / test (push) Has been cancelled
Build and test / docs (push) Has been cancelled
Build and test / build (push) Has been cancelled
docs/compiling: init
2025-12-16 14:53:50 +09:00

2.2 KiB

Compiling

This document describes how to compile muscl from source code, along with other related tasks.

Build

To just compile muscl, there is not many special steps needed. You need to have a working Rust toolchain installed.

# Compile in debug mode
cargo build
ls target/debug/muscl
ls target/debug/mysql-dbadm
ls target/debug/mysql-useradm

# Compile in release mode
cargo build --release
ls target/release/muscl
ls target/debug/mysql-dbadm
ls target/debug/mysql-useradm

# Compile in release mode with link time optimization (only used for distribution builds)
cargo build --profile release-lto
ls target/release-lto/muscl
ls target/debug/mysql-dbadm
ls target/debug/mysql-useradm

Generating completions

Note

This happens automatically when building the deb package, so you can skip this step if that's the goal.

In order to generate shell completions that work correctly, you want to put muscl (or alias symlinks) in your $PATH.

cargo build --release
(
  PATH="$(pwd)/target/release:$PATH"
  mkdir -p completions/bash
  mkdir -p completions/zsh
  mkdir -p completions/fish

  muscl completions --shell bash > completions/bash/muscl.bash
  muscl completions --shell zsh > completions/zsh/_muscl
  muscl completions --shell fish > completions/fish/muscl.fish
)

Due to a bug in clap, you will also need to edit the completion files for the aliases.

sed -i 's/muscl/mysql-dbadm/g' assets/completions/{mysql-dbadm.bash,mysql-dbadm.fish,_mysql-dbadm}
sed -i 's/muscl/mysql-useradm/g' assets/completions/{mysql-useradm.bash,mysql-useradm.fish,_mysql-useradm}

Bundling into a deb package

We have a script that automates the process of building a deb package for Debian-based systems.

Before running this, you will need to install cargo-deb and make sure you have dpkg-deb available on your system.

# Install cargo-deb if you don't have it already
cargo install cargo-deb

# Run the script to create the deb package
./create-deb.sh

# Inspect the resulting deb package
dpkg --contents target/debian/muscl_*.deb
dpkg --info target/debian/muscl_*.deb

The program will be built with the release-lto profile, so it can be a bit slower to build than a normal build.