72 lines
3.7 KiB
Bash
Executable File
72 lines
3.7 KiB
Bash
Executable File
#!/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="$exe_dir/$2" && shift && shift; fi
|
|
if [ "$option" = "cmake" ]; then exe_dir="$cmake_dir/$1" && PATH="$exe_dir:$PATH" && cmd_line="$exe_dir/$2" && shift && shift; fi
|
|
if [ "$option" = "node" ]; then exe_dir="$node_dir/$1/bin" && PATH="$exe_dir:$PATH" && cmd_line="$exe_dir/$2" && shift && shift; fi
|
|
if [ "$option" = "python" ]; then exe_dir="$python_dir/$1/install/bin" && PATH="$exe_dir:$PATH" && cmd_line="$exe_dir/$2" && shift && shift; fi
|
|
if [ "$option" = "python_env" ]; then PATH="$python_dir/$1/install/bin:$PATH" && shift && cmd_line="$1" && 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 suffixed with '_env' augment the system PATH with the tool's path for the current shell session.
|
|
You can chain the '_env' commands to augment the PATH, e.g:
|
|
|
|
dev.sh python_env 3.12.9+20250317 dev.sh node 20.18.2 yarn build-everything
|
|
|
|
OPTIONS:
|
|
cmake [version] [exe] CMake build system: '$cmake_dir/[version]/[exe]'
|
|
Versions: $cmake_versions
|
|
|
|
clang [version] [exe] CLANG compiler: '$clang_dir/[version]/[exe]'
|
|
Example: 'dev clang 18.1.4 clang++.exe --help'
|
|
Versions: $clang_versions
|
|
|
|
node [version] [exe] Node JS: '$node_dir/[version]/[exe]'
|
|
Versions: $node_versions
|
|
|
|
python [version] [exe] Python: '$python_dir/[version]/install/bin/[exe]'
|
|
python_env [cmd...] '$python_dir/[version]/install/bin:[PATH]'
|
|
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_line$user_args'"
|
|
eval "$cmd_line$user_args"
|