More cleanup
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setup ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
script_path=$0
|
||||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
root_dir="${devenver_root}"
|
||||
|
||||
# Arguments ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
clang_dir="$root_dir/LLVM"
|
||||
cmake_dir="$root_dir/CMake"
|
||||
node_dir="$root_dir/NodeJS"
|
||||
python_dir="$root_dir/Python"
|
||||
virustotal_url="https://www.virustotal.com/gui/file"
|
||||
|
||||
# Argument parsing :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
option="$1"
|
||||
shift
|
||||
|
||||
if [ "$option" = "clang" ]; then exe_dir="$clang_dir/$1/bin" && PATH="$exe_dir:$PATH" && cmd_line="$2" && shift && shift; fi
|
||||
if [ "$option" = "cmake" ]; then exe_dir="$cmake_dir/$1" && PATH="$exe_dir:$PATH" && cmd_line="$2" && shift && shift; fi
|
||||
if [ "$option" = "node" ]; then exe_dir="$node_dir/$1/bin" && PATH="$exe_dir:$PATH" && cmd_line="$2" && shift && shift; fi
|
||||
if [ "$option" = "python" ]; then
|
||||
python_root=$python_dir/$1/install
|
||||
# Shit like building UWSGI in Python via PIP with wheel doesn't seem to use
|
||||
# LD_LIBRARY_PATH but LDFLAGS works. Dependency hell
|
||||
cmd_prefix="LDFLAGS=${python_root}/lib LD_LIBRARY_PATH=$python_root/lib:$LD_LIBRARY_PATH PYTHONHOME=$python_root"
|
||||
exe_dir="$python_root/bin"
|
||||
PATH="$exe_dir:$PATH"
|
||||
cmd_line="$2"&& shift && shift;
|
||||
fi
|
||||
if [ "$option" = "virustotal" ]; then virustotal_hash=$(sha256sum "$1" | awk '{print $1}') && cmd_line="xdg-open $virustotal_url/$virustotal_hash &" && shift; fi
|
||||
|
||||
if [ -z "$cmd_line" ]; then option="help"; fi
|
||||
if [ "$option" = "help" ]; then
|
||||
clang_versions=$(ls -1 "$clang_dir" 2>/dev/null | tr '\n' ' ')
|
||||
cmake_versions=$(ls -1 "$cmake_dir" 2>/dev/null | tr '\n' ' ')
|
||||
node_versions=$(ls -1 "$node_dir" 2>/dev/null | tr '\n' ' ')
|
||||
python_versions=$(ls -1 "$python_dir" 2>/dev/null | tr '\n' ' ')
|
||||
cat << EOF
|
||||
USAGE: dev [option] [args...]
|
||||
|
||||
NOTES:
|
||||
Commands augment the system PATH with the tool's path for the current shell session.
|
||||
You can chain the commands to augment the PATH, e.g:
|
||||
|
||||
dev.sh python 3.12.9+20250317 dev.sh node 20.18.2 yarn build-everything
|
||||
|
||||
OPTIONS:
|
||||
cmake [version] [cmd...] CMake build system: 'PATH=$cmake_dir/[version]:\$PATH [cmd...]'
|
||||
Versions: $cmake_versions
|
||||
|
||||
clang [version] [cmd..] CLANG compiler: 'PATH=$clang_dir/[version]:\$PATH [cmd...]'
|
||||
Example: 'dev clang 18.1.4 clang++.exe --help'
|
||||
Versions: $clang_versions
|
||||
|
||||
node [version] [cmd...] Node JS: 'PATH=$node_dir/[version]:\$PATH [cmd...]'
|
||||
Versions: $node_versions
|
||||
|
||||
python [version] [cmd...] Python: 'PATH=$python_dir/[version]/install/bin:\$PATH [cmd...]'
|
||||
Versions: $python_versions
|
||||
|
||||
virustotal [file] Lookup file SHA256 hash on VirusTotal: '$virustotal_url/[file]'
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extract user arguments ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
user_args=""
|
||||
while [ $# -gt 0 ]; do user_args="$user_args $1"; shift; done
|
||||
|
||||
# Trim trailing space ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
while [ "${user_args: -1}" = " " ]; do user_args="${user_args% }"; done
|
||||
while [ "${cmd_line: -1}" = " " ]; do cmd_line="${cmd_line% }"; done
|
||||
|
||||
# Eval ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
echo "DEV: Running '$script_path' with '$cmd_prefix $cmd_line$user_args'"
|
||||
eval "$cmd_prefix $cmd_line$user_args"
|
||||
Reference in New Issue
Block a user