Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions tools/mcpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,40 @@ export default class extends TOOL {
if (this.platform)
throw new Error("-p '" + name + "': too many platforms!");
name = name.toLowerCase();
let parts = name.split("/");

const slashIndex = name.indexOf("/"), colonIndex = name.indexOf(":");
const splitOn = ((colonIndex > 0) && ((slashIndex < 0) || (colonIndex < slashIndex))) ? ":" : "/";
const parts = name.split(splitOn);
if ("esp8266" === parts[0])
parts[0] = "esp";
else if ((parts[0] == "sim") || (parts[0] == "simulator"))
parts[0] = this.currentPlatform;
this.platform = parts[0];
if (parts[1]) {
this.subplatform = parts[1];
this.environment.SUBPLATFORM = this.subplatform;
this.fullplatform = this.platform + "/" + this.subplatform;
if ("/" === splitOn) {
this.subplatform = parts[1];
this.environment.SUBPLATFORM = this.subplatform;
this.environment.SUBPLATFORMDIRECTORY = this.buildPath + this.slash + "devices" + this.slash + this.platform + this.slash + "targets" + this.slash + this.subplatform;
this.environment.SUBPLATFORMMANIFEST = this.environment.SUBPLATFORMDIRECTORY + this.slash + "manifest.json";
this.fullplatform = this.platform + "/" + this.subplatform;
}
else if (":" === splitOn) {
let dir = parts[1];
if (dir.startsWith("~" + this.slash) && this.getenv("HOME"))
dir = dir.replace("~", this.getenv("HOME"));
this.environment.SUBPLATFORMDIRECTORY = this.resolveDirectoryPath(dir);
this.environment.SUBPLATFORMMANIFEST = this.environment.SUBPLATFORMDIRECTORY + this.slash + "manifest.json";
try {
const manifest = JSON.parse(this.readFileString(this.environment.SUBPLATFORMMANIFEST));
this.subplatform = manifest.build?.SUBPLATFORM ?? this.environment.SUBPLATFORMDIRECTORY.split(this.slash).at(-1);
}
catch {
throw new Error("invalid subplatform manfest path: " + parts[1]);
}

this.environment.SUBPLATFORM = this.subplatform;
this.fullplatform = this.platform + "/" + this.subplatform;
}
this.environment.PLATFORMPATH = this.platform + this.slash + this.subplatform;
}
else {
Expand Down