From 760a00cabdbadcfe5bdea121b8444f1ed14e1a2d Mon Sep 17 00:00:00 2001 From: Lokathor Date: Thu, 19 Sep 2019 19:09:31 -0600 Subject: [PATCH] base files --- .gitignore | 7 +++ .travis.yml | 64 +++++++++++++++++++++++++++ Cargo.toml | 18 ++++++++ LICENSE-0BSD.md | 12 +++++ README.md | 12 +++++ appveyor.yml | 45 +++++++++++++++++++ bors.toml | 1 + pedantic.bat | 1 + rustfmt.toml | 7 +++ scripts/generic-cross/.cargo/config | 16 +++++++ scripts/linux-android/.cargo/config | 21 +++++++++ scripts/travis.sh | 55 +++++++++++++++++++++++ scripts/windows-android/.cargo/config | 21 +++++++++ 13 files changed, 280 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 Cargo.toml create mode 100644 LICENSE-0BSD.md create mode 100644 appveyor.yml create mode 100644 bors.toml create mode 100644 pedantic.bat create mode 100644 rustfmt.toml create mode 100644 scripts/generic-cross/.cargo/config create mode 100644 scripts/linux-android/.cargo/config create mode 100644 scripts/travis.sh create mode 100644 scripts/windows-android/.cargo/config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd0da6a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ + +Cargo.lock +/target/ +/.vscode/ + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..09938b0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,64 @@ +language: rust +sudo: false +git: + quiet: true + +rust: + - 1.36.0 + - stable + - beta + - nightly + +os: + - osx + - linux + # Technically works, but super slow, so we use AppVeyor + #- windows + +branches: + only: + - staging + - trying + - master + - dev + +matrix: + fast_finish: true + allow_failures: + - rust: nightly + include: + # If we wanted to flag on --release mode we'd add a line like this + #- { os: linux, rust: 1.36.0, env: FLAGS=--release } + + - { os: linux, rust: 1.36.0, env: TARGET=wasm32-unknown-unknown } + - { os: linux, rust: 1.36.0, env: TARGET=wasm32-wasi } + + - { os: linux, rust: 1.36.0, env: TARGET=aarch64-linux-android } + - { os: linux, rust: 1.36.0, env: TARGET=armv7-linux-androideabi } + - { os: linux, rust: 1.36.0, env: TARGET=i686-linux-android } + - { os: linux, rust: 1.36.0, env: TARGET=x86_64-linux-android } + + - { os: linux, rust: 1.36.0, env: TARGET=arm-unknown-linux-gnueabihf } + - { os: linux, rust: 1.36.0, env: TARGET=armv7-unknown-linux-gnueabihf } + - { os: linux, rust: 1.36.0, env: TARGET=thumbv7neon-unknown-linux-gnueabihf } + + - { os: osx, rust: 1.36.0, env: TARGET=aarch64-apple-ios } + - { os: osx, rust: 1.36.0, env: TARGET=armv7-apple-ios } + - { os: osx, rust: 1.36.0, env: TARGET=armv7s-apple-ios } + - { os: osx, rust: 1.36.0, env: TARGET=i386-apple-ios } + - { os: osx, rust: 1.36.0, env: TARGET=x86_64-apple-ios } + +script: + - pushd scripts + - ./travis.sh + - popd + +# Configured so we cache cargo-web for WASM unit testing, otherwise it takes +# forever (13+ minutes) to compile. See also +# https://levans.fr/rust_travis_cache.html +cache: + directories: + - $TRAVIS_HOME/.cargo/ + - $TRAVIS_HOME/.rustup/ +before_cache: + - rm -rf "$TRAVIS_HOME/.cargo/registry/src" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..00d765d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "bytemuck" +description = "A crate for mucking around with piles of bytes." +version = "0.1.0" +authors = ["Lokathor "] +repository = "https://github.com/Lokathor/bytemuck" +readme = "README.md" +keywords = ["transmute", "bytes", "casting"] +categories = ["encoding", "no-std"] +edition = "2018" +license = "0BSD" + +[features] +extern_crate_alloc = [] + +[badges] +appveyor = { repository = "Lokathor/bytemuck" } +travis-ci = { repository = "Lokathor/bytemuck" } diff --git a/LICENSE-0BSD.md b/LICENSE-0BSD.md new file mode 100644 index 0000000..bec544f --- /dev/null +++ b/LICENSE-0BSD.md @@ -0,0 +1,12 @@ +Copyright (C) 2019 Daniel Gee + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/README.md b/README.md index 0a2627a..a78d23e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ +[![License:0BSD](https://img.shields.io/badge/License-0BSD-brightgreen.svg)](https://opensource.org/licenses/FPL-1.0.0) +![Minimum Rust Version](https://img.shields.io/badge/Min%20Rust-1.36-green.svg) +[![travis.ci](https://travis-ci.org/Lokathor/bytemuck.svg?branch=master)](https://travis-ci.org/Lokathor/bytemuck) +[![AppVeyor](https://ci.appveyor.com/api/projects/status/hgr4if0snmkmqj88/branch/master?svg=true)](https://ci.appveyor.com/project/Lokathor/bytemuck/branch/master) +[![crates.io](https://img.shields.io/crates/v/bytemuck.svg)](https://crates.io/crates/bytemuck) +[![docs.rs](https://docs.rs/bytemuck/badge.svg)](https://docs.rs/bytemuck/) + # bytemuck + A crate for mucking around with piles of bytes + +CI coverage: +* Tested on: `x86`, `x86_64`, `wasm` +* Built on: `armv7`, `aarch64`, `thumbv7neon` diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..37caac6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,45 @@ + +os: Visual Studio 2015 + +branches: + only: + - staging + - trying + - master + - dev + +matrix: + fast_finish: true + +environment: + matrix: + # Stable + - channel: 1.36.0 + target: i686-pc-windows-msvc + - channel: 1.36.0 + target: i686-pc-windows-gnu + - channel: 1.36.0 + target: x86_64-pc-windows-msvc + - channel: 1.36.0 + target: x86_64-pc-windows-gnu + # Beta and Nightly are checked by TravisCI since builds there run in + # parallel. + +install: + - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init -y --default-toolchain %channel% --default-host %target% + - set PATH=%PATH%;%USERPROFILE%\.cargo\bin + - rustup component add rustfmt + - rustup component add clippy + - rustc -vV + - cargo -vV + +# On advice of retep we skip the "build" script phase +build: false + +test_script: + - cargo fmt -- --check + - cargo clippy + - cargo test --no-default-features + - cargo test + - cargo test --all-features diff --git a/bors.toml b/bors.toml new file mode 100644 index 0000000..359f894 --- /dev/null +++ b/bors.toml @@ -0,0 +1 @@ +status = ["continuous-integration/travis-ci/push"] diff --git a/pedantic.bat b/pedantic.bat new file mode 100644 index 0000000..d6323bf --- /dev/null +++ b/pedantic.bat @@ -0,0 +1 @@ +cargo clippy -- -W clippy::pedantic diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..67d949d --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,7 @@ +error_on_line_overflow = false +merge_imports = true +reorder_imports = true +use_try_shorthand = true +tab_spaces = 2 +max_width = 100 +color = "Never" diff --git a/scripts/generic-cross/.cargo/config b/scripts/generic-cross/.cargo/config new file mode 100644 index 0000000..8c82fbb --- /dev/null +++ b/scripts/generic-cross/.cargo/config @@ -0,0 +1,16 @@ +# Don't generate CPU mismatch warnings when cross-compiling + +[target.arm-unknown-linux-gnueabihf] +ar = "arm-linux-gnueabihf-ar" +linker = "arm-linux-gnueabihf-gcc" +rustflags = ["-C","target-cpu=generic"] + +[target.armv7-unknown-linux-gnueabihf] +ar = "arm-linux-gnueabihf-ar" +linker = "arm-linux-gnueabihf-gcc" +rustflags = ["-C","target-cpu=generic"] + +[target.thumbv7neon-unknown-linux-gnueabihf] +ar = "arm-linux-gnueabihf-ar" +linker = "arm-linux-gnueabihf-gcc" +rustflags = ["-C","target-cpu=generic"] diff --git a/scripts/linux-android/.cargo/config b/scripts/linux-android/.cargo/config new file mode 100644 index 0000000..befe0d9 --- /dev/null +++ b/scripts/linux-android/.cargo/config @@ -0,0 +1,21 @@ +# Android ar/linker/flags config for when building on linux. + +[target.aarch64-linux-android] +ar = "aarch64-linux-android-ar" +linker = "aarch64-linux-android21-clang" +rustflags = ["-C","target-cpu=generic"] + +[target.armv7-linux-androideabi] +ar = "armv7a-linux-androideabi-ar" +linker = "armv7a-linux-androideabi21-clang" +rustflags = ["-C","target-cpu=generic"] + +[target.i686-linux-android] +ar = "i686-linux-android-ar" +linker = "i686-linux-android21-clang" +rustflags = ["-C","target-cpu=generic"] + +[target.x86_64-linux-android] +ar = "x86_64-linux-android-ar" +linker = "x86_64-linux-android21-clang" +rustflags = ["-C","target-cpu=generic"] diff --git a/scripts/travis.sh b/scripts/travis.sh new file mode 100644 index 0000000..77884a5 --- /dev/null +++ b/scripts/travis.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e + +rustup component add clippy +cargo clippy + +if [[ "$TARGET" != "" ]]; then rustup target install $TARGET; fi + +if [[ "$TARGET" == "wasm32-"* && "$TARGET" != "wasm32-wasi" ]]; then + cargo-web --version || cargo install cargo-web + cargo web test --no-default-features $FLAGS --target=$TARGET + cargo web test $FLAGS --target=$TARGET + cargo web test --all-features $FLAGS --target=$TARGET + +elif [[ "$TARGET" == *"-linux-android"* ]]; then + export PATH=/usr/local/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH + pushd linux-android + cargo build --no-default-features --target=$TARGET $FLAGS + cargo build --target=$TARGET $FLAGS + cargo build --all-features --target=$TARGET $FLAGS + # Don't test, can't run android emulators successfully on travis currently + popd + +elif [[ "$TARGET" == *"-apple-ios" || "$TARGET" == "wasm32-wasi" ]]; then + cargo build --no-default-features --target=$TARGET $FLAGS + cargo build --target=$TARGET $FLAGS + cargo build --all-features --target=$TARGET $FLAGS + # Don't test + # iOS simulator setup/teardown is complicated + # cargo-web doesn't support wasm32-wasi yet, nor can wasm-pack test specify a target + +elif [[ "$TARGET" == *"-unknown-linux-gnueabihf" ]]; then + #sudo apt-get update + #sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf + pushd generic-cross + cargo build --no-default-features --target=$TARGET $FLAGS + cargo build --target=$TARGET $FLAGS + cargo build --all-features --target=$TARGET $FLAGS + # Don't test + popd + +elif [[ "$TARGET" != "" ]]; then + pushd generic-cross + cargo test --no-default-features --target=$TARGET $FLAGS + cargo test --target=$TARGET $FLAGS + cargo test --all-features --target=$TARGET $FLAGS + popd + +else + # Push nothing, target host CPU architecture + cargo test --no-default-features $FLAGS + cargo test $FLAGS + cargo test --all-features $FLAGS +fi diff --git a/scripts/windows-android/.cargo/config b/scripts/windows-android/.cargo/config new file mode 100644 index 0000000..0839f7e --- /dev/null +++ b/scripts/windows-android/.cargo/config @@ -0,0 +1,21 @@ +# Android ar/linker/flags config for when building on windows. + +[target.aarch64-linux-android] +ar = "aarch64-linux-android-ar.cmd" +linker = "aarch64-linux-android21-clang.cmd" +rustflags = ["-C","target-cpu=generic"] + +[target.armv7-linux-androideabi] +ar = "armv7a-linux-androideabi-ar.cmd" +linker = "armv7a-linux-androideabi21-clang.cmd" +rustflags = ["-C","target-cpu=generic"] + +[target.i686-linux-android] +ar = "i686-linux-android-ar.cmd" +linker = "i686-linux-android21-clang.cmd" +rustflags = ["-C","target-cpu=generic"] + +[target.x86_64-linux-android] +ar = "x86_64-linux-android-ar.cmd" +linker = "x86_64-linux-android21-clang.cmd" +rustflags = ["-C","target-cpu=generic"]