Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
Z
zap
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
esp-mirror
project-chip
zap
提交
ca3763ec
提交
ca3763ec
编辑于
4 years ago
作者:
Timotej Ecimovic
浏览文件
操作
下载
补丁
差异文件
Clean up some convoluted loading logic.
上级
fd029a05
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
src-electron/util/util.js
+28
-0
28 个添加, 0 个删除
src-electron/util/util.js
src-electron/zcl/zcl-loader-silabs.js
+22
-37
22 个添加, 37 个删除
src-electron/zcl/zcl-loader-silabs.js
有
50 个添加
和
37 个删除
src-electron/util/util.js
+
28
−
0
浏览文件 @
ca3763ec
...
...
@@ -322,6 +322,33 @@ function createAbsolutePath(relativePath, relativity, zapFilePath) {
return
relativePath
}
/**
* This method takes an array of root locations and a relative path.
* It will attempt to locate an absolute file at the path, combining
* the root location and a relative path, until a file is found and returned.
*
* If none of the combined root locations and relative paths results
* in an actual file, null is returned.
*
* @param {*} rootFileLocations Array of root file locations, typically directories
* @param {*} relativeFilePath Relative path
* @returns A fully resolved path that exists, or null if none is available.
*/
function
locateRelativeFilePath
(
rootFileLocations
,
relativeFilePath
)
{
if
(
relativeFilePath
)
{
for
(
var
i
=
0
;
i
<
rootFileLocations
.
length
;
i
++
)
{
var
resolvedFile
=
path
.
resolve
(
rootFileLocations
[
i
],
relativeFilePath
.
trim
()
)
if
(
fs
.
existsSync
(
resolvedFile
))
{
return
resolvedFile
}
}
}
return
null
}
/**
* Returns a promise of an execution of an external program.
*
...
...
@@ -370,3 +397,4 @@ exports.sessionReport = sessionReport
exports
.
executePromisesSequentially
=
executePromisesSequentially
exports
.
createAbsolutePath
=
createAbsolutePath
exports
.
executeExternalProgram
=
executeExternalProgram
exports
.
locateRelativeFilePath
=
locateRelativeFilePath
此差异已折叠。
点击以展开。
src-electron/zcl/zcl-loader-silabs.js
+
22
−
37
浏览文件 @
ca3763ec
...
...
@@ -37,6 +37,7 @@ function collectDataFromJsonFile(ctx) {
env
.
logInfo
(
`Collecting ZCL files from JSON file:
${
ctx
.
metadataFile
}
`
)
return
new
Promise
((
resolve
,
reject
)
=>
{
var
obj
=
JSON
.
parse
(
ctx
.
data
)
var
f
var
fileLocations
if
(
Array
.
isArray
(
obj
.
xmlRoot
))
{
...
...
@@ -47,28 +48,24 @@ function collectDataFromJsonFile(ctx) {
fileLocations
=
[
path
.
join
(
path
.
dirname
(
ctx
.
metadataFile
),
obj
.
xmlRoot
)]
}
var
zclFiles
=
[]
obj
.
xmlFile
.
forEach
((
f
)
=>
{
mapOverFileLocations
(
fileLocations
,
f
,
(
x
)
=>
{
zclFiles
.
push
(
x
)
})
obj
.
xmlFile
.
forEach
((
xmlF
)
=>
{
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
xmlF
)
if
(
f
!=
null
)
zclFiles
.
push
(
f
)
})
ctx
.
zclFiles
=
zclFiles
// Manufacturers XML file.
mapOverFileLocations
(
fileLocations
,
obj
.
manufacturersXml
,
(
x
)
=>
{
ctx
.
manufacturersXml
=
x
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
obj
.
manufacturersXml
)
if
(
f
!=
null
)
ctx
.
manufacturersXml
=
f
// Zcl XSD file
mapOverFileLocations
(
fileLocations
,
obj
.
zclSchema
,
(
x
)
=>
{
ctx
.
zclSchema
=
x
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
obj
.
zclSchema
)
if
(
f
!=
null
)
ctx
.
zclSchema
=
f
// Zcl Validation Script
mapOverFileLocations
(
fileLocations
,
obj
.
zclValidation
,
(
x
)
=>
{
ctx
.
zclValidation
=
x
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
obj
.
zclValidation
)
if
(
f
!=
null
)
ctx
.
zclValidation
=
f
// General options
// Note that these values when put into OPTION_CODE will generally be converted to lowercase.
...
...
@@ -86,18 +83,6 @@ function collectDataFromJsonFile(ctx) {
})
}
function
mapOverFileLocations
(
fileLocations
,
f
,
destinationResolver
)
{
if
(
f
)
{
for
(
var
i
=
0
;
i
<
fileLocations
.
length
;
i
++
)
{
var
resolvedFile
=
path
.
resolve
(
fileLocations
[
i
],
f
.
trim
())
if
(
fs
.
existsSync
(
resolvedFile
))
{
destinationResolver
(
resolvedFile
)
break
}
}
}
}
/**
* Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.
*
...
...
@@ -119,30 +104,30 @@ function collectDataFromPropertiesFile(ctx) {
.
split
(
'
,
'
)
.
map
((
p
)
=>
path
.
join
(
path
.
dirname
(
ctx
.
metadataFile
),
p
))
var
zclFiles
=
[]
var
f
// Iterate over all XML files in the properties file, and check
// if they exist in one or the other directory listed in xmlRoot
zclProps
.
xmlFile
.
split
(
'
,
'
).
forEach
((
f
)
=>
{
mapOverFileLocations
(
fileLocations
,
f
,
(
x
)
=>
{
zclFiles
.
push
(
x
)
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
f
)
if
(
f
!=
null
)
zclFiles
.
push
(
f
)
})
ctx
.
zclFiles
=
zclFiles
// Manufacturers XML file.
mapOverFileLocations
(
fileLocations
,
zclProps
.
manufacturersXml
,
(
x
)
=>
{
ctx
.
manufacturersXml
=
x
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
zclProps
.
manufacturersXml
)
if
(
f
!=
null
)
ctx
.
manufacturersXml
=
f
// Zcl XSD file
mapOverFileLocations
(
fileLocations
,
zclProps
.
zclSchema
,
(
x
)
=>
{
ctx
.
zclSchema
=
x
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
zclProps
.
zclSchema
)
if
(
f
!=
null
)
ctx
.
zclSchema
=
f
// Zcl Validation Script
mapOverFileLocations
(
fileLocations
,
zclProps
.
zclValidation
,
(
x
)
=>
{
ctx
.
zclValidation
=
x
})
f
=
util
.
locateRelativeFilePath
(
fileLocations
,
zclProps
.
zclValidation
)
if
(
f
!=
null
)
ctx
.
zclValidation
=
f
// General options
// Note that these values when put into OPTION_CODE will generally be converted to lowercase.
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录