Skip to content

Commit

Permalink
feat: Add aarch64-apple-darwin support
Browse files Browse the repository at this point in the history
cargo-dist is now compiled for and also can be used to package other packages for aarch64-apple-darwin (M1/M2 chips)
  • Loading branch information
frol committed Feb 20, 2023
1 parent 2a7d698 commit 467b7dc
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ jobs:
strategy:
matrix:
# For these target platforms
include:
- os: ubuntu-20.04
dist-args: --artifacts=global
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.sh | sh
- os: macos-11
dist-args: --artifacts=local --target=x86_64-apple-darwin
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.sh | sh
- os: ubuntu-20.04
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.sh | sh
- os: windows-2019
dist-args: --artifacts=local --target=x86_64-pc-windows-msvc
include:
- os: ubuntu-20.04
targets: x86_64-unknown-linux-gnu
dist-args: --artifacts=global
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.sh | sh
- os: macos-11
targets: aarch64-apple-darwin x86_64-apple-darwin
dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.sh | sh
- os: ubuntu-20.04
targets: x86_64-unknown-linux-gnu
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.sh | sh
- os: windows-2019
targets: x86_64-pc-windows-msvc
dist-args: --artifacts=local --target=x86_64-pc-windows-msvc
install-dist: irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.3-prerelease04/cargo-dist-v0.0.3-prerelease04-installer.ps1 | iex

runs-on: ${{ matrix.os }}
Expand All @@ -96,7 +100,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
run: |
rustup update 1.67.1 --no-self-update && rustup default 1.67.1
rustup target add ${{ matrix.targets }}
- name: Install cargo-dist
run: ${{ matrix.install-dist }}
- name: Run cargo-dist
Expand Down Expand Up @@ -127,4 +133,4 @@ jobs:
- uses: actions/checkout@v3
- name: mark release as non-draft
run: |
gh release edit ${{ github.ref_name }} --draft=false
gh release edit ${{ github.ref_name }} --draft=false
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ci = ["github"]
# The installers to generate for each app
installers = ["shell", "powershell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-pc-windows-msvc"]

# The profile that 'cargo dist' will build with
[profile.dist]
Expand Down
3 changes: 2 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Release notes are now temporarily simplified for reliability:
* Installers now properly handle packages that define multiple binaries (installing all of them, just like cargo-install)
* Installers now properly know the Github Release they are going to point to (previously they would guess based on the version of the package which was broken in complicated workflows)
* --installer=github-shell and --installer=github-powershell have had the "github-" prefix removed. They now generically use the concept of an "artifact download url" which will be configurable in the future (for now it only gets populated if ci=github is set and your workspace has a coherent definition for "repository" in its Cargo.tomls).
* Added aarch64-apple-darwin target support



Expand Down Expand Up @@ -145,4 +146,4 @@ cargo-dist-schema:

This is the first alpha release of cargo-dist with some minimal functionality!

There are also a couple 0.0.1 prereleases that came before this one that exist to define a sort of "bootstrapping history" for the first "real" release's binary builds because I find it vaguely satisfying and you can't stop me.
There are also a couple 0.0.1 prereleases that came before this one that exist to define a sort of "bootstrapping history" for the first "real" release's binary builds because I find it vaguely satisfying and you can't stop me.
23 changes: 20 additions & 3 deletions cargo-dist/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ fn write_github_ci<W: std::io::Write>(f: &mut W, dist: &DistGraph) -> Result<(),

// If we have Global Artifacts, we need one task for that. If we've done a Good Job
// then these artifacts should be possible to build on *any* platform. Linux is usually
// fast/cheap, so that's a reasonable choice.s
// fast/cheap, so that's a reasonable choice.
if needs_global_build {
push_github_artifacts_matrix_entry(
&mut artifacts_matrix,
GITHUB_LINUX_RUNNER,
&[&"x86_64-unknown-linux-gnu".to_owned()],
"--artifacts=global",
&install_dist_sh,
);
Expand All @@ -92,10 +93,16 @@ fn write_github_ci<W: std::io::Write>(f: &mut W, dist: &DistGraph) -> Result<(),
let install_dist =
install_dist_for_github_runner(runner, &install_dist_sh, &install_dist_ps1);
let mut dist_args = String::from("--artifacts=local");
for target in targets {
for target in &targets {
write!(dist_args, " --target={target}").unwrap();
}
push_github_artifacts_matrix_entry(&mut artifacts_matrix, runner, &dist_args, install_dist);
push_github_artifacts_matrix_entry(
&mut artifacts_matrix,
runner,
&targets,
&dist_args,
install_dist,
);
}

// Finally write the final CI script to the Writer
Expand All @@ -114,18 +121,28 @@ fn write_github_ci<W: std::io::Write>(f: &mut W, dist: &DistGraph) -> Result<(),
fn push_github_artifacts_matrix_entry(
matrix: &mut String,
runner: &str,
targets: &[&TargetTriple],
dist_args: &str,
install_dist: &str,
) {
use std::fmt::Write;

const MATRIX_ENTRY_TEMPLATE: &str = r###"
- os: {{{{GITHUB_RUNNER}}}}
targets: {{{{TARGETS}}}}
dist-args: {{{{DIST_ARGS}}}}
install-dist: {{{{INSTALL_DIST}}}}"###;

let entry = MATRIX_ENTRY_TEMPLATE
.replace("{{{{GITHUB_RUNNER}}}}", runner)
.replace(
"{{{{TARGETS}}}}",
&targets
.iter()
.map(AsRef::as_ref)
.collect::<Vec<&str>>()
.join(" "),
)
.replace("{{{{DIST_ARGS}}}}", dist_args)
.replace("{{{{INSTALL_DIST}}}}", install_dist);

Expand Down
6 changes: 4 additions & 2 deletions cargo-dist/src/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: {{{{INSTALL_RUST}}}}
run: |
{{{{INSTALL_RUST}}}}
rustup target add ${{ matrix.targets }}
- name: Install cargo-dist
run: ${{ matrix.install-dist }}
- name: Run cargo-dist
Expand Down Expand Up @@ -115,4 +117,4 @@ jobs:
- uses: actions/checkout@v3
- name: mark release as non-draft
run: |
gh release edit ${{ github.ref_name }} --draft=false
gh release edit ${{ github.ref_name }} --draft=false
2 changes: 1 addition & 1 deletion cargo-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ fn default_desktop_targets() -> Vec<String> {
"x86_64-unknown-linux-gnu".to_owned(),
"x86_64-apple-darwin".to_owned(),
"x86_64-pc-windows-msvc".to_owned(),
"aarch64-apple-darwin".to_owned(),
// cross-compiles not yet supported
// "aarch64-gnu-unknown-linux".to_owned(),
// "aarch64-pc-windows-msvc".to_owned(),
// "aarch64-apple-darwin".to_owned(),
]
}

0 comments on commit 467b7dc

Please sign in to comment.