DragonOS/tools/check_arch.sh
LoGin e80796eb82
feat: la64 boot (#1132)
* la64能够进入到kernel_main
* ci: 添加为ubuntu编译qemu-loongarch64的脚本
* feat: la64能输出hello world
* la64 安装gcc && 配置github ci
* chore: 更新CI工作流和构建脚本中的Docker镜像版本至v1.10

Signed-off-by: longjin <longjin@DragonOS.org>
2025-04-20 18:51:45 +08:00

41 lines
950 B
Bash
Executable File

#!/bin/bash
BASE_PATH=$(pwd)
# 定义错误信息
ARCH_MISMATCH_ERROR="Error: ARCH in env.mk does not match arch in dadk-manifest.toml"
if [ -z "$ARCH" ]; then
echo "Error: ARCH environment variable is not set." >&2
exit 1
fi
# Check if ROOT_PATH is set
if [ -n "$ROOT_PATH" ]; then
CHECK_PATH="$ROOT_PATH"
else
# Check if the current directory name is "tools"
if [ "$(basename "$BASE_PATH")" = "tools" ]; then
# Try the parent directory's dadk-manifest
CHECK_PATH=$(dirname "$BASE_PATH")/
else
# Otherwise, check the current directory
CHECK_PATH="$BASE_PATH"
fi
fi
echo "Checking $CHECK_PATH"
# 读取dadk-manifest.toml文件中的arch字段
DADK_ARCH=$(grep -oP '(?<=arch = ")[^"]+' $CHECK_PATH/dadk-manifest.toml)
# 检查arch字段是否为x86_64
if [ "$ARCH" != $DADK_ARCH ]; then
echo "$ARCH_MISMATCH_ERROR" >&2
exit 1
else
echo "Arch check passed."
exit 0
fi