Skip to content

Commit 09be1d7

Browse files
committed
Add the possibility to have seperate manifests for different projects
The 'manifest.json' in the 'app/' directory has priority over any other. It also allows for more simple update of the tools like cmake and the zephyr sdk. All the windows tools have now been updated.
1 parent 8a22128 commit 09be1d7

File tree

9 files changed

+122
-55
lines changed

9 files changed

+122
-55
lines changed

Diff for: .eslintrc.json

+17-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,25 @@
99
"@typescript-eslint"
1010
],
1111
"rules": {
12-
"@typescript-eslint/naming-convention": "warn",
12+
"@typescript-eslint/naming-convention": [
13+
"warn",
14+
{
15+
"selector": "import",
16+
"format": [
17+
"camelCase",
18+
"PascalCase"
19+
]
20+
}
21+
],
1322
"@typescript-eslint/semi": "warn",
1423
"curly": "warn",
1524
"eqeqeq": "warn",
1625
"no-throw-literal": "warn",
1726
"semi": "off"
18-
}
19-
}
27+
},
28+
"ignorePatterns": [
29+
"out",
30+
"dist",
31+
"**/*.d.ts"
32+
]
33+
}

Diff for: .nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.13.1
1+
v20.11.0

Diff for: .vscode/extensions.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See http://go.microsoft.com/fwlink/?LinkId=827846
33
// for the documentation about the extensions.json format
44
"recommendations": [
5-
"dbaeumer.vscode-eslint"
5+
"dbaeumer.vscode-eslint",
6+
"ms-vscode.extension-test-runner"
67
]
7-
}
8+
}

Diff for: manifest/manifest.json

+23-15
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
{
2020
"name": "ninja",
2121
"filename": "ninja-win.zip",
22-
"url": "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip",
23-
"md5": "8dad6a63141d57aae277e68ef7658ca1"
22+
"url": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip",
23+
"md5": "5c2f60f4a984a65602b6e6cb93eae367"
2424
},
2525
{
2626
"name": "cmake",
2727
"filename": "cmake-3.22.0-windows-x86_64.zip",
28-
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-windows-x86_64.zip",
29-
"md5": "1a273903dcb295455b69af7c9c10efa2",
30-
"suffix": "cmake-3.22.0-windows-x86_64\\bin\\"
28+
"url": "https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-windows-x86_64.zip",
29+
"md5": "f60735981d24d6f6d327fec6ac57d371",
30+
"suffix": "cmake-3.28.3-windows-x86_64\\bin\\"
3131
},
3232
{
3333
"name": "toolchain",
34-
"filename": "zephyr-sdk-0.15.1_windows-x86_64_minimal.zip",
35-
"url": "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/zephyr-sdk-0.15.1_windows-x86_64_minimal.zip",
36-
"md5": "4c73427373995d1ac53412383a2f6610",
37-
"suffix": "zephyr-sdk-0.15.1\\arm-zephyr-eabi\\bin\\",
34+
"filename": "zephyr-sdk-0.16.5_windows-x86_64_minimal.7z",
35+
"url": "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5/zephyr-sdk-0.16.5_windows-x86_64_minimal.7z",
36+
"md5": "37d76b698e5ddc47b01c9faa3d781f94",
37+
"suffix": "zephyr-sdk-0.16.5\\arm-zephyr-eabi\\bin\\",
3838
"env": [
3939
{
4040
"name": "ZEPHYR_TOOLCHAIN_VARIANT",
@@ -44,20 +44,28 @@
4444
},
4545
{
4646
"name": "ZEPHYR_SDK_INSTALL_DIR",
47-
"suffix": "zephyr-sdk-0.15.1",
47+
"suffix": "zephyr-sdk-0.16.5",
4848
"usepath": true,
4949
"append": false
5050
}
5151
]
5252
},
5353
{
5454
"name": "toolchain",
55-
"filename": "toolchain_windows-x86_64_arm-zephyr-eabi.zip",
56-
"url": "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.1/toolchain_windows-x86_64_arm-zephyr-eabi.zip",
57-
"md5": "1786d58c03f3e380d683b1e5ded45131",
58-
"suffix": "zephyr-sdk-0.15.1\\arm-zephyr-eabi\\bin\\",
55+
"filename": "toolchain_windows-x86_64_arm-zephyr-eabi.7z",
56+
"url": "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5/toolchain_windows-x86_64_arm-zephyr-eabi.7z",
57+
"md5": "94ee641b3f8edb8e5ae4fa60783e43ab",
58+
"suffix": "zephyr-sdk-0.16.5\\arm-zephyr-eabi\\bin\\",
5959
"clear_target": false,
60-
"copy_to_subfolder": "zephyr-sdk-0.15.1"
60+
"copy_to_subfolder": "zephyr-sdk-0.16.5"
61+
},
62+
{
63+
"name": "toolchain",
64+
"filename": "xpack-openocd-0.12.0-2-win32-x64.zip",
65+
"url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.12.0-2/xpack-openocd-0.12.0-2-win32-x64.zip",
66+
"md5": "db724ce414f8cb0e310a92add00be6a9",
67+
"suffix": "xpack-openocd-0.12.0-2\\bin\\",
68+
"clear_target": false
6169
}
6270
]
6371
}

