@@ -11,15 +11,48 @@ inputs:
1111outputs :
1212 fc :
1313 description : " Path to Fortran compiler"
14- value : ${{ steps.setup .outputs.fc }}
14+ value : ${{ steps.outputs .outputs.fc }}
1515 cc :
1616 description : " Path to C compiler"
17- value : ${{ steps.setup .outputs.cc }}
17+ value : ${{ steps.outputs .outputs.cc }}
1818runs :
1919 using : " composite"
2020 steps :
21- - id : setup
22- name : Setup toolchain
21+
22+ - name : Set oneAPI install dir
23+ id : oneapi-root
24+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
25+ shell : bash
26+ run : echo "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI" >> "$GITHUB_ENV"
27+
28+ # GNU tar can't handle symlinks on Windows, hide it so default Windows tar is used to restore cache
29+ - name : Hide GNU tar
30+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
31+ shell : bash
32+ run : mv "C:\Program Files\Git\usr\bin\tar.exe" "$RUNNER_TEMP\tar.exe"
33+
34+ - name : Get Date
35+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
36+ id : get-date
37+ shell : bash
38+ run : echo "date=$(/bin/date -u "+%Y%m%d")" >> "$GITHUB_OUTPUT"
39+
40+ - name : Restore cache
41+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
42+ id : cache
43+ uses : actions/cache/restore@v3
44+ with :
45+ path : ${{ env.ONEAPI_ROOT }}
46+ key : ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.version }}-${{ steps.get-date.outputs.date }}
47+
48+ - name : Restore GNU tar
49+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
50+ shell : bash
51+ run : mv "$RUNNER_TEMP\tar.exe" 'C:\Program Files\Git\usr\bin\tar.exe'
52+
53+ - name : Setup toolchain
54+ id : setup
55+ if : steps.cache.outputs.cache-hit != 'true'
2356 shell : bash
2457 env :
2558 COMPILER : ${{ inputs.compiler }}
@@ -49,13 +82,61 @@ runs:
4982 ;;
5083 esac
5184
52- which "${FC}"
53- which "${CC}"
54-
55- # set outputs
56- echo "fc=${FC}" >> $GITHUB_OUTPUT
57- echo "cc=${CC}" >> $GITHUB_OUTPUT
58-
59- # persist environment variables
60- echo "FC=${FC}" >> $GITHUB_ENV
61- echo "CC=${CC}" >> $GITHUB_ENV
85+ if ! ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]]); then
86+ which "${FC}"
87+ which "${CC}"
88+
89+ # persist environment variables
90+ echo "FC=${FC}" >> $GITHUB_ENV
91+ echo "CC=${CC}" >> $GITHUB_ENV
92+ fi
93+
94+ - name : Save cache
95+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel') && steps.cache.outputs.cache-hit != 'true'
96+ uses : actions/cache/save@v3
97+ with :
98+ path : ${{ env.ONEAPI_ROOT }}
99+ key : ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.version }}-${{ steps.get-date.outputs.date }}
100+
101+ - name : Activate oneAPI
102+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
103+ shell : cmd
104+ run : |
105+ for /f "tokens=* usebackq" %%f in (`dir /b "%ONEAPI_ROOT%\compiler\" ^| findstr /V latest ^| sort`) do @set "LATEST=%%f"
106+ :: this script fails when install location is not the default
107+ call "%ONEAPI_ROOT%\compiler\%LATEST%\env\vars.bat"
108+ set | findstr /c:"oneAPI" >> "%GITHUB_ENV%"
109+
110+ - name : Set outputs and env vars
111+ shell : bash
112+ id : outputs
113+ run : |
114+ if [ "$RUNNER_OS" == "Windows" ]; then
115+ if [[ "${{ inputs.compiler }}" == "intel" ]]; then
116+ echo fc=ifx>>$GITHUB_OUTPUT
117+ echo cc=icx>>$GITHUB_OUTPUT
118+ echo FC=ifx>>$GITHUB_ENV
119+ echo CC=icx>>$GITHUB_ENV
120+ elif [[ "${{ inputs.compiler }}" == "intel-classic" ]]; then
121+ echo fc=ifort>>$GITHUB_OUTPUT
122+ echo cc=icl>>$GITHUB_OUTPUT
123+ echo FC=ifort>>$GITHUB_ENV
124+ echo CC=icl>>$GITHUB_ENV
125+ else
126+ echo fc=$FC>>$GITHUB_OUTPUT
127+ echo cc=$CC>>$GITHUB_OUTPUT
128+ echo FC=$FC>>$GITHUB_ENV%
129+ echo CC=$CC>>$GITHUB_ENV%
130+ fi
131+ else
132+ echo fc=$FC>>$GITHUB_OUTPUT
133+ echo cc=$CC>>$GITHUB_OUTPUT
134+ echo FC=$FC>>$GITHUB_ENV
135+ echo CC=$CC>>$GITHUB_ENV
136+ fi
137+
138+ # GitHub Actions prepends GNU linker to the PATH before all bash steps, hide it so MSVC linker is found
139+ - name : Hide GNU linker (Windows)
140+ if : runner.os == 'Windows' && contains(inputs.compiler, 'intel')
141+ shell : bash
142+ run : mv "/usr/bin/link" "$RUNNER_TEMP/link"
0 commit comments