Skip to content

Commit cf7807a

Browse files
committed
Added determine-rid test.
1 parent d01e1b2 commit cf7807a

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Don't attempt end of line normalization on shell scripts
2+
*.sh -text
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: determine-rid Test
2+
on: [push, workflow_dispatch]
3+
jobs:
4+
test-unix:
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
include:
9+
- os: ubuntu-latest
10+
- os: ubuntu-arm64-latest
11+
- os: macos-latest
12+
name: Test ${{matrix.os}}
13+
runs-on: ${{matrix.os}}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- run: uname -s
18+
- run: uname -m
19+
- run: ./determine-rid.sh
20+
test-windows:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- os: windows-latest
26+
name: Test ${{matrix.os}}
27+
runs-on: ${{matrix.os}}
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- run: echo $env:PROCESSOR_ARCHITECTURE
32+
- run: ./determine-rid.cmd

determine-rid.cmd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@echo off
2+
setlocal
3+
4+
if not "%FORCE_RID%" == "" (
5+
set PLATFORM_RID=%FORCE_RID%
6+
) else if /i "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
7+
set PLATFORM_RID=win-x64
8+
) else if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
9+
set PLATFORM_RID=win-arm64
10+
) else if /i "%PROCESSOR_ARCHITECTURE%" == "X86" (
11+
set PLATFORM_RID=win-x86
12+
) else (
13+
echo Unrecognized processor architecture '%PROCESSOR_ARCHITECTURE%'. Not sure what to use for RID. 1>&2
14+
echo You can force a specific RID by setting FORCE_RID. 1>&2
15+
exit /B 1
16+
)
17+
18+
echo %PLATFORM_RID%

determine-rid.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash -Eeu
2+
3+
PLATFORM=`uname -s`
4+
5+
function GetRidArchitecture()
6+
{
7+
ARCHITECTURE=`uname -m`
8+
if [[ $ARCHITECTURE == 'x86_64' ]]; then
9+
echo "x64"
10+
elif [[ $ARCHITECTURE == 'aarch64' ]]; then
11+
echo "arm64"
12+
else
13+
echo "Unrecognized processor architecture '$ARCHITECTURE'. Not sure what to use for RID." 1>&2
14+
echo "You can force a specific RID by setting FORCE_RID." 1>&2
15+
return 1
16+
fi
17+
}
18+
19+
if [[ -n ${FORCE_RID:-} ]]; then
20+
echo "$FORCE_RID"
21+
elif [[ $PLATFORM == 'Linux' ]]; then
22+
RID_ARCHITECTURE=`GetRidArchitecture`
23+
echo "linux-$RID_ARCHITECTURE"
24+
elif [[ $PLATFORM == 'Darwin' ]]; then
25+
RID_ARCHITECTURE=`GetRidArchitecture`
26+
echo "osx-$RID_ARCHITECTURE"
27+
elif [[ $PLATFORM == MINGW* ]]; then
28+
echo "MINGW (and Git Bash) are not supported, use the Windows-specific build scripts instead." >&2
29+
exit 1
30+
elif [[ $PLATFORM == CYGWIN* ]]; then
31+
echo "CYGWIN is not supported, use the Windows-specific build scripts instead." >&2
32+
exit 1
33+
else
34+
echo "Unrecognized platform '$PLATFORM'. Not sure what to use for RID." >&2
35+
echo "You can force a specific RID by setting FORCE_RID." >&2
36+
exit 1
37+
fi

0 commit comments

Comments
 (0)