diff --git a/README.md b/README.md index 9caee7bf6c..d06da54415 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,13 @@ Written for .NET Core in C#. |![Win-x86](docs/res/win_med.png) **Windows x86**|[![Build & Test][win-x86-build-badge]][build]| |![Win-arm64](docs/res/win_med.png) **Windows ARM64**|[![Build & Test][win-arm64-build-badge]][build]| |![macOS](docs/res/apple_med.png) **macOS**|[![Build & Test][macOS-build-badge]][build]| -|![Linux-x64](docs/res/linux_med.png) **Linux x64**|[![Build & Test][linux-x64-build-badge]][build]| -|![Linux-arm](docs/res/linux_med.png) **Linux ARM**|[![Build & Test][linux-arm-build-badge]][build]| -|![RHEL6-x64](docs/res/redhat_med.png) **RHEL 6 x64**|[![Build & Test][rhel6-x64-build-badge]][build]| +|![Linux-x64](docs/res/linux_med.png) **Linux x64**|[![Build & Test][linux-x64-build-badge]][build]| +|![Linux-arm](docs/res/linux_med.png) **Linux ARM**|[![Build & Test][linux-arm-build-badge]][build]| +|![RHEL6-x64](docs/res/redhat_med.png) **RHEL 6 x64**|[![Build & Test][rhel6-x64-build-badge]][build]| [win-x64-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=Windows%20(x64) [win-x86-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=Windows%20(x86) -[win-arm64-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=Windows%20(arm64) +[win-arm64-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=Windows%20(ARM64) [macOS-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=macOS%20(x64) [linux-x64-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=Linux%20(x64) [linux-arm-build-badge]: https://mseng.visualstudio.com/pipelinetools/_apis/build/status/VSTS.Agent/azure-pipelines-agent.ci?branchName=master&jobname=Linux%20(ARM) diff --git a/src/dev.sh b/src/dev.sh index 86a3d0ceec..e4b2834ffe 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -119,12 +119,15 @@ function detect_platform_and_runtime_id() { CURRENT_PLATFORM=$(uname | awk '{print tolower($0)}') fi - echo "Detected Process Arch: $PROCESSOR_ARCHITECTURE" if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then + local processor_type=$(detect_system_architecture) + echo "Detected Process Arch: $processor_type" + + # Default to win-x64 DETECTED_RUNTIME_ID='win-x64' - if [[ "$PROCESSOR_ARCHITECTURE" == 'x86' ]]; then + if [[ "$processor_type" == 'x86' ]]; then DETECTED_RUNTIME_ID='win-x86' - elif [[ "$PROCESSOR_ARCHITECTURE" == 'ARM64' ]]; then + elif [[ "$processor_type" == 'ARM64' ]]; then DETECTED_RUNTIME_ID='win-arm64' fi elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then @@ -368,6 +371,48 @@ function cmd_lint_verify() { "${DOTNET_DIR}/dotnet" format --verify-no-changes -v diag "$REPO_ROOT/azure-pipelines-agent.sln" || checkRC "cmd_lint_verify" } +function detect_system_architecture() { + local processor # Variable to hold the processor type (e.g., x, ARM) + local os_arch # Variable to hold the OS bitness (e.g., 64, 86) + + # Detect processor type using PROCESSOR_IDENTIFIER + # Check for AMD64 or Intel in the variable to classify as "x" (covers x86 and x64 processors) + if [[ "$PROCESSOR_IDENTIFIER" =~ "AMD64" || "$PROCESSOR_IDENTIFIER" =~ "Intel64" ]]; then + processor="x" + # Check for ARM64 in the variable to classify as "ARM" + elif [[ "$PROCESSOR_IDENTIFIER" =~ "ARM" || "$PROCESSOR_IDENTIFIER" =~ "Arm" ]]; then + processor="ARM" + # Default to "x" for unknown or unhandled cases + else + processor="x" + fi + + # Detect OS bitness using uname + # "x86_64" indicates a 64-bit operating system + if [[ "$(uname -m)" == "x86_64" ]]; then + os_arch="64" + # "i686" or "i386" indicates a 32-bit operating system + elif [[ "$(uname -m)" == "i686" || "$(uname -m)" == "i386" ]]; then + os_arch="86" + # "aarch64" indicates a 64-bit ARM operating system + elif [[ "$(uname -m)" == "aarch64" ]]; then + os_arch="64" + # Default to "64" for unknown or unhandled cases + else + os_arch="64" + fi + + # Note: AMD32 does not exist as a specific label; 32-bit AMD processors are referred to as x86. + # ARM32 also does not exist in this context; ARM processors are always 64-bit. + + # Combine processor type and OS bitness for the final result + # Examples: + # - "x64" for Intel/AMD 64-bit + # - "x86" for Intel/AMD 32-bit + # - "ARM64" for ARM 64-bit + echo "${processor}${os_arch}" +} + detect_platform_and_runtime_id echo "Current platform: $CURRENT_PLATFORM" echo "Current runtime ID: $DETECTED_RUNTIME_ID"