Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
clean up + pass target triple to clippy
  • Loading branch information
piscisaureus committed Feb 13, 2020
1 parent 649fb18 commit b13b1b9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 48 deletions.
52 changes: 28 additions & 24 deletions .github/workflows/ci.yml
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build:
name: ${{ matrix.config.os }} ${{ matrix.config.TARGET }}
name: ${{ matrix.config.os }} ${{ matrix.config.target }}
if: |
github.event_name == 'push' ||
!startsWith(github.event.pull_request.head.label, 'denoland:')
Expand All @@ -16,13 +16,13 @@ jobs:
matrix:
config:
- os: macOS-latest
TARGET: x86_64-apple-darwin
target: x86_64-apple-darwin
- os: ubuntu-16.04
TARGET: "x86_64-unknown-linux-gnu"
target: "x86_64-unknown-linux-gnu"
- os: ubuntu-16.04
TARGET: aarch64-unknown-linux-gnu
target: aarch64-unknown-linux-gnu
- os: windows-2019
TARGET: x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc

steps:
- name: Configure git
Expand All @@ -39,25 +39,31 @@ jobs:
with:
rust-version: "1.41.0"

- name: Install rust tools
run: rustup component add clippy rustfmt

- name: Install python
uses: actions/setup-python@v1
with:
python-version: "2.7.x"
architecture: x64
- name: Install cross compile deps
if: matrix.config.TARGET == 'aarch64-unknown-linux-gnu'

- name: Install cross compilation toolchain
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
rustup target add aarch64-unknown-linux-gnu
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
g++-5-aarch64-linux-gnu gcc-5-aarch64-linux-gnu g++-5-multilib \
libc6-arm64-cross
sudo apt install -yq --no-install-suggests --no-install-recommends \
binfmt-support g++-5-aarch64-linux-gnu g++-5-multilib \
gcc-5-aarch64-linux-gnu libc6-arm64-cross qemu qemu-user \
qemu-user-binfmt
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 \
/lib/ld-linux-aarch64.so.1
echo "::set-env name=CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER::/usr/bin/aarch64-linux-gnu-gcc-5"
sudo apt -yq install qemu qemu-user binfmt-support qemu-user-binfmt
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib/ld-linux-aarch64.so.1
echo "::set-env name=QEMU_LD_PREFIX::/usr/aarch64-linux-gnu"
- name: Install and start sccache
shell: pwsh
working-directory: ${{ runner.temp }}
Expand All @@ -68,10 +74,10 @@ jobs:
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "0.2.12"
$platform =
$platform =
@{ "macOS" = "x86_64-apple-darwin"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
}.${{ runner.os }}
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/" +
Expand All @@ -85,17 +91,15 @@ jobs:
echo "::set-env name=RUSTC_WRAPPER::sccache"
- name: Test
run: cargo test -vv --locked --all-targets --target ${{ matrix.config.TARGET }}
run: cargo test -vv --all-targets --locked
--target ${{ matrix.config.target }}

- name: Clippy
run: |
rustup component add clippy
cargo clippy --all-targets --locked -- -D clippy::all
run: cargo clippy --all-targets --locked
--target ${{ matrix.config.target }} -- -D clippy::all

- name: Rustfmt
run: |
rustup component add rustfmt
cargo fmt -- --check
run: cargo fmt -- --check

# TODO: add clang-format and maybe cpplint.

Expand Down
37 changes: 13 additions & 24 deletions build.rs
Expand Up @@ -83,21 +83,13 @@ fn build_v8() {
}
}

dbg!(env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str());

match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() {
"aarch64" => {
gn_args.push("target_cpu=\"arm64\"".to_string());
if need_sysroot_download("arm64") {
install_sysroot("arm64");
}
if need_sysroot_download("amd64") {
install_sysroot("amd64");
}
}
"x86_64" => {
gn_args.push("use_sysroot=false".to_string());
maybe_install_sysroot("arm64");
maybe_install_sysroot("amd64");
}
"x86_64" => gn_args.push("use_sysroot=false".to_string()),
_ => unimplemented!(),
};

Expand All @@ -109,19 +101,16 @@ fn build_v8() {
cargo_gn::build("rusty_v8", None);
}

fn install_sysroot(arch: &str) {
let status = Command::new("python")
.arg("./build/linux/sysroot_scripts/install-sysroot.py")
.arg(format!("--arch={}", arch))
.status()
.expect(&format!("sysroot download failed: {}", arch));
assert!(status.success());
}

fn need_sysroot_download(arch: &str) -> bool {
let sysroot_path =
PathBuf::from(format!("build/linux/debian_sid_{}-sysroot", arch));
!sysroot_path.is_dir()
fn maybe_install_sysroot(arch: &str) {
let sysroot_path = format!("build/linux/debian_sid_{}-sysroot", arch);
if !PathBuf::from(sysroot_path).is_dir() {
let status = Command::new("python")
.arg("./build/linux/sysroot_scripts/install-sysroot.py")
.arg(format!("--arch={}", arch))
.status()
.expect(&format!("sysroot download failed: {}", arch));
assert!(status.success());
}
}

fn platform() -> &'static str {
Expand Down

0 comments on commit b13b1b9

Please sign in to comment.