Skip to content

Commit

Permalink
Implement initial support for no_std
Browse files Browse the repository at this point in the history
This implements initial support for no_std. Modules such as parsing,
saving and rendering are disabled and timing has to be manually provided
by registering a global handler. The rendering module is on its way to
no_std support as well, but not all Pull Requests to the necessary
dependencies are done yet.

See LiveSplit#223 for more information.
  • Loading branch information
CryZe committed Nov 19, 2019
1 parent adcf751 commit 2dfc4af
Show file tree
Hide file tree
Showing 110 changed files with 880 additions and 311 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_shared.sh
Expand Up @@ -10,7 +10,7 @@ main() {
release_flag="--release"
fi

$cargo build -p cdylib --target $TARGET $release_flag
$cargo build -p cdylib --target $TARGET $release_flag $FEATURES
}

main
13 changes: 9 additions & 4 deletions .github/workflows/build_static.sh
Expand Up @@ -10,20 +10,25 @@ main() {
release_flag="--release"
fi

if [ "$NO_STD" = "true" ]; then
(cd crates/no-std-test && cargo build --target $TARGET $FEATURES)
return
fi

case $TARGET in
asmjs-unknown-emscripten)
$cargo build -p livesplit --target $TARGET --release
$cargo build -p livesplit --target $TARGET --release $FEATURES
;;
wasm32-unknown-emscripten)
rm target/wasm32-unknown-emscripten/release/deps/*.wasm 2>/dev/null || :
rm target/wasm32-unknown-emscripten/release/deps/*.js 2>/dev/null || :
$cargo build -p livesplit --target $TARGET --release
$cargo build -p livesplit --target $TARGET --release $FEATURES
;;
wasm32-unknown-unknown)
$cargo build -p cdylib --target $TARGET --release
$cargo build -p cdylib --target $TARGET --release $FEATURES
;;
*)
$cargo build -p staticlib --target $TARGET $release_flag
$cargo build -p staticlib --target $TARGET $release_flag $FEATURES
;;
esac
}
Expand Down
166 changes: 162 additions & 4 deletions .github/workflows/rust.yml
Expand Up @@ -15,6 +15,21 @@ jobs:
fail-fast: false
matrix:
label:
# Bare Metal
- Bare Metal Nvidia PTX 64
- Bare Metal ARM Cortex-M thumbv6m
- Bare Metal ARM Cortex-M thumbv7em
- Bare Metal ARM Cortex-M thumbv7em Hardware Float
- Bare Metal ARM Cortex-M thumbv7m
- Bare Metal ARM Cortex-M thumbv8m.base
- Bare Metal ARM Cortex-M thumbv8m.main
- Bare Metal ARM Cortex-M thumbv8m.main Hardware Float
- Bare Metal RISC-V 32 i
- Bare Metal RISC-V 32 imac
- Bare Metal RISC-V 32 imc
- Bare Metal RISC-V 64 gc
- Bare Metal RISC-V 64 imac

# Web
# FIXME: asmjs is broken at the moment. It's unclear why.
# - Web asmjs
Expand Down Expand Up @@ -104,6 +119,140 @@ jobs:
- macOS Nightly

include:
# Bare Metal
- label: Bare Metal Nvidia PTX 64
target: nvptx64-nvidia-cuda
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal ARM Cortex-M thumbv6m
target: thumbv6m-none-eabi
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true
features: "--features doesnt-have-atomics"

- label: Bare Metal ARM Cortex-M thumbv7em
target: thumbv7em-none-eabi
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal ARM Cortex-M thumbv7em Hardware Float
target: thumbv7em-none-eabihf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal ARM Cortex-M thumbv7m
target: thumbv7m-none-eabi
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal ARM Cortex-M thumbv8m.base
target: thumbv8m.base-none-eabi
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal ARM Cortex-M thumbv8m.main
target: thumbv8m.main-none-eabi
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal ARM Cortex-M thumbv8m.main Hardware Float
target: thumbv8m.main-none-eabihf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal RISC-V 32 i
target: riscv32i-unknown-none-elf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true
features: "--features doesnt-have-atomics"

- label: Bare Metal RISC-V 32 imac
target: riscv32imac-unknown-none-elf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal RISC-V 32 imc
target: riscv32imc-unknown-none-elf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true
features: "--features doesnt-have-atomics"

- label: Bare Metal RISC-V 64 gc
target: riscv64gc-unknown-none-elf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

- label: Bare Metal RISC-V 64 imac
target: riscv64imac-unknown-none-elf
os: ubuntu-latest
toolchain: stable
tests: skip
dylib: skip
release: skip
no_std: true
install_target: true

# Web
# - label: Web asmjs
# target: asmjs-unknown-emscripten
Expand All @@ -119,15 +268,13 @@ jobs:
toolchain: stable
tests: skip
dylib: skip
release_anyway: true

- label: Web wasm32
target: wasm32-unknown-unknown
os: ubuntu-latest
tests: skip
dylib: skip
install_target: true
release_anyway: true

# Windows
- label: Windows aarch64
Expand Down Expand Up @@ -394,24 +541,28 @@ jobs:
target: x86_64-pc-windows-msvc
os: windows-latest
toolchain: beta
release: skip
cross: skip

- label: Windows Nightly
target: x86_64-pc-windows-msvc
os: windows-latest
toolchain: nightly
release: skip
cross: skip

- label: Windows Beta gnu
target: x86_64-pc-windows-gnu
toolchain: beta-x86_64-pc-windows-gnu
release: skip
os: windows-latest
cross: skip
install_target: true

- label: Windows Nightly gnu
target: x86_64-pc-windows-gnu
toolchain: nightly-x86_64-pc-windows-gnu
release: skip
os: windows-latest
cross: skip
install_target: true
Expand All @@ -420,22 +571,26 @@ jobs:
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
toolchain: beta
release: skip

- label: Linux Nightly
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
toolchain: nightly
release: skip

- label: macOS Beta
target: x86_64-apple-darwin
os: macOS-latest
toolchain: beta
release: skip
cross: skip

- label: macOS Nightly
target: x86_64-apple-darwin
os: macOS-latest
toolchain: nightly
release: skip
cross: skip

steps:
Expand Down Expand Up @@ -463,6 +618,8 @@ jobs:
TARGET: ${{ matrix.target }}
SKIP_CROSS: ${{ matrix.cross }}
IS_DEPLOY: ${{ startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta'))) }}
FEATURES: ${{ matrix.features }}
NO_STD: ${{ matrix.no_std }}

- name: Build Shared Library
if: matrix.dylib == ''
Expand All @@ -471,6 +628,7 @@ jobs:
TARGET: ${{ matrix.target }}
SKIP_CROSS: ${{ matrix.cross }}
IS_DEPLOY: ${{ startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta'))) }}
FEATURES: ${{ matrix.features }}

- name: Test
if: matrix.tests == ''
Expand All @@ -480,15 +638,15 @@ jobs:
SKIP_CROSS: ${{ matrix.cross }}

- name: Prepare Release
if: startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta')))
if: startsWith(github.ref, 'refs/tags/') && matrix.release == ''
shell: bash
run: .github/workflows/before_deploy.sh
env:
OS_NAME: ${{ matrix.os }}
TARGET: ${{ matrix.target }}

- name: Release
if: startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta')))
if: startsWith(github.ref, 'refs/tags/') && matrix.release == ''
uses: softprops/action-gh-release@v1
with:
files: livesplit-core-*.*
Expand Down
47 changes: 31 additions & 16 deletions Cargo.toml
Expand Up @@ -32,29 +32,32 @@ panic = "abort"

[workspace]
members = ["capi", "capi/bind_gen", "capi/js", "capi/staticlib", "capi/cdylib", "crates/*"]
exclude = ["crates/no-std-test"]

[dependencies]
# Required crates
# core
base64 = { version = "0.11.0", default-features = false, features = ["alloc"] }
cfg-if = "0.1.7"
chrono = { version = "0.4.0", features = ["serde", "clock"], default-features = false }
cfg-if = "0.1.10"
derive_more = { version = "0.99.1", default-features = false, features = ["not", "add", "from", "deref"] }
hashbrown = "0.6.3"
libm = "0.1.4"
livesplit-hotkey = { path = "crates/livesplit-hotkey", version = "0.5.0", default-features = false }
odds = { version = "0.3.1", default-features = false }
ordered-float = { version = "1.0.2", default-features = false }
palette = { version = "0.5.0", default-features = false, features = ["std"] }
serde = { version = "1.0.98", default-features = false, features = ["derive", "alloc", "std"] }
snafu = { version = "0.6.0", default-features = false, features = ["std"] }
palette = { version = "0.5.0", default-features = false, features = ["libm"] }
serde = { version = "1.0.98", default-features = false, features = ["derive", "alloc"] }
snafu = { version = "0.6.0", default-features = false }
unicase = "2.6.0"

# std
byteorder = "1.3.2"
image = { version = "0.22.0", features = ["png_codec"], default-features = false }
indexmap = { version = "1.2.0", default-features = false, features = ["serde-1"] }
livesplit-hotkey = { path = "crates/livesplit-hotkey", version = "0.5.0" }
parking_lot = { version = "0.9.0", default-features = false }
quick-xml = { version = "0.17.0", default-features = false }
serde_json = "1.0.8"
utf-8 = "0.7.4"
byteorder = { version = "1.3.2", optional = true }
chrono = { version = "0.4.0", features = ["serde", "clock"], default-features = false, optional = true }
image = { version = "0.22.0", features = ["png_codec"], default-features = false, optional = true }
indexmap = { version = "1.2.0", default-features = false, features = ["serde-1"], optional = true }
parking_lot = { version = "0.9.0", default-features = false, optional = true }
quick-xml = { version = "0.17.0", default-features = false, optional = true }
serde_json = { version = "1.0.8", optional = true }
utf-8 = { version = "0.7.4", optional = true }

# Rendering
euclid = { version = "0.20.0", default-features = false, optional = true }
Expand All @@ -73,12 +76,24 @@ criterion = "0.3.0"
crc = "1.8.1"

[features]
default = ["image-shrinking"]
default = ["image-shrinking", "std"]
doesnt-have-atomics = []
std = ["byteorder", "chrono", "image", "indexmap", "livesplit-hotkey/std", "palette/std", "parking_lot", "quick-xml", "serde_json", "serde/std", "snafu/std", "utf-8"]
more-image-formats = ["image/webp", "image/pnm", "image/ico", "image/jpeg", "image/gif_codec", "image/tiff", "image/tga", "image/bmp", "image/hdr"]
image-shrinking = ["more-image-formats"]
rendering = ["more-image-formats", "euclid", "livesplit-title-abbreviations", "lyon", "rusttype", "smallvec"]
rendering = ["std", "more-image-formats", "euclid", "livesplit-title-abbreviations", "lyon", "rusttype", "smallvec"]
software-rendering = ["rendering", "euc", "vek", "derive_more/mul"]

# FIXME: Some targets don't have atomics, but we can't test for this properly
# yet. So there's a feature you explicitly have to opt into to deactivate the
# usage of atomics. Vice versa would be too dangerous, as `default-features =
# false` would deactivate atomics then. However there's also `cargo test
# --all-features`, which is equally dangerous. To detect this, we have an
# additional `internal-use-all-features` feature that is only ever activated
# when `--all-features` is passed, so we can ignore the `doesnt-have-atomics` in
# that case. https://github.com/rust-lang/rust/issues/32976
internal-use-all-features = []

[[bench]]
name = "balanced_pb"
harness = false
Expand Down

0 comments on commit 2dfc4af

Please sign in to comment.