This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate the list of programmers by parsing programmers.txt for each …
…package (#1129) * Improved handling of programmer selection - Selected programmer is now saved to and loaded from the arduino.json file - Arduino.json is monitored for changes, and changing file will update selected programmer & ui - Programmer selection UI now shows both the friendly name of the programmer, as well as the arduino name - Minor fix to deviceContexts to fire change events after all states are modified - Layed groundwork to support querying list of programmers for the current board from arduino toolchain * Parse the list of programmers from packages * Tests for parsing programmers * Show board specific list of programmers when selecting Populate the selected programmer and it's display name using list of programmers provided by BoardManager. When selecting programmer, only present the user a list of programmers relevant to the current board. * Initial set of tests for ProgrammerManager * add support for cli * fix hardcoded package name for programmers * adds programmer.key back to support arduino IDE * fix handeling of programmer name in ide and cli Co-authored-by: Adi Azulay <[email protected]>
- Loading branch information
Showing
12 changed files
with
444 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import { IPlatform, IProgrammer } from "./package"; | ||
|
||
export function parseProgrammerDescriptor(programmerDescriptor: string, plat: IPlatform): Map<string, IProgrammer> { | ||
const progrmmerLineRegex = /([^\.]+)\.(\S+)=(.+)/; | ||
|
||
const result = new Map<string, IProgrammer>(); | ||
const lines = programmerDescriptor.split(/[\r|\r\n|\n]/); | ||
const menuMap = new Map<string, string>(); | ||
|
||
lines.forEach((line) => { | ||
// Ignore comments. | ||
if (line.startsWith("#")) { | ||
return; | ||
} | ||
|
||
const match = progrmmerLineRegex.exec(line); | ||
if (match && match.length > 3) { | ||
let programmer = result.get(match[1]); | ||
if (!programmer) { | ||
programmer = new Programmer(match[1], plat); | ||
result.set(programmer.name | ||
, programmer); | ||
} | ||
if (match[2] === "name") { | ||
programmer.displayName = match[3].trim(); | ||
} | ||
} | ||
}); | ||
return result; | ||
} | ||
|
||
export class Programmer implements IProgrammer { | ||
constructor(private _name: string, | ||
private _platform: IPlatform, | ||
private _displayName: string = _name) { | ||
} | ||
|
||
public get name(): string { | ||
return this._name; | ||
} | ||
|
||
public get platform(): IPlatform { | ||
return this._platform; | ||
} | ||
|
||
public get displayName(): string { | ||
return this._displayName; | ||
} | ||
|
||
public set displayName(value: string) { | ||
this._displayName = value; | ||
} | ||
|
||
/** | ||
* @returns {string} Return programmer key in format packageName:name | ||
*/ | ||
public get key() { | ||
return `${this.getPackageName}:${this.name}`; | ||
} | ||
|
||
private get getPackageName(): string { | ||
return this.platform.packageName ? this.platform.packageName : this.platform.package.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.