mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
- Renamed to `ImColor32` to avoid confusion with `ImColor` from the C++. code: https://github.com/ocornut/imgui/blob/9499afdf/imgui.h#L2180 - Eventually I'd probably like to add something mirroring the actual `ImColor`. - Now supports construction and access from `const fn` where possible. - Still impossible for the `f32` APIs - Now supports `.r`/`.g`/`.b`/.a` field access (read and write), by way of a new type `imgui::color::ImColor32Fields`, which essentially exists just to serve this purpose. This is a bit cludgey, but lets us provide the ability for reading and writing `r/g/b/a` values without adding many `fn get_r(self) -> u8` and `fn set_r(&mut self, r: u8);` style functions. - No longer requires FFI calls to construct from RGB floats. - This gives much more freedom to the optimizer, as external calls are impenetrable optimization barriers (It has to pessimistially assume that they read/write to all globally accessable memory, and must be called in the exact order that is listed). - Also, it allows inlining these calls, and avoid computing the same value twice (if the args are the same). - Also improves usage from IDEs, debuggers, etc, and avoids a rare possibility of UB if NaN was passed in (however, this almost certainly could only cause problems if cross-lang LTO was used, which I believe we don't support). - This code is more complex than needed, but was taken from another project of mine (functions were renamed to line up with imgui's names), and has good (literally exhaustive) test coverage. - Unfortunately, float arithmetic in const fn is still not allowed, so for now these aren't usable `const fn`. - Added utility constants to mirror the `IM_COL32_WHITE`, `IM_COL32_BLACK`, `IM_COL32_BLACK_TRANS` constants.
144 lines
5.9 KiB
YAML
144 lines
5.9 KiB
YAML
name: ci
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
schedule:
|
|
- cron: "0 0 * * 1"
|
|
|
|
jobs:
|
|
clippy:
|
|
name: Run linter
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
RUSTFLAGS: -D warnings
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Checkout submodules
|
|
shell: bash
|
|
run: |
|
|
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
|
git submodule sync --recursive
|
|
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
|
- uses: hecrj/setup-rust-action@v1
|
|
with:
|
|
components: clippy
|
|
- name: Cache cargo directories
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
${{ runner.os }}-cargo-
|
|
- name: Cache cargo target dirs
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-target-lint-stable-${{ hashFiles('**/Cargo.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-target-lint-stable-${{ hashFiles('**/Cargo.toml') }}
|
|
${{ runner.os }}-target-lint-stable-
|
|
${{ runner.os }}-target-lint-
|
|
- run: cargo clippy --workspace --all-targets
|
|
# supported winit versions
|
|
- run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --all-features --all-targets
|
|
- run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-19 --all-targets
|
|
- run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20 --all-targets
|
|
- run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-22 --all-targets
|
|
- run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-23 --all-targets
|
|
- run: cargo clippy --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-24 --all-targets
|
|
rustfmt:
|
|
name: Check rustfmt
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
# TODO: why not `with: {submodules: true}`
|
|
- name: Checkout submodules
|
|
shell: bash
|
|
run: |
|
|
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
|
git submodule sync --recursive
|
|
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
|
- uses: hecrj/setup-rust-action@v1
|
|
with:
|
|
components: rustfmt
|
|
- run: cargo fmt --all -- --check
|
|
|
|
test:
|
|
name: Run tests
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
RUSTFLAGS: -D warnings
|
|
RUST_BACKTRACE: 1
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
rust:
|
|
- stable
|
|
- beta
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Checkout submodules
|
|
shell: bash
|
|
run: |
|
|
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
|
git submodule sync --recursive
|
|
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
|
- name: Install toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: ${{ matrix.rust }}
|
|
override: true
|
|
- run: sudo apt install libxcb-shape0-dev libxcb-xfixes0-dev
|
|
if: runner.os == 'Linux'
|
|
# workaround for https://github.com/actions/cache/issues/403
|
|
- name: Install GNU tar
|
|
if: matrix.os == 'macos-latest'
|
|
run: |
|
|
brew install gnu-tar
|
|
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
|
|
- name: Cache cargo directories
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
${{ runner.os }}-cargo-
|
|
- name: Cache cargo target dirs
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: target
|
|
# note `cargo test` and `cargo clippy` don't use the same build
|
|
# artifacts, so this has a different key
|
|
key: ${{ runner.os }}-target-test-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-target-test-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
|
|
${{ runner.os }}-target-test-${{ matrix.rust }}-
|
|
- run: cargo test --workspace --all-targets
|
|
# - run: cargo test --manifest-path imgui-gfx-examples/Cargo.toml --no-default-features --features directx
|
|
# if: runner.os == 'Windows'
|
|
- run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-19
|
|
- run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20
|
|
- run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-22
|
|
- run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-23
|
|
- run: cargo test --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-24
|
|
# Run unreasonably slow tests under release, but only the crates that have
|
|
# them, and don't bother doing this on most platforms.
|
|
- run: cargo test -p imgui --release -- --ignored
|
|
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
|