6989: Build aarch64-apple-darwin binaries on CI r=matklad a=lnicola

This splits the `dist` matrix job into four and tries to make `xtask dist` more principled about target and artifact naming.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2020-12-22 13:12:22 +00:00 committed by GitHub
commit 1f22eca3d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 156 additions and 34 deletions

View file

@ -15,12 +15,9 @@ env:
RUSTUP_MAX_RETRIES: 10 RUSTUP_MAX_RETRIES: 10
jobs: jobs:
dist: dist-windows:
name: dist name: dist (Windows)
runs-on: ${{ matrix.os }} runs-on: windows-latest
strategy:
matrix:
os: [ubuntu-16.04, windows-latest, macos-latest]
steps: steps:
- name: Checkout repository - name: Checkout repository
@ -30,8 +27,7 @@ jobs:
# which takes a long time. The fastest way to do this is to rename the # which takes a long time. The fastest way to do this is to rename the
# existing folder, as deleting it takes about as much time as not doing # existing folder, as deleting it takes about as much time as not doing
# anything and just updating rust-docs. # anything and just updating rust-docs.
- name: Rename existing rust toolchain (Windows) - name: Rename existing rust toolchain
if: matrix.os == 'windows-latest'
run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
- name: Install Rust toolchain - name: Install Rust toolchain
@ -41,38 +37,116 @@ jobs:
profile: minimal profile: minimal
override: true override: true
- name: Dist
run: cargo xtask dist
env:
RA_TARGET: x86_64-pc-windows-msvc
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: dist-windows-latest
path: ./dist
dist-ubuntu:
name: dist (Ubuntu 16.04)
runs-on: ubuntu-16.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install Nodejs - name: Install Nodejs
if: matrix.os == 'ubuntu-16.04'
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 12.x
- name: Dist - name: Dist
if: matrix.os == 'ubuntu-16.04' && github.ref == 'refs/heads/release' if: github.ref == 'refs/heads/release'
run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER
env:
RA_TARGET: x86_64-unknown-linux-gnu
- name: Dist - name: Dist
if: matrix.os == 'ubuntu-16.04' && github.ref != 'refs/heads/release' if: github.ref != 'refs/heads/release'
run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly
env:
- name: Dist RA_TARGET: x86_64-unknown-linux-gnu
if: matrix.os != 'ubuntu-16.04'
run: cargo xtask dist
- name: Nightly analysis-stats check - name: Nightly analysis-stats check
if: matrix.os == 'ubuntu-16.04' && github.ref != 'refs/heads/release' if: github.ref != 'refs/heads/release'
run: ./dist/rust-analyzer-linux analysis-stats . run: ./dist/rust-analyzer-x86_64-unknown-linux-gnu analysis-stats .
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: dist-${{ matrix.os }} name: dist-ubuntu-16.04
path: ./dist
dist-macos-latest:
name: dist (MacOS latest)
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Dist
run: cargo xtask dist
env:
RA_TARGET: x86_64-apple-darwin
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: dist-macos-latest
path: ./dist
dist-macos-11:
name: dist (MacOS 11.0)
runs-on: macos-11.0
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain (beta)
uses: actions-rs/toolchain@v1
with:
toolchain: beta
target: aarch64-apple-darwin
profile: minimal
override: true
- name: Dist
run: cargo xtask dist
env:
RA_TARGET: aarch64-apple-darwin
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: dist-macos-11.0
path: ./dist path: ./dist
publish: publish:
name: publish name: publish
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: ['dist'] needs: ['dist-windows', 'dist-ubuntu', 'dist-macos-latest', 'dist-macos-11']
steps: steps:
- name: Install Nodejs - name: Install Nodejs
uses: actions/setup-node@v1 uses: actions/setup-node@v1
@ -91,6 +165,10 @@ jobs:
- run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- run: 'echo "HEAD_SHA: $HEAD_SHA"' - run: 'echo "HEAD_SHA: $HEAD_SHA"'
- uses: actions/download-artifact@v1
with:
name: dist-macos-11.0
path: dist
- uses: actions/download-artifact@v1 - uses: actions/download-artifact@v1
with: with:
name: dist-macos-latest name: dist-macos-latest
@ -103,7 +181,7 @@ jobs:
with: with:
name: dist-windows-latest name: dist-windows-latest
path: dist path: dist
- run: ls -all ./dist - run: ls -al ./dist
- name: Publish Release - name: Publish Release
uses: ./.github/actions/github-release uses: ./.github/actions/github-release

View file

@ -58,30 +58,74 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
} }
fn dist_server() -> Result<()> { fn dist_server() -> Result<()> {
if cfg!(target_os = "linux") { let target = get_target();
if target.contains("-linux-gnu") {
env::set_var("CC", "clang"); env::set_var("CC", "clang");
} }
cmd!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release").run()?;
let (src, dst) = if cfg!(target_os = "linux") { let toolchain = toolchain(&target);
("./target/release/rust-analyzer", "./dist/rust-analyzer-linux") cmd!("cargo +{toolchain} build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --release").run()?;
} else if cfg!(target_os = "windows") {
("./target/release/rust-analyzer.exe", "./dist/rust-analyzer-windows.exe")
} else if cfg!(target_os = "macos") {
("./target/release/rust-analyzer", "./dist/rust-analyzer-mac")
} else {
panic!("Unsupported OS")
};
let src = Path::new(src);
let dst = Path::new(dst);
let suffix = exe_suffix(&target);
let src =
Path::new("target").join(&target).join("release").join(format!("rust-analyzer{}", suffix));
let dst = Path::new("dist").join(format!("rust-analyzer-{}{}", target, suffix));
cp(&src, &dst)?; cp(&src, &dst)?;
gzip(&src, &dst.with_extension("gz"))?; gzip(&src, &dst.with_extension("gz"))?;
// FIXME: the old names are temporarily kept for client compatibility, but they should be removed
// Remove this block after a couple of releases
match target.as_ref() {
"x86_64-unknown-linux-gnu" => {
cp(&src, "dist/rust-analyzer-linux")?;
gzip(&src, Path::new("dist/rust-analyzer-linux.gz"))?;
}
"x86_64-pc-windows-msvc" => {
cp(&src, "dist/rust-analyzer-windows.exe")?;
gzip(&src, Path::new("dist/rust-analyzer-windows.gz"))?;
}
"x86_64-apple-darwin" => {
cp(&src, "dist/rust-analyzer-mac")?;
gzip(&src, Path::new("dist/rust-analyzer-mac.gz"))?;
}
_ => {}
}
Ok(()) Ok(())
} }
fn get_target() -> String {
match env::var("RA_TARGET") {
Ok(target) => target,
_ => {
if cfg!(target_os = "linux") {
"x86_64-unknown-linux-gnu".to_string()
} else if cfg!(target_os = "windows") {
"x86_64-pc-windows-msvc".to_string()
} else if cfg!(target_os = "macos") {
"x86_64-apple-darwin".to_string()
} else {
panic!("Unsupported OS, maybe try setting RA_TARGET")
}
}
}
}
fn exe_suffix(target: &str) -> String {
if target.contains("-windows-") {
".exe".into()
} else {
"".into()
}
}
fn toolchain(target: &str) -> String {
match target {
"aarch64-apple-darwin" => "beta".to_string(),
_ => "stable".to_string(),
}
}
fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> { fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> {
let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best()); let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best());
let mut input = io::BufReader::new(File::open(src_path)?); let mut input = io::BufReader::new(File::open(src_path)?);