Skip to content

Commit cac1a71

Browse files
authored
Arm backend: Refactor check_platform_support (#13904)
Move check_platform_support() to utils.sh file since it will be used by other scripts in coming commits. Add check_os_support() in utils.sh and call it from main. Signed-off-by: [email protected]
1 parent 41ce65c commit cac1a71

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

backends/arm/scripts/utils.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,37 @@ function patch_repo() {
5656
echo -e "[${FUNCNAME[0]}] Patched ${name} @ $(git describe --all --long 2> /dev/null) in ${repo_dir} dir.\n"
5757
popd
5858
}
59+
60+
function check_platform_support() {
61+
# No args
62+
# Exits with return code 1 if the platform is unsupported
63+
64+
# Make sure we are on a supported platform
65+
if [[ "${ARCH}" != "x86_64" ]] && [[ "${ARCH}" != "aarch64" ]] \
66+
&& [[ "${ARCH}" != "arm64" ]]; then
67+
echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"
68+
exit 1
69+
fi
70+
}
71+
72+
function check_os_support() {
73+
# No args
74+
# Exits with return code 1 if invalid combination of platform and os
75+
76+
# Check valid combinations of OS and platform
77+
78+
# Linux on x86_64
79+
if [[ "${ARCH}" == "x86_64" ]] && [[ "${OS}" != "Linux" ]]; then
80+
echo "Error: Only Linux is supported on x86_64"
81+
exit 1
82+
fi
83+
84+
# Linux on arm64/aarch64
85+
# Darwin on arm64/aarch64
86+
if [[ "${ARCH}" == "aarch64" ]] || [[ "${ARCH}" == "arm64" ]]; then
87+
if [[ "${OS}" != "Darwin" ]] || [[ "${OS}" != "Linux" ]]; then
88+
echo "Error: Only Linux and Darwin are supported on arm64"
89+
exit 1
90+
fi
91+
fi
92+
}

examples/arm/setup.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,6 @@ function create_setup_path(){
347347
fi
348348
}
349349

350-
function check_platform_support() {
351-
# Make sure we are on a supported platform
352-
if [[ "${ARCH}" != "x86_64" ]] && [[ "${ARCH}" != "aarch64" ]] \
353-
&& [[ "${ARCH}" != "arm64" ]]; then
354-
echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"
355-
exit 1
356-
fi
357-
}
358-
359350

360351
########
361352
### main
@@ -367,9 +358,13 @@ if [[ $is_script_sourced -eq 0 ]]; then
367358

368359
check_options "$@"
369360

361+
# Import utils
362+
source $et_dir/backends/arm/scripts/utils.sh
370363
source $et_dir/backends/arm/scripts/fvp_utils.sh
371364

365+
echo "[main]: Checking platform and os"
372366
check_platform_support
367+
check_os_support
373368

374369
cd "${script_dir}"
375370

@@ -387,9 +382,6 @@ if [[ $is_script_sourced -eq 0 ]]; then
387382
echo "enable-vela=${enable_vela}"
388383
echo "mlsdk-manifest-url=${mlsdk_manifest_url}"
389384

390-
# Import utils
391-
source $et_dir/backends/arm/scripts/utils.sh
392-
393385
# Select appropriate toolchain
394386
select_toolchain
395387

0 commit comments

Comments
 (0)