Skip to content

Commit

Permalink
Add prebuild linux script
Browse files Browse the repository at this point in the history
  • Loading branch information
alisomay committed Nov 3, 2023
1 parent 2769fe4 commit 0d37f31
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ exclude = [
cpal = { git = "https://github.com/RustAudio/cpal.git", features = ["asio"] }
midir = { version = "0.9", features = ["winrt"] }

[target.'cfg(target_os = "linux")'.dependencies]
cpal = { git = "https://github.com/RustAudio/cpal.git", features = ["jack"] }
midir = { version = "0.9", features = ["jack"] }

# [target.'cfg(target_os = "windows")'.dependencies]
# cpal = { version = "0.15", features = ["asio"] }
# midir = { version = "0.9", features = ["winrt"] }

# [target.'cfg(target_os = "linux")'.dependencies]
# cpal = { version = "0.15", features = ["jack"] }
# midir = { version = "0.9", features = ["jack"] }

[dependencies]
midir = "0.9"
clap = { version = "4", features = ["derive", "env"] }
Expand Down
2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ install-win:
cargo build --release
Copy-Item -Path {{ justfile_directory() }}\target\release\smrec.exe -Destination {{ env_var_or_default("USERPROFILE", "") }}\.cargo\bin\

prepare-linux:
./pre-build-linux.sh
63 changes: 63 additions & 0 deletions pre-build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Determine the package manager
if command -v apt-get >/dev/null 2>&1; then
PACKAGE_MANAGER="apt-get"
elif command -v dnf >/dev/null 2>&1; then
PACKAGE_MANAGER="dnf"
elif command -v yum >/dev/null 2>&1; then
PACKAGE_MANAGER="yum"
elif command -v zypper >/dev/null 2>&1; then
PACKAGE_MANAGER="zypper"
elif command -v pacman >/dev/null 2>&1; then
PACKAGE_MANAGER="pacman"
else
echo "Unsupported package manager. Exiting."
exit 1
fi

# Define the package names
if [[ "$PACKAGE_MANAGER" == "apt-get" ]]; then
ALSA_PACKAGE="libasound2-dev"
JACK_PACKAGE="libjack-jackd2-dev"
elif [[ "$PACKAGE_MANAGER" == "dnf" || "$PACKAGE_MANAGER" == "yum" ]]; then
ALSA_PACKAGE="alsa-lib-devel"
JACK_PACKAGE="jack-audio-connection-kit-devel"
elif [[ "$PACKAGE_MANAGER" == "zypper" ]]; then
ALSA_PACKAGE="alsa-devel"
JACK_PACKAGE="jack-devel"
elif [[ "$PACKAGE_MANAGER" == "pacman" ]]; then
ALSA_PACKAGE="alsa-lib"
JACK_PACKAGE="jack"
fi

# Update package lists for the latest version of the repository
if [[ "$PACKAGE_MANAGER" == "pacman" ]]; then
echo "Updating package databases..."
sudo pacman -Syq --noconfirm || {
echo "Updating package databases failed. Exiting."
exit 1
}
else
echo "Updating package lists..."
sudo $PACKAGE_MANAGER update -yq || {
echo "Updating package lists failed. Exiting."
exit 1
}
fi

# Install necessary packages for ALSA
echo "Installing ALSA development files..."
sudo $PACKAGE_MANAGER install -yq $ALSA_PACKAGE || {
echo "Installing ALSA development files failed. Exiting."
exit 1
}

# Install necessary packages for JACK
echo "Installing JACK development files..."
sudo $PACKAGE_MANAGER install -yq $JACK_PACKAGE || {
echo "Installing JACK development files failed. Exiting."
exit 1
}

echo "Build environment preparation complete."

0 comments on commit 0d37f31

Please sign in to comment.