Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to cargo binaries #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/modules/rust.eselect
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ get_last_set_symlinks() {
}

#get lists of symlinks
get_symlinks() {
get_provider_symlinks() {
local target=$1
if [ "${target}" == "NOT_SET" ]; then
echo /usr/bin/rustdoc
Expand All @@ -81,6 +81,21 @@ get_symlinks() {
echo "${symlinks[@]}"
}

#get lists of symlinks for cargo binaries
get_binaries_symlinks() {
if is_number "${target}"; then
local targets=( $(find_targets) )
target=${targets[target]}
fi

local symlinks=()
for package in /etc/env.d/rust/*binaries-${target}; do
symlinks+=$(get_symlinks_from_file "${EROOT}${package}")
done
echo "${symlinks[@]}"
}


# remove symlink if exists
remove_symlink() {
local symlink=$1
Expand Down Expand Up @@ -143,14 +158,21 @@ set_version() {

set_symlink "${EROOT}/usr/bin/rustc-${target_postfix}" "${EROOT}/usr/bin/rustc"

local symlinks=( $(get_symlinks ${target}) )
for i in "${symlinks[@]}"; do
local target_symlinks=( $(get_provider_symlinks ${target}) )
for i in "${target_symlinks[@]}"; do
set_symlink "${EROOT}${i}-${target_postfix}" "${EROOT}${i}"
done

cp "${EROOT}/etc/env.d/rust/provider-${target}" \
"${EROOT}/etc/env.d/rust/last-set" || \
die -q "symlink list copying failed"

local binaries_symlinks=( $(get_binaries_symlinks ${target}) )
for i in "${binaries_symlinks[@]}"; do
set_symlink "${EROOT}/usr/lib/rust-${target_postfix}/bin/$(basename ${i})" "${EROOT}${i}"
echo "${i}" >> "${EROOT}/etc/env.d/rust/last-set" || \
die -q "binary symlink list copying failed"
done
}

### list action ###
Expand Down