Skip to content

Commit

Permalink
Generate glam source code offline instead of with macros (#294)
Browse files Browse the repository at this point in the history
Replaces macro codegen with code generated offline by a code generator tool.

The intention is to improve source code readability for users.

* Move implementation from core module to codegen templates.

All scalar, sse2 and wasm32 code is inside the codegen templates now,
the core module is removed.

* Making const creation functions, deprecating const macros.

* Bump minimum Rust version to 1.58.1 and the 2021 edition

Needed for const pointer dereferences and assert in a const eval context.
  • Loading branch information
bitshifter committed Jun 20, 2022
1 parent 88e4538 commit 58285f7
Show file tree
Hide file tree
Showing 155 changed files with 56,813 additions and 22,528 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
toolchain: [1.52.1, stable, beta, nightly]
toolchain: [1.58.1, stable, beta, nightly]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# run: cargo install cargo-tarpaulin

- name: Generate code coverage
run: cargo tarpaulin -v --timeout 120 --out Lcov --output-dir ./coverage
run: cargo tarpaulin --timeout 120 --out Lcov --output-dir ./coverage

- name: Upload to coveralls.io
uses: coverallsapp/github-action@master
Expand Down
4 changes: 2 additions & 2 deletions .tarpaulin.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[sse2_math]
features = "approx bytemuck mint rand rkyv serde debug-glam-assert"
exclude-files = ["src/transform.rs", "src/core/wasm32/*", "src/swizzles/vec3a_impl_wasm32.rs", "src/swizzles/vec4_impl_wasm32.rs", "benches/*", "tests/support/mod.rs"]
exclude-files = ["codegen/*", "src/wasm32.rs", "src/bool/wasm32/*", "src/f32/wasm32/*", "src/swizzles/vec3a_impl_wasm32.rs", "src/swizzles/vec4_impl_wasm32.rs", "benches/*", "tests/support.rs"]

[scalar_math]
features = "scalar-math approx bytemuck mint rand rkyv serde debug-glam-assert"
exclude-files = ["src/transform.rs", "src/core/wasm32/*", "src/swizzles/vec3a_impl_wasm32.rs", "src/swizzles/vec4_impl_wasm32.rs", "benches/*", "tests/support/mod.rs"]
exclude-files = ["codegen/*", "src/wasm32.rs", "src/bool/wasm32/*", "src/f32/wasm32/*", "src/swizzles/vec3a_impl_wasm32.rs", "src/swizzles/vec4_impl_wasm32.rs", "benches/*", "tests/support.rs"]
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog], and this project adheres to
[Semantic Versioning].

## [Unreleased]

### Breaking changes

* Minimum Supported Version of Rust bumped to 1.58.1 to allow const pointer
dereferences in constant evaluation.

* The `abs_diff_eq` method on `Mat2` and `DMat2` now takes `other` by value
instead of reference. This is consistent with the other matrix types.

### Changed

* Source code is now largely generated. This largely removes the usage of macros
internally to improve readability. There should be no change in API or
behavior.

### Removed

* Deleted deprecated `TransformRT` and `TransformSRT` types.

## [0.20.5] - 2022-04-12

### Fixed
Expand Down
11 changes: 2 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "glam"
version = "0.20.5" # remember to update html_root_url
edition = "2018"
edition = "2021"
authors = ["Cameron Hart <cameron.hart@gmail.com>"]
description = "A simple and fast 3D math library for games and graphics"
repository = "https://github.com/bitshifter/glam-rs"
readme = "README.md"
license = "MIT OR Apache-2.0"
keywords = ["gamedev", "math", "matrix", "vector", "quaternion"]
categories = ["game-engines", "no-std"]
rust-version = "1.58.1"

[badges]
maintenance = { status = "actively-developed" }
Expand All @@ -27,9 +28,6 @@ glam-assert = []
# this is primarily for testing the fallback implementation
scalar-math = []

