mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 06:16:33 +00:00
Adapted to latest CLI.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
e636e06a7e
commit
9f7aec4091
@ -43,42 +43,22 @@ export class ArduinoCli {
|
||||
throw new Error(stderr);
|
||||
}
|
||||
|
||||
// const { sketchbook_path: sketchDirPath, arduino_data: dataDirPath } = JSON.parse(raw);
|
||||
const { sketchbook_path, arduino_data } = JSON.parse(stdout.trim());
|
||||
|
||||
// https://github.com/arduino/arduino-cli/issues/342
|
||||
// XXX: this is a hack. The CLI provides a non-valid JSON.
|
||||
const config: Partial<Config> = {};
|
||||
const raw = stdout.trim();
|
||||
for (const line of raw.split(/\r?\n/) || []) {
|
||||
// TODO: Named capture groups are avail from ES2018.
|
||||
// const pair = line.match(/(?<key>[^:]+):(?<value>[^,]+),?/);
|
||||
const index = line.indexOf(':');
|
||||
if (index !== -1) {
|
||||
const key = line.substr(0, index).trim();
|
||||
const value = line.substr(index + 1, line.length).trim();
|
||||
if (!!key && !!value) {
|
||||
if (key === 'sketchbook_path') {
|
||||
config.sketchDirUri = FileUri.create(value).toString();
|
||||
} else if (key === 'arduino_data') {
|
||||
config.dataDirUri = FileUri.create(value).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.dataDirUri) {
|
||||
reject(new Error(`Could not parse config. 'arduino_data' was missing from: ${stdout}`));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.sketchDirUri) {
|
||||
if (!sketchbook_path) {
|
||||
reject(new Error(`Could not parse config. 'sketchbook_path' was missing from: ${stdout}`));
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.info(`Retrieved the default configuration from the CLI: ${JSON.stringify(config)}`);
|
||||
if (!arduino_data) {
|
||||
reject(new Error(`Could not parse config. 'arduino_data' was missing from: ${stdout}`));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({ sketchDirUri: config.sketchDirUri, dataDirUri: config.dataDirUri });
|
||||
resolve({
|
||||
sketchDirUri: FileUri.create(sketchbook_path).toString(),
|
||||
dataDirUri: FileUri.create(arduino_data).toString()
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export class ArduinoDaemon implements BackendApplicationContribution {
|
||||
if (!this.cliContribution.debugCli) {
|
||||
const executable = await this.cli.getExecPath();
|
||||
this.logger.info(`>>> Starting 'arduino-cli' daemon... [${executable}]`);
|
||||
const daemon = exec(`${executable} --debug daemon`, (err, stdout, stderr) => {
|
||||
const daemon = exec(`${executable} daemon -v --log-level info --format json`, (err, stdout, stderr) => {
|
||||
if (err || stderr) {
|
||||
console.log(err || new Error(stderr));
|
||||
return;
|
||||
|
@ -51,6 +51,9 @@ export class CompileReq extends jspb.Message {
|
||||
getExportfile(): string;
|
||||
setExportfile(value: string): void;
|
||||
|
||||
getJobs(): number;
|
||||
setJobs(value: number): void;
|
||||
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): CompileReq.AsObject;
|
||||
@ -77,6 +80,7 @@ export namespace CompileReq {
|
||||
quiet: boolean,
|
||||
vidpid: string,
|
||||
exportfile: string,
|
||||
jobs: number,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,8 @@ proto.cc.arduino.cli.commands.CompileReq.toObject = function(includeInstance, ms
|
||||
verbose: jspb.Message.getFieldWithDefault(msg, 10, false),
|
||||
quiet: jspb.Message.getFieldWithDefault(msg, 11, false),
|
||||
vidpid: jspb.Message.getFieldWithDefault(msg, 12, ""),
|
||||
exportfile: jspb.Message.getFieldWithDefault(msg, 13, "")
|
||||
exportfile: jspb.Message.getFieldWithDefault(msg, 13, ""),
|
||||
jobs: jspb.Message.getFieldWithDefault(msg, 14, 0)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -171,6 +172,10 @@ proto.cc.arduino.cli.commands.CompileReq.deserializeBinaryFromReader = function(
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setExportfile(value);
|
||||
break;
|
||||
case 14:
|
||||
var value = /** @type {number} */ (reader.readInt32());
|
||||
msg.setJobs(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -292,6 +297,13 @@ proto.cc.arduino.cli.commands.CompileReq.serializeBinaryToWriter = function(mess
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getJobs();
|
||||
if (f !== 0) {
|
||||
writer.writeInt32(
|
||||
14,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -527,6 +539,21 @@ proto.cc.arduino.cli.commands.CompileReq.prototype.setExportfile = function(valu
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional int32 jobs = 14;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.CompileReq.prototype.getJobs = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 14, 0));
|
||||
};
|
||||
|
||||
|
||||
/** @param {number} value */
|
||||
proto.cc.arduino.cli.commands.CompileReq.prototype.setJobs = function(value) {
|
||||
jspb.Message.setProto3IntField(this, 14, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
|
Loading…
x
Reference in New Issue
Block a user