Skip to content

Commit b6ff9bd

Browse files
authored
fix: refactor for unsupported static binary platforms (#356)
Previous builds for unsupported platforms issued a bunch of warnings because of unused code. This refactors the clang-tools-manager/src/downloader/static_dist.rs module to only compile code that is actually used per the compile target.
1 parent 41fcd9e commit b6ff9bd

11 files changed

Lines changed: 246 additions & 243 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,8 @@ concurrency:
2626

2727
jobs:
2828
seed-build-script:
29-
runs-on: ubuntu-latest
3029
name: Pre-seed static binaries' versions
31-
steps:
32-
- env:
33-
GITHUB_TOKEN: ${{ github.token }}
34-
run: >-
35-
gh release download
36-
-R cpp-linter/clang-tools-static-binaries
37-
--pattern versions.json
38-
--output versions.json
39-
- name: Upload versions.json
40-
uses: actions/upload-artifact@v7
41-
with:
42-
name: static-binary-versions
43-
path: versions.json
44-
if-no-files-found: error
30+
uses: ./.github/workflows/pre-seed-versions.yml
4531

4632
build-bin:
4733
needs: [seed-build-script]
@@ -83,7 +69,7 @@ jobs:
8369
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
8470
uses: actions/download-artifact@v8
8571
with:
86-
name: static-binary-versions
72+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
8773
path: clang-tools-manager
8874
- run: cargo build --bin cpp-linter --features bin --release
8975
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'

.github/workflows/binary-builds.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,8 @@ concurrency:
3535

3636
jobs:
3737
seed-build-script:
38-
runs-on: ubuntu-latest
3938
name: Pre-seed static binaries' versions
40-
steps:
41-
- env:
42-
GITHUB_TOKEN: ${{ github.token }}
43-
run: >-
44-
gh release download
45-
-R cpp-linter/clang-tools-static-binaries
46-
--pattern versions.json
47-
--output versions.json
48-
- name: Upload versions.json
49-
uses: actions/upload-artifact@v7
50-
with:
51-
name: static-binary-versions
52-
path: versions.json
53-
if-no-files-found: error
39+
uses: ./.github/workflows/pre-seed-versions.yml
5440

5541
create-assets:
5642
needs: [seed-build-script]
@@ -135,7 +121,7 @@ jobs:
135121
- name: Restore build script seed
136122
uses: actions/download-artifact@v8
137123
with:
138-
name: static-binary-versions
124+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
139125
path: clang-tools-manager
140126

141127
- name: Build

.github/workflows/build-docs.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,8 @@ jobs:
4545
- run: cargo fetch
4646

4747
seed-build-script:
48-
runs-on: ubuntu-latest
4948
name: Pre-seed static binaries' versions
50-
steps:
51-
- env:
52-
GITHUB_TOKEN: ${{ github.token }}
53-
run: >-
54-
gh release download
55-
-R cpp-linter/clang-tools-static-binaries
56-
--pattern versions.json
57-
--output versions.json
58-
- name: Upload versions.json
59-
uses: actions/upload-artifact@v7
60-
with:
61-
name: static-binary-versions
62-
path: versions.json
63-
if-no-files-found: error
49+
uses: ./.github/workflows/pre-seed-versions.yml
6450

6551
build-mkdocs:
6652
runs-on: ubuntu-latest
@@ -87,7 +73,7 @@ jobs:
8773
- name: Restore build script seed
8874
uses: actions/download-artifact@v8
8975
with:
90-
name: static-binary-versions
76+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
9177
path: clang-tools-manager
9278
- name: Build docs
9379
run: nur docs --build
@@ -123,7 +109,7 @@ jobs:
123109
- name: Restore build script seed
124110
uses: actions/download-artifact@v8
125111
with:
126-
name: static-binary-versions
112+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
127113
path: clang-tools-manager
128114
- run: nur docs rs
129115
- name: upload rustdoc build as artifact

.github/workflows/node-js-packaging.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,8 @@ concurrency:
3939

4040
jobs:
4141
seed-build-script:
42-
runs-on: ubuntu-latest
4342
name: Pre-seed static binaries' versions
44-
steps:
45-
- env:
46-
GITHUB_TOKEN: ${{ github.token }}
47-
run: >-
48-
gh release download
49-
-R cpp-linter/clang-tools-static-binaries
50-
--pattern versions.json
51-
--output versions.json
52-
- name: Upload versions.json
53-
uses: actions/upload-artifact@v7
54-
with:
55-
name: static-binary-versions
56-
path: versions.json
57-
if-no-files-found: error
43+
uses: ./.github/workflows/pre-seed-versions.yml
5844

5945
build:
6046
needs: [seed-build-script]
@@ -143,7 +129,7 @@ jobs:
143129
- name: Restore build script seed
144130
uses: actions/download-artifact@v8
145131
with:
146-
name: static-binary-versions
132+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
147133
path: clang-tools-manager
148134
- name: Build
149135
run: ${{ matrix.settings.build }}
@@ -178,7 +164,7 @@ jobs:
178164
- name: Restore build script seed
179165
uses: actions/download-artifact@v8
180166
with:
181-
name: static-binary-versions
167+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
182168
path: clang-tools-manager
183169
- name: Build
184170
shell: cpa.sh {0}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Pre-seed versions
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
artifact-name:
7+
description: >-
8+
The name of uploaded artifact containing the versions.json file.
9+
value: static-binary-versions
10+
11+
permissions: {}
12+
13+
jobs:
14+
pre-seed-versions:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- env:
18+
GITHUB_TOKEN: ${{ github.token }}
19+
run: >-
20+
gh release download
21+
-R cpp-linter/clang-tools-static-binaries
22+
--pattern versions.json
23+
--output versions.json
24+
- name: Upload versions.json
25+
uses: actions/upload-artifact@v7
26+
with:
27+
name: static-binary-versions
28+
path: versions.json
29+
if-no-files-found: error

.github/workflows/python-packaging.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,8 @@ concurrency:
4444

4545
jobs:
4646
seed-build-script:
47-
runs-on: ubuntu-latest
4847
name: Pre-seed static binaries' versions
49-
steps:
50-
- env:
51-
GITHUB_TOKEN: ${{ github.token }}
52-
run: >-
53-
gh release download
54-
-R cpp-linter/clang-tools-static-binaries
55-
--pattern versions.json
56-
--output versions.json
57-
- name: Upload versions.json
58-
uses: actions/upload-artifact@v7
59-
with:
60-
name: static-binary-versions
61-
path: versions.json
62-
if-no-files-found: error
48+
uses: ./.github/workflows/pre-seed-versions.yml
6349

6450
linux:
6551
needs: [seed-build-script]
@@ -93,31 +79,18 @@ jobs:
9379
- name: Restore build script seed
9480
uses: actions/download-artifact@v8
9581
with:
96-
name: static-binary-versions
82+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
9783
path: clang-tools-manager
9884
- name: Build wheels
9985
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
10086
with:
10187
target: ${{ matrix.platform.target }}
102-
# Use the zig toolchain for all targets except ppc64le.
103-
# Note, this is meant to avoid build errors in aws-lc-sys crate, which compiles C code.
88+
# Use the zig toolchain to avoid build errors in aws-lc-sys crate, which compiles C code.
10489
args: >-
10590
--release --out dist --find-interpreter --zig
10691
# avoid cache-poisoning potential for actually distributed builds
10792
sccache: ${{ startsWith(github.ref, 'refs/tags') && 'false' || 'true' }}
10893
manylinux: 'auto'
109-
# before-script-linux: |
110-
# case "${{ matrix.platform.target }}" in
111-
# ppc64le)
112-
# apt-get update
113-
# apt-get install -y \
114-
# pkg-config \
115-
# gcc-powerpc64le-linux-gnu \
116-
# g++-powerpc64le-linux-gnu \
117-
# binutils-powerpc64le-linux-gnu \
118-
# libc6-dev-ppc64el-cross
119-
# ;;
120-
# esac
12194
- name: Upload wheels
12295
uses: actions/upload-artifact@v7
12396
with:
@@ -145,7 +118,7 @@ jobs:
145118
- name: Restore build script seed
146119
uses: actions/download-artifact@v8
147120
with:
148-
name: static-binary-versions
121+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
149122
path: clang-tools-manager
150123
- name: Build wheels
151124
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
@@ -180,7 +153,7 @@ jobs:
180153
- name: Restore build script seed
181154
uses: actions/download-artifact@v8
182155
with:
183-
name: static-binary-versions
156+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
184157
path: clang-tools-manager
185158
- name: Build wheels
186159
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0

.github/workflows/run-dev-tests.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,8 @@ concurrency:
3030

3131
jobs:
3232
seed-build-script:
33-
runs-on: ubuntu-latest
3433
name: Pre-seed static binaries' versions
35-
steps:
36-
- env:
37-
GITHUB_TOKEN: ${{ github.token }}
38-
run: >-
39-
gh release download
40-
-R cpp-linter/clang-tools-static-binaries
41-
--pattern versions.json
42-
--output versions.json
43-
- name: Upload versions.json
44-
uses: actions/upload-artifact@v7
45-
with:
46-
name: static-binary-versions
47-
path: versions.json
48-
if-no-files-found: error
34+
uses: ./.github/workflows/pre-seed-versions.yml
4935

5036
test:
5137
needs: [seed-build-script]
@@ -120,7 +106,7 @@ jobs:
120106
- name: Restore build script seed
121107
uses: actions/download-artifact@v8
122108
with:
123-
name: static-binary-versions
109+
name: ${{ needs.seed-build-script.outputs.artifact-name }}
124110
path: clang-tools-manager
125111

126112
- name: Run test suite

.github/workflows/stale.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: 'Close stale issues'
22
on:
33
schedule:
4-
- cron: '30 1 * * *'
4+
# Run at 1:30 AM every Monday, Wednesday, and Friday
5+
- cron: '30 1 * * 1,3,5'
56

67
permissions: {}
78

clang-tools-manager/src/downloader/hashing.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,20 @@ use std::{fs, io::Read, num::NonZero, path::Path};
1616
pub enum HashAlgorithm {
1717
/// SHA-256 hash algorithm with the expected checksum value.
1818
Sha256(String),
19+
1920
/// BLAKE2b-256 hash algorithm with the expected checksum value.
2021
Blake2b256(String),
22+
2123
/// SHA-512 hash algorithm with the expected checksum value.
24+
#[cfg(any(
25+
// Windows support is only for x86_64 architecture (for now)
26+
all(target_os = "windows", target_arch = "x86_64"),
27+
// Linux and macOS support only x86_64 and aarch64 architectures
28+
all(
29+
any(target_os = "linux", target_os = "macos"),
30+
any(target_arch = "x86_64", target_arch = "aarch64")
31+
),
32+
))]
2233
Sha512(String),
2334
}
2435

@@ -74,6 +85,15 @@ impl HashAlgorithm {
7485
let hasher = Blake2b::<U32>::new();
7586
Self::hash_file(hasher, file_path, expected)
7687
}
88+
#[cfg(any(
89+
// Windows support is only for x86_64 architecture (for now)
90+
all(target_os = "windows", target_arch = "x86_64"),
91+
// Linux and macOS support only x86_64 and aarch64 architectures
92+
all(
93+
any(target_os = "linux", target_os = "macos"),
94+
any(target_arch = "x86_64", target_arch = "aarch64")
95+
),
96+
))]
7797
HashAlgorithm::Sha512(expected) => {
7898
use sha2::{Digest, Sha512};
7999

0 commit comments

Comments
 (0)