#!/bin/bash
# Initialize the supplied contest workspace once, also after a team-home reset.
set -eu
export PATH="/usr/local/lib/acpc-toolchain:$PATH"
workspace="$HOME/eclipse-workspace"
mkdir -p "$workspace"
if [ ! -f "$workspace/.acpc-imported" ]; then
    /opt/eclipse/eclipse -nosplash -data "$workspace" \
        -application org.eclipse.cdt.managedbuilder.core.headlessbuild \
        -import "$HOME/contest" -no-indexer > "$workspace/import.log" 2>&1
    touch "$workspace/.acpc-imported"
fi
exec /opt/eclipse/eclipse -data "$workspace" "$@"
