-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Config: https://docs.wokwi.com/vscode/project-config#custom-chips - Chips API docs: https://docs.wokwi.com/chips-api/getting-started
- Loading branch information
Showing
4 changed files
with
67 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
export interface WokwiTOMLChip { | ||
name: string; | ||
binary: string; | ||
} | ||
|
||
export interface WokwiTOML { | ||
wokwi: { | ||
version: number; | ||
firmware: string; | ||
elf: string; | ||
}; | ||
chip?: WokwiTOMLChip[]; | ||
} |
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,31 @@ | ||
import { existsSync } from 'fs'; | ||
import { join, resolve } from 'path'; | ||
import type { WokwiTOMLChip } from './WokwiConfig'; | ||
|
||
function removeExtension(path: string) { | ||
return path.replace(/\.[^.]+$/, ''); | ||
} | ||
|
||
export function loadChips(chips: WokwiTOMLChip[], rootDir: string) { | ||
const result = []; | ||
for (const chip of chips ?? []) { | ||
const wasmPath = join(rootDir, chip.binary); | ||
if (!existsSync(wasmPath)) { | ||
console.error(`Error: chip WASM file not found: ${resolve(wasmPath)}`); | ||
process.exit(1); | ||
} | ||
|
||
const jsonPath = join(rootDir, removeExtension(chip.binary) + '.json'); | ||
if (!existsSync(jsonPath)) { | ||
console.error(`Error: chip JSON file not found: ${resolve(jsonPath)}`); | ||
process.exit(1); | ||
} | ||
|
||
result.push({ | ||
name: chip.name, | ||
jsonPath, | ||
wasmPath, | ||
}); | ||
} | ||
return result; | ||
} |
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