添加EnvCheck目录结构

This commit is contained in:
HEYAHONG 2024-02-15 17:57:57 +08:00
parent d7e4399884
commit f6c6797fb4
No known key found for this signature in database
GPG Key ID: 2D9DCE4738519ABB
7 changed files with 98 additions and 0 deletions

View File

@ -284,6 +284,10 @@ cutecom-ng安装脚本。本安装脚本主要安装个人魔改版cutecom-ng。
- MSYS2 UCRT64 (64位Windows)
- MSYS2 MINGW32 32位Windows
## EnvCheck
环境检查相关脚本,具体见[tools/EnvCheck](tools/EnvCheck).
# 环境变量
本工程主要使用环境变量进行脚本操作:

View File

@ -0,0 +1,20 @@
#!/bin/bash
#测试程序(通过which测试)参数1为程序名
function EnvCheckTestProgram
{
[ -n "$1" ] ||
{
return 255;
};
ToolPath=`which $1 2> /dev/null`;
[ -e "$ToolPath" ] ||
{
return 255;
};
return 0;
}

38
tools/EnvCheck/EnvCheck.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
#shellcheck disable=SC2128 # ignore array expansion warning
if [ -n "${BASH_SOURCE-}" ]
then
self_path="${BASH_SOURCE}"
elif [ -n "${ZSH_VERSION-}" ]
then
self_path="${(%):-%x}"
else
exit 1
fi
# shellcheck disable=SC2169,SC2169,SC2039 # unreachable with 'dash'
if [[ "$OSTYPE" == "darwin"* ]]; then
# convert possibly relative path to absolute
script_dir="$(realpath_int "${self_path}")"
# resolve any ../ references to make the path shorter
script_dir="$(cd "${script_dir}" || exit 1; pwd)"
else
# convert to full path and get the directory name of that
script_name="$(readlink -f "${self_path}")"
script_dir="$(dirname "${script_name}")"
fi
#导出EnvCheck根路径
export ENVCHECK_ROOT_PATH="${script_dir}";
#导入EnvCheck.d中的脚本
for script_path in `ls ${ENVCHECK_ROOT_PATH}/EnvCheck.d/*.sh`
do
if [ -f ${script_path} ]
then
. ${script_path}
fi
done

3
tools/EnvCheck/Kconfig Normal file
View File

@ -0,0 +1,3 @@
menu "EnvCheck Kconfig"
endmenu

19
tools/EnvCheck/ReadMe.md Normal file
View File

@ -0,0 +1,19 @@
# 说明
EnvCheck用于环境检查并设置一些环境变量。本组件需要在HEnvBox中使用如需独立使用请自行处理相关Kconfig的环境变量
## 使用
EnvCheck的使用如下
```bash
#使用source或者.导入EnvCheck.sh脚本
. EnvCheck.sh脚本路径
```
# 运行环境
具体运行环境要求如下:
- Bash

View File

@ -3,3 +3,10 @@ mainmenu "Linux Tool Config"
config HENVBOX_USE_KCONFIG
bool "enable kconfig"
default y
if HENVBOX_USE_KCONFIG
#导入EnvCheck的Kconfig配置
source "../EnvCheck/Kconfig"
endif

View File

@ -3,3 +3,10 @@ mainmenu "Win32 Tool Config"
config HENVBOX_USE_KCONFIG
bool "enable kconfig"
default y
if HENVBOX_USE_KCONFIG
#导入EnvCheck的Kconfig配置
source "../EnvCheck/Kconfig"
endif