# deprecated and will move to a separate crate
transform-types = []

# libm is required when building no_std
libm = ["num-traits/libm"]

Expand Down Expand Up @@ -95,11 +93,6 @@ harness = false
name = "quat"
harness = false

[[bench]]
name = "transform"
harness = false
required-features = ["transform-types"]

[[bench]]
name = "vec2"
harness = false
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status]][github-ci] [![Coverage Status]][coveralls.io]
[![Latest Version]][crates.io] [![docs]][docs.rs]
[![Minimum Supported Rust Version]][Rust 1.52]
[![Minimum Supported Rust Version]][Rust 1.58.1]

A simple and fast 3D math library for games and graphics.

Expand Down Expand Up @@ -128,9 +128,7 @@ glam = { version = "0.20.4", default-features = false }

### Minimum Supported Rust Version (MSRV)

The minimum supported version of Rust for `glam` is `1.52.1`.

`wasm32` SIMD intrinsics require Rust `1.54.0`.
The minimum supported version of Rust for `glam` is `1.58.1`.

## Conventions

Expand Down Expand Up @@ -249,5 +247,5 @@ See [ATTRIBUTION.md] for details.
[crates.io]: https://crates.io/crates/glam/
[docs]: https://docs.rs/glam/badge.svg
[docs.rs]: https://docs.rs/glam/
[Minimum Supported Rust Version]: https://img.shields.io/badge/Rust-1.52.1-blue?color=fc8d62&logo=rust
[Rust 1.52]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1521-2021-05-10
[Minimum Supported Rust Version]: https://img.shields.io/badge/Rust-1.58.1-blue?color=fc8d62&logo=rust
[Rust 1.58.1]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1581-2022-01-19
132 changes: 0 additions & 132 deletions benches/transform.rs

This file was deleted.

8 changes: 4 additions & 4 deletions build_all_msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -e

CARGO='rustup run 1.52.1 cargo'
$CARGO test --features "bytemuck mint rand serde debug-glam-assert transform-types" && \
$CARGO test --features "scalar-math bytemuck mint rand serde debug-glam-assert transform-types" && \
$CARGO test --no-default-features --features "libm scalar-math bytemuck mint rand serde debug-glam-assert transform-types" && \
CARGO='rustup run 1.58.1 cargo'
$CARGO test --features "bytemuck mint rand serde debug-glam-assert" && \
$CARGO test --features "scalar-math bytemuck mint rand serde debug-glam-assert" && \
$CARGO test --no-default-features --features "libm scalar-math bytemuck mint rand serde debug-glam-assert" && \
$CARGO bench --no-run
6 changes: 3 additions & 3 deletions build_and_test_features.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ set -e
FEATURE_SETS=(
# std
"std"
"std approx bytemuck mint rand serde debug-glam-assert transform-types"
"std scalar-math approx bytemuck mint rand serde debug-glam-assert transform-types"
"std approx bytemuck mint rand serde debug-glam-assert"
"std scalar-math approx bytemuck mint rand serde debug-glam-assert"
"std cuda"
"std scalar-math cuda"
# no_std
"libm"
"libm scalar-math approx bytemuck mint rand serde debug-glam-assert transform-types"
"libm scalar-math approx bytemuck mint rand serde debug-glam-assert"
)

rustc --version
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.51"
msrv = "1.58"
16 changes: 16 additions & 0 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "codegen"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = { version = "1", default-features = false }
clap = { version = "3", default-features = false, features = ["cargo", "std"] }
git2 = { version = "0.14", default-features = false }
globset = { version = "0.4", default-features = false }
rustfmt-wrapper = { version = "0.1" }
serde = { version = "1.0", default-features = false, features = ["std"] }
serde_json = { version = "1.0", default-features = false, features = ["std"] }
tera = { version = "1", default-features = false }
Loading

0 comments on commit 58285f7

Please sign in to comment.