Cpp
This commit is contained in:
parent
3ba98e21ad
commit
7743665917
6
.zshrc
6
.zshrc
@ -51,6 +51,12 @@ if command -v conda >/dev/null 2>&1; then
|
|||||||
[ -f "$CONDA_BASE/etc/profile.d/conda.sh" ] && source "$CONDA_BASE/etc/profile.d/conda.sh"
|
[ -f "$CONDA_BASE/etc/profile.d/conda.sh" ] && source "$CONDA_BASE/etc/profile.d/conda.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 5. R and Rig
|
||||||
|
export RIG_HOME="$PROG_DIR/r"
|
||||||
|
if [ -d "$RIG_HOME/bin" ]; then
|
||||||
|
export PATH="$RIG_HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
# Zoxide
|
# Zoxide
|
||||||
eval "$(zoxide init --cmd cd zsh)"
|
eval "$(zoxide init --cmd cd zsh)"
|
||||||
|
|
||||||
|
|||||||
7
Makefile
7
Makefile
@ -10,6 +10,7 @@ setup:
|
|||||||
bash ./scripts/go.sh
|
bash ./scripts/go.sh
|
||||||
bash ./scripts/rust.sh
|
bash ./scripts/rust.sh
|
||||||
bash ./scripts/python.sh
|
bash ./scripts/python.sh
|
||||||
|
bash ./scripts/r.sh
|
||||||
make clean
|
make clean
|
||||||
make stow
|
make stow
|
||||||
@echo "Full setup completed."
|
@echo "Full setup completed."
|
||||||
@ -45,6 +46,12 @@ rust:
|
|||||||
python:
|
python:
|
||||||
bash ./scripts/python.sh
|
bash ./scripts/python.sh
|
||||||
|
|
||||||
|
r:
|
||||||
|
bash ./scripts/r.sh
|
||||||
|
|
||||||
|
cpp:
|
||||||
|
bash ./scripts/cpp.sh
|
||||||
|
|
||||||
storagebox:
|
storagebox:
|
||||||
bash ./scripts/storagebox.sh
|
bash ./scripts/storagebox.sh
|
||||||
|
|
||||||
|
|||||||
30
scripts/cpp.sh
Normal file
30
scripts/cpp.sh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Path: scripts/cpp.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BLUE='\033[1;34m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
# OS Detection
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
OS=$ID
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Setting up C++ Tooling (LLVM/Clang)...${NC}"
|
||||||
|
|
||||||
|
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
|
||||||
|
sudo pacman -S --noconfirm --needed clang cmake ninja lldb gdb
|
||||||
|
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y clang cmake ninja-build lldb gdb
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN} SUCCESS:${NC} C++ Environment Ready."
|
||||||
|
echo -e " - Compiler: $(clang --version | head -n 1)"
|
||||||
|
echo -e " - Builder: $(cmake --version | head -n 1)"
|
||||||
|
echo -e " - Debugger: $(lldb --version | head -n 1)"
|
||||||
@ -1,43 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
|
||||||
# Path: scripts/node.sh
|
# Path: scripts/node.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
BLUE='\033[1;34m'
|
BLUE='\033[1;34m'
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
GREEN='\033[1;32m'
|
GREEN='\033[1;32m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
# 1. Define Custom Path
|
# 1. Define Custom Path (The Black Box)
|
||||||
export NVM_DIR="$HOME/.programming/node"
|
export NVM_DIR="$HOME/.programming/node"
|
||||||
|
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM)...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM) in ${NVM_DIR}...${NC}"
|
||||||
|
|
||||||
# 2. Install NVM (if missing)
|
# 2. Install NVM (if missing)
|
||||||
if [ ! -d "$NVM_DIR" ]; then
|
if [ ! -d "$NVM_DIR" ]; then
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Installing NVM to custom path...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Installing NVM to custom path...${NC}"
|
||||||
|
|
||||||
# PROFILE=/dev/null prevents the installer from editing your .zshrc/.bashrc
|
# NVM_DIR is exported above, so the install script picks it up automatically.
|
||||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | PROFILE=/dev/null bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | PROFILE=/dev/null bash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Source NVM (Load it into current shell)
|
# 3. Source NVM (Load it into current shell)
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||||
|
|
||||||
# 4. Install Node
|
# 4. Install Node
|
||||||
if command -v nvm &> /dev/null; then
|
if command -v nvm &> /dev/null; then
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Installing LTS...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Installing Node LTS...${NC}"
|
||||||
nvm install --lts
|
|
||||||
|
# --no-progress suppresses the progress bar spam in logs
|
||||||
|
nvm install --lts --no-progress
|
||||||
nvm use --lts
|
nvm use --lts
|
||||||
|
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Installing Global Tools...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Enabling Corepack (pnpm/yarn)...${NC}"
|
||||||
|
|
||||||
# Disable strict error checking for npm global installs (they are noisy)
|
corepack enable
|
||||||
set +e
|
|
||||||
npm install -g pnpm yarn || true
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo -e "${GREEN} LOG: Node setup complete. $(node -v)${NC}"
|
echo -e "${GREEN} LOG: Node setup complete. $(node -v)${NC}"
|
||||||
|
echo -e "${GREEN} LOG: Package Managers: pnpm $(pnpm -v), yarn $(yarn -v)${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${RED} ERROR: NVM failed to load from $NVM_DIR${NC}"
|
echo -e "${RED} ERROR: NVM failed to load from $NVM_DIR${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
104
scripts/r.sh
Normal file
104
scripts/r.sh
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Path: scripts/r.sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BLUE='\033[1;34m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
RED='\033[1;31m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
# OS Detection
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
OS=$ID
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Detecting R installation strategy for $OS...${NC}"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# STRATEGY A: ARCH LINUX (Native Pacman)
|
||||||
|
# Arch always has the latest R kernel. We don't need Rig.
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
|
||||||
|
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Arch Linux detected. Using system R (Pacman)...${NC}"
|
||||||
|
|
||||||
|
# 1. Install R + Build Tools
|
||||||
|
# gcc-fortran is critical for compiling R packages
|
||||||
|
sudo pacman -S --noconfirm --needed r gcc-fortran curl tar
|
||||||
|
|
||||||
|
echo -e "${GREEN} SUCCESS:${NC} R installed via Pacman."
|
||||||
|
|
||||||
|
# Define R binary path for the renv step later
|
||||||
|
R_BIN="R"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# STRATEGY B: UBUNTU/DEBIAN (Rig Version Manager)
|
||||||
|
# These distros have old R versions. We need Rig to get the latest.
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
|
||||||
|
|
||||||
|
# 1. Install Deps
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Installing Debian build dependencies...${NC}"
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y gfortran curl tar
|
||||||
|
|
||||||
|
# 2. Setup Rig Paths
|
||||||
|
export RIG_HOME="$HOME/.programming/r"
|
||||||
|
export RIG_BIN="$RIG_HOME/bin"
|
||||||
|
export PATH="$RIG_BIN:$PATH"
|
||||||
|
|
||||||
|
# 3. Install Rig Binary
|
||||||
|
if [ ! -f "$RIG_BIN/rig" ]; then
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Downloading Rig binary...${NC}"
|
||||||
|
mkdir -p "$RIG_BIN"
|
||||||
|
|
||||||
|
# Robust URL Fetching
|
||||||
|
LATEST_REL_DATA=$(curl -s https://api.github.com/repos/r-lib/rig/releases/latest)
|
||||||
|
RIG_URL=$(echo "$LATEST_REL_DATA" | grep -o 'https://[^"]*rig-linux-[^"]*\.tar\.gz' | head -n 1)
|
||||||
|
|
||||||
|
if [ -z "$RIG_URL" ]; then
|
||||||
|
echo -e "${RED} ERROR:${NC} Could not find Rig download URL."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract to temp
|
||||||
|
TEMP_EXTRACT=$(mktemp -d)
|
||||||
|
curl -L -s "$RIG_URL" | tar -xz -C "$TEMP_EXTRACT"
|
||||||
|
FOUND_BIN=$(find "$TEMP_EXTRACT" -name "rig" -type f | head -n 1)
|
||||||
|
|
||||||
|
if [ -f "$FOUND_BIN" ]; then
|
||||||
|
mv "$FOUND_BIN" "$RIG_BIN/rig"
|
||||||
|
chmod +x "$RIG_BIN/rig"
|
||||||
|
else
|
||||||
|
rm -rf "$TEMP_EXTRACT"; exit 1
|
||||||
|
fi
|
||||||
|
rm -rf "$TEMP_EXTRACT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. Install R via Rig
|
||||||
|
TARGET_VER="release"
|
||||||
|
if ! "$RIG_BIN/rig" list | grep -q "release"; then
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Installing R (${TARGET_VER})...${NC}"
|
||||||
|
sudo "$RIG_BIN/rig" add "$TARGET_VER" --without-cran-mirror
|
||||||
|
sudo "$RIG_BIN/rig" default "$TARGET_VER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define R binary path for the renv step
|
||||||
|
R_BIN="$RIG_BIN/rig run"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# COMMON: RENV (Dependency Management)
|
||||||
|
# This works the same on both systems.
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Installing 'renv' package globally...${NC}"
|
||||||
|
|
||||||
|
# We use a small R script to install renv if missing
|
||||||
|
# Note: On Arch, $R_BIN is just "R". On Ubuntu, it might be "rig run".
|
||||||
|
$R_BIN -e 'if (!require("renv", quietly=TRUE)) install.packages("renv", repos="https://cloud.r-project.org")'
|
||||||
|
|
||||||
|
echo -e "${GREEN} SUCCESS:${NC} R setup completed."
|
||||||
@ -7,21 +7,27 @@ YELLOW='\033[1;33m'
|
|||||||
GREEN='\033[1;32m'
|
GREEN='\033[1;32m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
# 1. Define Custom Paths
|
# 1. Define Custom Paths (The Black Box)
|
||||||
export RUSTUP_HOME="$HOME/.programming/rust/multirust"
|
export RUSTUP_HOME="$HOME/.programming/rust/multirust"
|
||||||
export CARGO_HOME="$HOME/.programming/rust/cargo"
|
export CARGO_HOME="$HOME/.programming/rust/cargo"
|
||||||
|
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Setting up Rust (Rustup)...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Setting up Rust (Rustup) in ${CARGO_HOME}...${NC}"
|
||||||
|
|
||||||
# 2. Install Rustup (if missing)
|
# 2. Install Rustup (if missing)
|
||||||
if [ ! -f "$CARGO_HOME/bin/rustup" ]; then
|
if [ ! -f "$CARGO_HOME/bin/rustup" ]; then
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Installing Rustup to custom path...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Installing Rustup to custom path...${NC}"
|
||||||
|
|
||||||
|
# Create parent dirs to be safe
|
||||||
|
mkdir -p "$RUSTUP_HOME" "$CARGO_HOME"
|
||||||
|
|
||||||
|
# Install: --no-modify-path keeps your .zshrc clean (we manage it manually)
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
|
||||||
else
|
else
|
||||||
echo -e "${GREEN} LOG: Rustup already installed in custom path.${NC}"
|
echo -e "${GREEN} LOG: Rustup already installed in custom path.${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Source Environment
|
# 3. Source Environment
|
||||||
|
# This loads cargo into the PATH for the rest of this script
|
||||||
if [ -f "$CARGO_HOME/env" ]; then
|
if [ -f "$CARGO_HOME/env" ]; then
|
||||||
source "$CARGO_HOME/env"
|
source "$CARGO_HOME/env"
|
||||||
fi
|
fi
|
||||||
@ -31,7 +37,13 @@ if command -v cargo &> /dev/null; then
|
|||||||
echo -e "${BLUE} LOG:${YELLOW} Updating toolchain...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Updating toolchain...${NC}"
|
||||||
rustup default stable
|
rustup default stable
|
||||||
rustup update
|
rustup update
|
||||||
echo -e "${GREEN} LOG: Rust setup complete.$(cargo --version)${NC}"
|
|
||||||
|
# CRITICAL FOR LEARNING: Install source code for the standard library
|
||||||
|
# This allows you to inspect 'std' code in your IDE (VS Code/Neovim)
|
||||||
|
echo -e "${BLUE} LOG:${YELLOW} Installing rust-src for 'Go to Definition'...${NC}"
|
||||||
|
rustup component add rust-src
|
||||||
|
|
||||||
|
echo -e "${GREEN} LOG: Rust setup complete. $(cargo --version)${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${RED} ERROR: Cargo not found in PATH. Check CARGO_HOME.${NC}"
|
echo -e "${RED} ERROR: Cargo not found in PATH. Check CARGO_HOME.${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user