Diff for: package.json

+18-16
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"name": "zephyr-tools",
33
"displayName": "Circuit Dojo Zephyr SDK Tools",
44
"description": "Used for building your Zephyr projects.",
5-
"version": "0.1.33",
5+
"version": "0.2.0",
66
"license": "Apache-2.0",
77
"publisher": "circuitdojo",
88
"icon": "img/bulb.png",
99
"engines": {
10-
"vscode": "^1.52.0",
10+
"vscode": "^1.86.0",
1111
"node": ">=16"
1212
},
1313
"repository": {
@@ -114,23 +114,25 @@
114114
"test": "node ./out/test/runTest.js"
115115
},
116116
"devDependencies": {
117-
"@types/fs-extra": "^8.0.1",
118-
"@types/glob": "^7.1.3",
119-
"@types/mocha": "^8.0.4",
120-
"@types/node": "^12.11.7",
121-
"@types/vscode": "^1.52.0",
122-
"@typescript-eslint/eslint-plugin": "^4.9.0",
123-
"@typescript-eslint/parser": "^4.9.0",
124-
"eslint": "^7.15.0",
125-
"glob": "^7.1.6",
126-
"mocha": "^8.1.3",
127-
"typescript": "^4.1.2",
128-
"vscode-test": "^1.4.1"
117+
"@types/fs-extra": "^11.0.4",
118+
"@types/mocha": "^10.0.6",
119+
"@types/node": "20.11.16",
120+
"@types/node-7z": "^2.1.8",
121+
"@types/vscode": "^1.86.0",
122+
"@typescript-eslint/eslint-plugin": "^6.21.0",
123+
"@typescript-eslint/parser": "^6.21.0",
124+
"eslint": "^8.56.0",
125+
"glob": "^10.3.10",
126+
"mocha": "^10.2.0",
127+
"typescript": "^5.3.3",
128+
"vscode-test": "^1.6.1"
129129
},
130130
"dependencies": {
131-
"fs-extra": "^10.0.0",
131+
"fs-extra": "^11.2.0",
132132
"node-stream-zip": "^1.15.0",
133-
"typed-rest-client": "^1.8.6"
133+
"typed-rest-client": "^1.8.11",
134+
"node-7z": "^3.0.0",
135+
"7zip-bin": "^5.2.0"
134136
},
135137
"extensionPack": [
136138
"ms-vscode.cpptools",

Diff for: src/extension.ts

+20-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import * as os from 'os';
1313
import * as fs from 'fs-extra';
1414
import * as path from 'path';
1515
import * as unzip from 'node-stream-zip';
16+
import sevenBin from '7zip-bin';
17+
import { extractFull } from 'node-7z';
1618

1719
import { TaskManager } from './taskmanager';
1820
import { FileDownload } from './download';
@@ -56,9 +58,6 @@ type Manifest = {
5658
linux: ManifestEntry[];
5759
};
5860

59-
// Manifest data
60-
const manifest: Manifest = require("../manifest/manifest.json");
61-
6261
// Platform
6362
let platform: NodeJS.Platform = os.platform();
6463

@@ -90,6 +89,9 @@ let baudlist = [
9089
// Important directories
9190
let toolsdir = path.join(os.homedir(), toolsfoldername);
9291

92+
// Manifest data
93+
const manifest: Manifest = require(helper.find_file("manifest.json"));
94+
9395
// Project specific configuration
9496
export interface ProjectConfig {
9597
board?: string;
@@ -134,7 +136,7 @@ export async function activate(context: vscode.ExtensionContext) {
134136
}
135137

136138
// Create new
137-
context.subscriptions.push(vscode.commands.registerCommand('zephyr-tools.create-project', async (dest: vscode.Uri | undefined) => { await commands.create_new(context, config, dest) }));
139+
context.subscriptions.push(vscode.commands.registerCommand('zephyr-tools.create-project', async (dest: vscode.Uri | undefined) => { await commands.create_new(context, config, dest); }));
138140

139141
// The command has been defined in the package.json file
140142
// Now provide the implementation of the command with registerCommand
@@ -248,6 +250,16 @@ export async function activate(context: vscode.ExtensionContext) {
248250
await zip.extract(null, copytopath);
249251
await zip.close();
250252

253+
} else if (download.url.includes("7z")) {
254+
255+
// Unzip and copy
256+
output.appendLine(`[SETUP] 7z extract ${filepath} to ${copytopath}`);
257+
258+
const pathTo7zip = sevenBin.path7za;
259+
const seven = extractFull(filepath, copytopath, {
260+
$bin: pathTo7zip
261+
});
262+
251263
} else if (download.url.includes("tar")) {
252264

253265
// Then untar
@@ -549,7 +561,7 @@ export async function activate(context: vscode.ExtensionContext) {
549561
let dest = await helper.get_dest(_dest);
550562

551563
// See if config is set first
552-
if (config.isSetup && dest != null) {
564+
if (config.isSetup && dest !== null) {
553565
initRepo(config, context, dest);
554566
} else {
555567
vscode.window.showErrorMessage('Run `Zephyr Tools: Setup` command first.');
@@ -1097,7 +1109,7 @@ export async function initRepo(config: GlobalConfig, context: vscode.ExtensionCo
10971109
let branch = await vscode.window.showInputBox(branchInputOptions);
10981110

10991111
// TODO: determine choices for west.yml
1100-
let manifest = "west.yml"
1112+
let manifest = "west.yml";
11011113

11021114
// git clone to destination
11031115
let cmd = `west init -m ${url} --mf ${manifest}`;
@@ -1275,7 +1287,7 @@ async function load(config: GlobalConfig, project: ProjectConfig) {
12751287
}
12761288

12771289
// Put device into BL mode automagically
1278-
if (project.board == "circuitdojo_feather_nrf9160_ns") {
1290+
if (project.board === "circuitdojo_feather_nrf9160_ns") {
12791291
let cmd = `zephyr-tools -b`;
12801292
let exec = new vscode.ShellExecution(cmd, options);
12811293

@@ -1596,7 +1608,7 @@ async function changeBoard(config: GlobalConfig, context: vscode.ExtensionContex
15961608
let files = await vscode.workspace.fs.readDirectory(rootPath);
15971609
for (const [index, [file, type]] of files.entries()) {
15981610

1599-
if (type == vscode.FileType.Directory) {
1611+
if (type === vscode.FileType.Directory) {
16001612
// Get boards
16011613
let boardsDir = vscode.Uri.joinPath(rootPath, `${file}/boards`);
16021614

Diff for: src/helper.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as os from 'os';
66
import * as fs from 'fs-extra';
77
import * as path from 'path';
88
import * as unzip from 'node-stream-zip';
9+
import { fileURLToPath } from 'url';
910

1011
export async function get_dest(_dest: vscode.Uri | undefined): Promise<vscode.Uri | null> {
1112

@@ -35,4 +36,31 @@ export async function get_dest(_dest: vscode.Uri | undefined): Promise<vscode.Ur
3536
}
3637

3738
return dest;
38-
}
39+
}
40+
41+
function checkFileExistsSync(filepath: string) {
42+
let flag = true;
43+
try {
44+
fs.accessSync(filepath, fs.constants.F_OK);
45+
} catch (e) {
46+
flag = false;
47+
}
48+
return flag;
49+
}
50+
51+
export function find_file(file: string): string {
52+
let sources = ["../manifest", path.join(os.homedir(), ".zephyrtools")];
53+
54+
if (vscode.workspace.workspaceFolders) {
55+
sources.push(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, "app"));
56+
}
57+
58+
for (let index = sources.length; index > 0; index--) {
59+
let fullpath = path.join(sources[index - 1], file);
60+
if (checkFileExistsSync(fullpath)) {
61+
return fullpath;
62+
}
63+
}
64+
65+
return path.join(sources[0], file);
66+
}

Diff for: src/test/suite/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as path from 'path';
2-
import * as Mocha from 'mocha';
2+
import Mocha from 'mocha';
33
import * as glob from 'glob';
44

5+
56
export function run(): Promise<void> {
67
// Create the mocha test
78
const mocha = new Mocha({
@@ -12,13 +13,13 @@ export function run(): Promise<void> {
1213
const testsRoot = path.resolve(__dirname, '..');
1314

1415
return new Promise((c, e) => {
15-
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16+
glob.glob('**/**.test.js', { cwd: testsRoot }).catch(err => {
1617
if (err) {
1718
return e(err);
1819
}
19-
20+
}).then(files => {
2021
// Add files to the test suite
21-
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22+
files?.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
2223

2324
try {
2425
// Run the mocha test
@@ -36,3 +37,4 @@ export function run(): Promise<void> {
3637
});
3738
});
3839
}
40+

Diff for: tsconfig.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"compilerOptions": {
3-
"module": "commonjs",
4-
"target": "es6",
3+
"module": "Node16",
4+
"target": "ES2022",
55
"outDir": "out",
66
"lib": [
7-
"es6"
7+
"ES2022"
88
],
99
"sourceMap": true,
1010
"rootDir": "src",
11-
"strict": true /* enable all strict type-checking options */
11+
"strict": true /* enable all strict type-checking options */
1212
/* Additional Checks */
1313
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
1414
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
@@ -18,4 +18,4 @@
1818
"node_modules",
1919
".vscode-test"
2020
]
21-
}
21+
}

0 commit comments

Comments
 (0)