Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273package com.microchip.mplab.progcli;
import java.io.File;
/** * Resolves CMSIS pack repository locations so the Java engine reads packs from * wherever {@code mplabx packs install} writes them. * * Resolution order deliberately mirrors src/packs.zig: * user repo : -Dpackslib.userpacksfolder -> $MPLABX_PACKS_DIR -> ~/.mchp_packs * system repo : -Dpackslib.packsfolder -> $MPLABX_SYSTEM_PACKS_DIR -> (unset) * * Stock ipecmd derived these from the ipecmd.jar install path, which tied the * engine to a full MPLAB X installation. Nothing here touches the network or * installs packs; acquisition is the Zig pack manager's job. */public final class PackPaths { public static final String USER_PACKS_PROPERTY = "packslib.userpacksfolder"; public static final String SYSTEM_PACKS_PROPERTY = "packslib.packsfolder"; public static final String THIRDPARTY_PROPERTY = "mplabx.thirdparty.lib.path";
private PackPaths() { }
/** Populates the system properties the crownking/packslib code reads. */ public static void install() { String userRepo = userRepo(); if (userRepo != null) { System.setProperty(USER_PACKS_PROPERTY, userRepo); }
String systemRepo = systemRepo(); if (systemRepo != null) { System.setProperty(SYSTEM_PACKS_PROPERTY, systemRepo); }
String thirdparty = firstNonEmpty(System.getProperty(THIRDPARTY_PROPERTY), System.getenv("MPLABX_THIRDPARTY_DIR")); if (thirdparty != null) { System.setProperty(THIRDPARTY_PROPERTY, thirdparty); } }
/** User pack repository, i.e. the directory {@code mplabx packs install} populates. */ public static String userRepo() { String explicit = firstNonEmpty(System.getProperty(USER_PACKS_PROPERTY), System.getenv("MPLABX_PACKS_DIR")); if (explicit != null) { return explicit; }
String home = System.getProperty("user.home"); if (home == null || home.isEmpty()) { return null; }
return home + File.separator + ".mchp_packs"; }
/** Optional read-only system pack repository (an MPLAB X install's packs/ dir). */ public static String systemRepo() { return firstNonEmpty(System.getProperty(SYSTEM_PACKS_PROPERTY), System.getenv("MPLABX_SYSTEM_PACKS_DIR")); }
private static String firstNonEmpty(String... values) { for (String value : values) { if (value != null && !value.trim().isEmpty()) { return value; } }
return null; }}