nRF-Kconfig插件解析

Foreword

之前刚好看过一点VScode插件原理,这里就能用上了,看一下nRF-Kconfig是怎么实现的,改一个通用版本来,方便大家使用

nRF-Kconfig

Kconfig插件的安装目录在这里

C:\Users\用户名\.vscode\extensions\nordic-semiconductor.nrf-kconfig-2024.12.13

实际这个插件也没有加密或者混淆什么的,可以直接看

尝试build

	"scripts": {
		"vscode:prepublish": "npm run build && npm run changelog",
		"build": "rimraf dist && tsx ./scripts/build.js --production",
		"watch": "tsx ./scripts/build.js --watch",
		"dev": "tsx ./scripts/build.js --watch",
		"type-check": "tsc --noEmit",
		"lint": "tsx ../scripts/lint.ts nrf-kconfig",
		"lintfix": "tsx ../scripts/lint.ts --fix nrf-kconfig",
		"changelog": "tsx ../scripts/changelog.ts kconfig",
		"copyright": "npm run --prefix ../ copyright",
		"buildHeaderFiles": "tsx ../scripts/buildHeaderFiles.ts",
		"update-build-number": "node ../scripts/updateBuildNumber.js kconfig",
		"copy-css": "copyfiles \"src/**/*.css\" \"src/**/*.scss\" out/nrf-kconfig && copyfiles \"../common/src/**/*.css\"  \"../common/src/**/*.scss\" out/common",
		"build-tests": "tsc -p . --outDir out",
		"watch-tests": "tsc -p . -w --outDir out",
		"pretest": "npm run build-tests && npm run build && npm run copy-css",
		"test": "node ./out/nrf-kconfig/test/runTests.js"
	},

直接使用Package.js中的script部分,可以直接build或者prepublish

可能会遇到下面的错误

npm : 无法加载文件 D:\nodejs\npm.ps1,因为在此系统上禁止运行脚本

查看脚本允许策略,可以看到返回值是严格,这样不允许npm调用ps1的脚本

Get-ExecutionPolicy

image-20250102163319155

修改策略,改为允许远程运行

Set-ExecutionPolicy RemoteSigned

image-20250102163501393

修改完成,再次进行build,正常了

image-20250102163648400

依然提示缺少rimraf命令,但是至少说明脚本跑起来了,这个问题后面再处理

安装一下rimraf就行了,实际上后续还会有tsx也缺少,一起都安装了

npm install --save rimraf
npm install --save tsx

继续往下跑就会发现,这样copy的代码缺少一个script文件夹,这里面包含了各种打包的脚本文件,这里只能先到此为止了

源码分析

{
	"contributes": {
        # 这里注册了各种使用的按钮
		"commands": [
			{
				"command": "kconfig.add",
				"category": "nRF Kconfig",
				"title": "Kconfig: Add build folder"
			},
			{
				"command": "kconfig.showGui",
				"category": "nRF Kconfig",
				"title": "Kconfig: Show Config GUI"
			},
			{
				"command": "kconfig.goToSymDefinition",
				"category": "nRF Kconfig",
				"title": "Go to Symbol Definition"
			},
			{
				"command": "kconfig.expandSubtree",
				"category": "nRF Kconfig",
				"title": "Expand Subtree"
			},
			{
				"command": "kconfig.collapseSubtree",
				"category": "nRF Kconfig",
				"title": "Collapse Subtree"
			},
			{
				"command": "kconfig.ctx.setActive
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值