@@ -21,30 +21,23 @@ jobs:
21
21
fail-fast : false
22
22
matrix :
23
23
config :
24
-
25
- - {os: windows-latest, r: 'release', rust-version: 'stable-x86_64-pc-windows-msvc', msystem: "MINGW64"}
26
- - {os: windows-latest, r: 'release', rust-version: 'nightly-x86_64-pc-windows-msvc', msystem: "MINGW64"}
27
- - {os: windows-latest, r: 'devel', rust-version: 'stable-x86_64-pc-windows-msvc', msystem: "MINGW64"}
28
- - {os: windows-latest, r: 'oldrel', rust-version: 'stable-x86_64-pc-windows-msvc', msystem: "MINGW64"}
29
-
30
-
31
- - {os: windows-latest, r: 'release', rust-version: 'stable-i686-pc-windows-msvc', msystem: "MINGW32"}
32
- - {os: windows-latest, r: 'release', rust-version: 'nightly-i686-pc-windows-msvc', msystem: "MINGW32"}
33
- - {os: windows-latest, r: 'devel', rust-version: 'stable-i686-pc-windows-msvc', msystem: "MINGW32"}
34
- - {os: windows-latest, r: 'oldrel', rust-version: 'stable-i686-pc-windows-msvc', msystem: "MINGW32"}
35
-
24
+ - {os: windows-latest, r: 'release', rust-version: 'stable-msvc', targets: ['x86_64-pc-windows-gnu', 'i686-pc-windows-gnu']}
25
+ - {os: windows-latest, r: 'release', rust-version: 'nightly-msvc', targets: ['x86_64-pc-windows-gnu', 'i686-pc-windows-gnu']}
26
+ - {os: windows-latest, r: 'devel', rust-version: 'stable-msvc', targets: ['x86_64-pc-windows-gnu', 'i686-pc-windows-gnu']}
27
+ - {os: windows-latest, r: 'oldrel', rust-version: 'stable-msvc', targets: ['x86_64-pc-windows-gnu', 'i686-pc-windows-gnu']}
36
28
37
29
- {os: macOS-latest, r: 'release', rust-version: 'stable'}
38
30
- {os: macOS-latest, r: 'release', rust-version: 'nightly'}
39
- - {os: macOS-latest, r: 'devel', rust-version: 'stable'}
40
- - {os: macOS-latest, r: 'oldrel', rust-version: 'stable'}
31
+ - {os: macOS-latest, r: 'devel', rust-version: 'stable'}
32
+ - {os: macOS-latest, r: 'oldrel', rust-version: 'stable'}
33
+ - {os: macOS-11.0, r: 'release', rust-version: 'nightly', targets: ['default', 'aarch64-apple-darwin'],
34
+ no-test-targets : ' aarch64-apple-darwin' , emit-bindings: 'true'}
41
35
42
-
43
- - {os: ubuntu-20.04, r: 'release', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
36
+ - {os: ubuntu-20.04, r: 'release', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
44
37
- {os: ubuntu-20.04, r: 'release', rust-version: 'nightly', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
45
38
# R-devel requires LD_LIBRARY_PATH
46
- - {os: ubuntu-20.04, r: 'devel', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
47
- - {os: ubuntu-20.04, r: 'oldrel', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
39
+ - {os: ubuntu-20.04, r: 'devel', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
40
+ - {os: ubuntu-20.04, r: 'oldrel', rust-version: 'stable', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
48
41
49
42
50
43
55
48
defaults :
56
49
run :
57
50
shell : pwsh
51
+
58
52
steps :
59
- - uses : actions/checkout@v2
60
53
54
+ - uses : actions/checkout@v2
61
55
62
56
- name : Set up R
63
57
uses : r-lib/actions/setup-r@v1
@@ -71,42 +65,62 @@ jobs:
71
65
default : true
72
66
components : rustfmt, clippy
73
67
68
+ - name : Configure targets
69
+ run : |
70
+ if ($env:RUST_TARGETS -eq '') {
71
+ $env:RUST_TARGETS = "default"
72
+ }
73
+ foreach ($target in ($env:RUST_TARGETS).Split(",")) {
74
+ if ($target -ne "default") {
75
+ rustup target add $target
76
+ }
77
+ }
78
+ echo "RUST_TARGETS=$env:RUST_TARGETS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
79
+ env :
80
+ RUST_TARGETS : ${{ join(matrix.config.targets, ',')}}
81
+
74
82
# All configurations for Windows go here
75
83
# Rust toolchain is used to determine target architecture
76
84
- name : Configure Windows
77
85
if : runner.os == 'Windows'
78
- # 1. Add appropriate *-gnu target
79
- # 2. Set CARGO_BUILD_FLAGS to the Rust target
80
- # 3. Configure path to libclang
81
- # 4. Add path to mingw32/mingw64 -- otherwise library is linked to rtools
82
- # 5. Add path to R's i386/x64 -- to solve x86 build/test issue
86
+ # 1. Configure path to libclang
87
+ # 2. Add path to mingw32/mingw64 -- otherwise library is linked to rtools
88
+ # 3. Add path to R's i386/x64 -- to solve x86 build/test issue
83
89
run : |
84
- if ($env:RUST_TOOLCHAIN -like "*x86_64*") {
85
- rustup target add x86_64-pc-windows-gnu ;
86
- echo "CARGO_BUILD_FLAGS=--target=x86_64-pc-windows-gnu" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
87
- echo "LIBCLANG_PATH=C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
90
+ if ($env:RUST_TARGETS -like "*x86_64*") {
88
91
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
89
92
echo "$(Rscript.exe -e 'cat(normalizePath(R.home()))')\bin\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
90
93
}
91
- if ($env:RUST_TOOLCHAIN -like "*i686*") {
92
- rustup target add i686-pc-windows-gnu ;
93
- echo "CARGO_BUILD_FLAGS=--target=i686-pc-windows-gnu" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
94
- echo "LIBCLANG_PATH=C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append ;
94
+ if ($env:RUST_TARGETS -like "*i686*") {
95
95
echo "C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
96
96
echo "$(Rscript.exe -e 'cat(normalizePath(R.home()))')\bin\i386" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append ;
97
-
98
97
}
99
- env :
100
- RUST_TOOLCHAIN : ${{ matrix.config.rust-version }}
101
98
102
99
103
100
# MacOS configurations, mainly llvm and path to libclang
101
+ # Because of this R installation issue on MacOS-11.0
102
+ # https://github.com/r-lib/actions/issues/200
103
+ # Symlinks to R/Rscript are not properly set up, so we do it by hand, using this trick
104
+ # https://github.com/r-lib/ps/commit/a24f2c4d1bdba63be14e7729b9ab81d0ed9f719e
105
+ # Environment variables are required fir Mac-OS-11.0, see
106
+ # https://github.com/extendr/libR-sys/issues/35
104
107
- name : Configure MacOs
105
108
if : runner.os == 'macOS'
106
109
run : |
107
110
brew install llvm
108
111
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
109
-
112
+ $env:LLVM_CONFIG_PATH = "$(brew --prefix llvm)/bin/llvm-config"
113
+ echo "LLVM_CONFIG_PATH=$env:LLVM_CONFIG_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
114
+ echo "LIBRSYS_LIBCLANG_INCLUDE_PATH=$(. $env:LLVM_CONFIG_PATH --libdir)/clang/$(. $env:LLVM_CONFIG_PATH --version)/include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
115
+
116
+ if ((Get-ChildItem -Path /usr/local/bin -Filter R | Measure-Object).Count -eq 0) {
117
+ echo "::warning:: Found no R symlink in /usr/local/bin, setting up manually..."
118
+ ln -s /Library/Frameworks/R.framework/Versions/Current/Resources/bin/R /usr/local/bin/
119
+ }
120
+ if ((Get-ChildItem -Path /usr/local/bin -Filter Rscript | Measure-Object).Count -eq 0) {
121
+ echo "::warning:: Found no Rscript symlink in /usr/local/bin, setting up manually..."
122
+ ln -s /Library/Frameworks/R.framework/Versions/Current/Resources/bin/Rscript /usr/local/bin/
123
+ }
110
124
111
125
# This is required for ubuntu r-devel
112
126
# 'Del alias:R' removes R alias which prevents running R
@@ -120,25 +134,69 @@ jobs:
120
134
- name : Build & Emit bindings
121
135
id : build
122
136
run : |
123
- cargo build -vv --features use-bindgen $env:CARGO_BUILD_FLAGS
137
+ foreach ($target in ($env:RUST_TARGETS).Split(",")) {
138
+ echo "Building for target: $target"
139
+ cargo build -vv --features use-bindgen $(if ($target -ne 'default') {"--target=$target"} )
140
+ if (!$?) {
141
+ echo "::error::$target" ;
142
+ throw "Last exit code $LASTEXITCODE"
143
+ }
144
+ }
124
145
env :
125
146
LIBRSYS_BINDINGS_OUTPUT_PATH : generated_bindings
126
147
127
148
# Test the result of previous step
128
149
- name : Run tests
129
150
id : test
130
151
run : |
131
- cargo test -vv --features use-bindgen $env:CARGO_BUILD_FLAGS -- --nocapture --test-threads=1
152
+ foreach ($target in ($env:RUST_TARGETS).Split(",")) {
153
+ if(($env:NO_TEST_TARGETS).Split(",").Contains($target)) {
154
+ echo "::warning:: Skipping bindgen tests for target: $target"
155
+ }
156
+ else {
157
+ echo "Running bindgen tests for target: $target"
158
+ cargo test -vv --features use-bindgen $(if ($target -ne 'default') {"--target=$target"} ) -- --nocapture --test-threads=1
159
+ if (!$?) {
160
+ echo "::error::$target";
161
+ throw "Last exit code $LASTEXITCODE"
162
+ }
163
+ }
164
+ }
165
+ env :
166
+ NO_TEST_TARGETS : ${{ join(matrix.config.no-test-targets, ',') }}
167
+
132
168
133
169
134
- # If success, upload bindings
170
+ # If success
171
+ # AND (either rust is stable and 'emit-bindings' != 'false'
172
+ # OR rust is any and 'emit-bindings' == 'true'),
173
+ # upload bindings
135
174
- name : Upload generated bindings
136
- if : steps.build.outcome == 'success' && steps.test.outcome == 'success' && startsWith(matrix.config.rust-version, 'stable')
175
+ if :
176
+ steps.build.outcome == 'success' &&
177
+ steps.test.outcome == 'success' &&
178
+ ((startsWith(matrix.config.rust-version, 'stable') && matrix.config.emit-bindings != 'false') ||
179
+ (matrix.config.emit-bindings == 'true'))
137
180
uses : actions/upload-artifact@main
138
181
with :
139
182
name : ${{ matrix.config.os }} (R-${{ matrix.config.r }} rust-${{ matrix.config.rust-version }}) generated bindings
140
183
path : generated_bindings
141
184
142
185
# Run tests again using different bindings
143
186
- name : Run tests on precomputed bindings shipped with libR-sys
144
- run : cargo test -vv $env:CARGO_BUILD_FLAGS -- --nocapture --test-threads=1
187
+ run : |
188
+ foreach ($target in ($env:RUST_TARGETS).Split(",")) {
189
+ if(($env:NO_TEST_TARGETS).Split(",").Contains($target)) {
190
+ echo "::warning:: Skipping tests for target: $target"
191
+ }
192
+ else {
193
+ echo "Running tests for target: $target"
194
+ cargo test -vv $(if ($target -ne 'default') {"--target=$target"} ) -- --nocapture --test-threads=1
195
+ if (!$?) {
196
+ echo "::error::$target";
197
+ throw "Last exit code $LASTEXITCODE"
198
+ }
199
+ }
200
+ }
201
+ env :
202
+ NO_TEST_TARGETS : ${{ join(matrix.config.no-test-targets, ',') }}
0 commit comments