name: physics
gpid: malunal
semv: 1.0.0

options:
  level: 2

requires:
- https://git.malunal.studio/sakura/std@v1.0.0

targets:
- name: malunal.linear
  type: library
  root: ./linear
  deps:
  - std.math
  - std.serial

# The shapes of space, made of `malunal::linear`'s vectors, and the tests
# between them.
- name: malunal.geometry
  type: library
  root: ./geometry
  deps:
  - malunal.linear
  - std.math
  - std.serial

# Light in the units it's measured in, lumens, candela, lux, and nits, and
# converted between them; exposure values; and the colors of temperatures.
- name: malunal.photometry
  type: library
  root: ./photometry
  deps:
  - malunal.linear
  - std.math

# What collides and moves in a plane: shapes, where and how deep two meet,
# rays, a tree of boxes, a grid of solid cells, as a tilemap's walls are, and a
# space of bodies pushed by forces and what they meet, and held by joints.
- name: malunal.physics2d
  type: library
  root: ./physics2d
  deps:
  - malunal.linear
  - std.containers
  - std.math
  - std.serial
  - std.time

# What collides and moves in space: shapes, where and how deep two meet, rays,
# a tree of boxes, the triangles of a surface, as a level's ground and walls
# are, and a space of bodies pushed by forces and what they meet, and held by
# joints.
- name: malunal.physics3d
  type: library
  root: ./physics3d
  deps:
  - malunal.geometry
  - malunal.linear
  - std.containers
  - std.math
  - std.serial
  - std.time

# Times what `malunal::linear` does against the same written a number at a
# time; see its header.
- name:  malunal.linear.bench
  type:  program
  level: ${level}
  deps:
  - malunal.linear
  - std.containers
  - std.io
  - std.math
  - std.time
  srcs:
  - tools/bench.sakura

# Times what `malunal::geometry` does against the same written a number at a
# time; see its header.
- name:  malunal.geometry.bench
  type:  program
  level: ${level}
  deps:
  - malunal.geometry
  - malunal.linear
  - std.containers
  - std.io
  - std.math
  - std.time
  srcs:
  - tools/geometry_bench.sakura

# Steps `malunal::physics2d`'s space through Box2D's benchmark scenes; see its
# header.
- name:  malunal.physics2d.bench
  type:  program
  level: ${level}
  deps:
  - malunal.linear
  - malunal.physics2d
  - std.containers
  - std.io
  - std.math
  - std.time
  srcs:
  - tools/physics2d_bench.sakura

# Steps `malunal::physics3d`'s space through Jolt's performance test scenes;
# see its header.
- name:  malunal.physics3d.bench
  type:  program
  level: ${level}
  deps:
  - malunal.geometry
  - malunal.linear
  - malunal.physics3d
  - std.containers
  - std.io
  - std.math
  - std.time
  srcs:
  - tools/physics3d_bench.sakura

tests:
# On the machine, which works each number at a time.
- name: malunal.linear.tests
  type: program
  deps: [malunal.linear, std.json, std.math, std.serial, std.testing]
  srcs: [tests/main.sakura, tests/linear.sakura]

# The same tests built with `-O2`, which works vectors as lanes, and gives the
# same bits.
- name: malunal.linear.lanes.tests
  type: program
  runs: native
  level: 2
  deps: [malunal.linear, std.json, std.math, std.serial, std.testing]
  srcs: [tests/main.sakura, tests/linear.sakura]

# `malunal::geometry`'s, the same two ways.
- name: malunal.geometry.tests
  type: program
  deps: [malunal.geometry, malunal.linear, std.json, std.math, std.serial, std.testing]
  srcs: [tests/main.sakura, tests/geometry.sakura]

- name: malunal.geometry.lanes.tests
  type: program
  runs: native
  level: 2
  deps: [malunal.geometry, malunal.linear, std.json, std.math, std.serial, std.testing]
  srcs: [tests/main.sakura, tests/geometry.sakura]

- name: malunal.photometry.tests
  type: program
  deps: [malunal.linear, malunal.photometry, std.math, std.testing]
  srcs: [tests/main.sakura, tests/photometry.sakura]

- name: malunal.physics2d.tests
  type: program
  deps: [malunal.linear, malunal.physics2d, std.containers, std.math, std.testing]
  srcs: [tests/main.sakura, tests/physics2d.sakura, tests/space2d.sakura]

- name: malunal.physics3d.tests
  type: program
  deps: [malunal.geometry, malunal.linear, malunal.physics3d, std.containers, std.math, std.testing]
  srcs: [tests/main.sakura, tests/physics3d.sakura, tests/space3d.sakura]

exports:
- malunal.linear
- malunal.geometry
- malunal.photometry
- malunal.physics2d
- malunal.physics3d

package:
  desc: The numbers of physical space and what's in it. Vectors, quaternions, and matrices of f32, and the shapes of space made of them, worked as SIMD lanes where an executable holds them; light in the units it's measured in; and what collides and moves in a plane and in space, as rigid bodies.
  auth: John Christman <sorakatadzuma@gmail.com>
