Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#!/bin/sh# Assemble the bundled Java runtime (lib/) from an MPLAB X installation.## Usage: ./assemble-lib.sh <path-to-mplabx-vX.YY># e.g. ./assemble-lib.sh /opt/microchip/mplabx/v6.35## Copies every jar from the mdbcore / mplablibs / mplab_ipe / platform# clusters except those listed in jars.exclude.## IMPORTANT: the directory structure *under* mplab_platform/ is preserved.# MPLAB's jars rely on relative Class-Path manifest entries# (e.g. "ext/crownking.edc.jar", "../mplablibs/modules/ext/...") and the# NetBeans module locator derives cluster locations from those paths, so a# flat jar dump does not work.
set -eu
MPLABX="${1:?usage: assemble-lib.sh <path-to-mplabx-vX.YY>}"PLATFORM="$MPLABX/mplab_platform"HERE="$(cd -P -- "$(dirname -- "$0")" && pwd)"LIB="$HERE/lib"
[ -d "$PLATFORM" ] || { echo "not an MPLAB X install: $MPLABX" >&2; exit 1; }
EXCLUDE="$(sed 's/#.*//' "$HERE/jars.exclude" | tr -d ' \t' | grep -v '^$' | sort -u)"
rm -rf "$LIB"mkdir -p "$LIB"
copied=0skipped=0# Copy jars (respecting the exclude list) and every non-jar resource file.# Non-jar resources matter: e.g. mplablibs/modules/ext/mplabinfo.properties# carries the MPLAB X version that pack/device resolution requires, and it is# located as a sibling of mplabinfo.jar via the code-source path.## NUL-safe: some resources (readmes) contain spaces in their names.find "$PLATFORM/mdbcore" "$PLATFORM/mplablibs" "$PLATFORM/mplab_ipe" \ "$PLATFORM/platform" -type f -print0 \| sort -z \| while IFS= read -r -d '' f; do base="$(basename "$f")" case "$f" in *.jar) if echo "$EXCLUDE" | grep -qxF "$base"; then skipped=$((skipped + 1)) continue fi ;; esac
# Preserve path relative to mplab_platform/ (e.g. mplablibs/modules/ext/...). rel="${f#"$PLATFORM"/}" mkdir -p "$LIB/$(dirname "$rel")" cp "$f" "$LIB/$rel" copied=$((copied + 1))done
copied=$(find "$LIB" -type f | wc -l | tr -d ' ')jars=$(find "$LIB" -name '*.jar' | wc -l | tr -d ' ')printf 'lib/: %d files (%d jars), %s total\n' \ "$copied" "$jars" "$(du -sh "$LIB" | cut -f1)"