#!/usr/bin/env bash # ACCEPTANCE TEST: compile the REAL, unmodified DrussGT sources against the # genuine Robocode 1.9.5.5 API (Approach B reuses robocode.jar instead of # re-implementing robocode.*). # # ROBOCODE_JAR=... DRUSSGT_SRC=... DRUSSGT_JAR=... ./compile_drussgt.sh # # Why two source files are excluded: # GFRange.java and Indice.java are *decompilation artefacts*. The same two # classes are ALSO declared inline at the bottom of DrussGunDC.java, so a # single javac invocation over all 22 files fails with # "duplicate class: jk.mega.dGun.GFRange/Indice" even with no shim at all. # The original DrussGT.jar already ships GFRange.class/Indice.class, so we # drop the redundant standalone files and let the jar supply them (together # with the 6 genuinely-unsourced classes: JKDCUtils, NormalDistribution, # StoreScan, DCRobotState, DCWave, Scan). set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}" DRUSSGT_SRC="${DRUSSGT_SRC:-/tmp/drussgt/src}" DRUSSGT_JAR="${DRUSSGT_JAR:-/tmp/drussgt/DrussGT.jar}" OUT="${OUT:-$HERE/out/drussgt}" for f in "$ROBOCODE_JAR" "$DRUSSGT_JAR"; do [[ -f "$f" ]] || { echo "missing: $f" >&2; exit 1; } done [[ -d "$DRUSSGT_SRC" ]] || { echo "missing source dir: $DRUSSGT_SRC" >&2; exit 1; } mkdir -p "$OUT" mapfile -t SRC < <(find "$DRUSSGT_SRC" -name '*.java' ! -name 'GFRange.java' ! -name 'Indice.java' | sort) echo "javac -nowarn -cp \"$ROBOCODE_JAR:$DRUSSGT_JAR\" -d \"$OUT\" <${#SRC[@]} files>" javac -nowarn -cp "$ROBOCODE_JAR:$DRUSSGT_JAR" -d "$OUT" "${SRC[@]}" echo "OK: ${#SRC[@]}/22 source files compiled, $(find "$OUT" -name '*.class' | wc -l) classes emitted" echo "(2/22 excluded as duplicate-class decompilation artefacts; supplied by DrussGT.jar)"