1#!/bin/bash 2 3BASE_PATH=$(pwd) 4# 定义错误信息 5ARCH_MISMATCH_ERROR="Error: ARCH in env.mk does not match arch in dadk-manifest.toml" 6 7if [ -z "$ARCH" ]; then 8 echo "Error: ARCH environment variable is not set." >&2 9 exit 1 10fi 11 12 13# Check if ROOT_PATH is set 14if [ -n "$ROOT_PATH" ]; then 15 CHECK_PATH="$ROOT_PATH" 16else 17 # Check if the current directory name is "tools" 18 if [ "$(basename "$BASE_PATH")" = "tools" ]; then 19 # Try the parent directory's dadk-manifest 20 CHECK_PATH=$(dirname "$BASE_PATH")/ 21 else 22 # Otherwise, check the current directory 23 CHECK_PATH="$BASE_PATH" 24 fi 25fi 26 27echo "Checking $CHECK_PATH" 28 29 30# 读取dadk-manifest.toml文件中的arch字段 31DADK_ARCH=$(grep -oP '(?<=arch = ")[^"]+' $CHECK_PATH/dadk-manifest.toml) 32 33# 检查arch字段是否为x86_64 34if [ "$ARCH" != $DADK_ARCH ]; then 35 echo "$ARCH_MISMATCH_ERROR" >&2 36 exit 1 37else 38 echo "Arch check passed." 39 exit 0 40fi 41