Skip to content

Commit 0ba49a3

Browse files
committed
Support specific revisions for pgo
1 parent ed737b5 commit 0ba49a3

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

.github/workflows/release.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
- os: windows-latest
3030
target: x86_64-pc-windows-msvc
3131
code-target: win32-x64
32-
pgo: clap-rs/clap
32+
pgo: clap-rs/clap@v4.5.36
3333
- os: windows-latest
3434
target: i686-pc-windows-msvc
35-
pgo: clap-rs/clap
35+
pgo: clap-rs/clap@v4.5.36
3636
- os: windows-latest
3737
target: aarch64-pc-windows-msvc
3838
code-target: win32-arm64
@@ -42,24 +42,24 @@ jobs:
4242
# Zig is not used because it doesn't work with PGO
4343
container: quay.io/pypa/manylinux_2_28_x86_64
4444
code-target: linux-x64
45-
pgo: clap-rs/clap
45+
pgo: clap-rs/clap@v4.5.36
4646
- os: ubuntu-24.04-arm
4747
target: aarch64-unknown-linux-gnu
4848
container: quay.io/pypa/manylinux_2_28_aarch64
4949
code-target: linux-arm64
50-
pgo: clap-rs/clap
50+
pgo: clap-rs/clap@v4.5.36
5151
- os: ubuntu-latest
5252
target: arm-unknown-linux-gnueabihf
5353
zig_target: arm-unknown-linux-gnueabihf.2.28
5454
code-target: linux-armhf
5555
- os: macos-13
5656
target: x86_64-apple-darwin
5757
code-target: darwin-x64
58-
pgo: clap-rs/clap
58+
pgo: clap-rs/clap@v4.5.36
5959
- os: macos-14
6060
target: aarch64-apple-darwin
6161
code-target: darwin-arm64
62-
pgo: clap-rs/clap
62+
pgo: clap-rs/clap@v4.5.36
6363

6464
name: dist (${{ matrix.target }})
6565
runs-on: ${{ matrix.os }}

xtask/src/dist.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ fn gather_pgo_profile<'a>(
180180

181181
let (train_path, label) = match &train_crate {
182182
PgoTrainingCrate::RustAnalyzer => (PathBuf::from("."), "itself"),
183-
PgoTrainingCrate::GitHub(url) => {
184-
(download_crate_for_training(sh, &pgo_dir, url)?, url.as_str())
183+
PgoTrainingCrate::GitHub(repo) => {
184+
(download_crate_for_training(sh, &pgo_dir, repo)?, repo.as_str())
185185
}
186186
};
187187

@@ -212,12 +212,20 @@ fn gather_pgo_profile<'a>(
212212
}
213213

214214
/// Downloads a crate from GitHub, stores it into `pgo_dir` and returns a path to it.
215-
fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, url: &str) -> anyhow::Result<PathBuf> {
216-
let normalized_path = url.replace("/", "-");
215+
fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, repo: &str) -> anyhow::Result<PathBuf> {
216+
let mut it = repo.splitn(2, '@');
217+
let repo = it.next().unwrap();
218+
let revision = it.next();
219+
220+
// FIXME: switch to `--revision` here around 2035 or so
221+
let revision =
222+
if let Some(revision) = revision { &["--branch", revision] as &[&str] } else { &[] };
223+
224+
let normalized_path = repo.replace("/", "-");
217225
let target_path = pgo_dir.join(normalized_path);
218-
cmd!(sh, "git clone --depth 1 https://github.com/{url} {target_path}")
226+
cmd!(sh, "git clone --depth 1 https://github.com/{repo} {revision...} {target_path}")
219227
.run()
220-
.with_context(|| "cannot download PGO training crate from {url}")?;
228+
.with_context(|| "cannot download PGO training crate from {repo}")?;
221229

222230
Ok(target_path)
223231
}

0 commit comments

Comments
 (0)