Skip to content

Help with reducing package size #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ jobs:
# Check simd for compat builds
- name: Check 2d simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
if ! wasm-objdump -d rapier-compat/builds/rapier2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1;
fi
- name: Check 3d simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
if ! wasm-objdump -d rapier-compat/builds/rapier3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1;
fi
# Upload
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: minimal

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: npm ci
- name: Prepare minimal 2d build
working-directory: ./builds/prepare_builds/
run: |
cargo run -- -c assets/example_dim2_minimal.json
- name: install rapier-compat dependencies
working-directory: ./rapier-compat
run: npm ci;
- name: Build minimal 2d project
working-directory: ./builds/rapier2d-minimal
run: |
npm run build
- name: Build minimal 2d project compat
working-directory: ./rapier-compat
run: |
npm run build-conf -- example_dim2_minimal
36 changes: 26 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Note that `prepare_all_projects.sh` only needs to be run once. It needs to be re

The built packages will be in `builds/rapier2d/pkg`, `builds/rapier3d/pkg`, etc. To build the `-compat` variant of the
packages, run `npm run build` in the `rapier-compat` directory. Note that this will only work if you already ran
`prepare_all_projects.sh`. The compat packages are then generated in, e.g., `rapier-compat/builds/3d/pkg`.
`prepare_all_projects.sh`. The compat packages are then generated in, e.g., `rapier-compat/builds/rapier3d/pkg`.

## Feature selection

Expand Down
2 changes: 2 additions & 0 deletions builds/prepare_builds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ edition = "2021"
clap = { version = "4.5" }
clap_derive = { version = "4.5" }
tera = "1.20"
serde_json = "1"
serde = { version = "1", features = ["derive"] }
3 changes: 2 additions & 1 deletion builds/prepare_builds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ It uses clap so you can pass `-h` to get more info about its parameters.

## usage

At workspace root: `cargo run -p prepare_builds -- -d dim2 -f simd`.
In this directory: `cargo run -- -c assets/dim2.json`.
The configuration file contains relative links which are not made canonical so the call location is important.

Or use provided scripts: `./builds/prepare_builds/prepare_all_projects.sh && ./builds/prepare_builds/build_all_projects.sh`

Expand Down
10 changes: 10 additions & 0 deletions builds/prepare_builds/assets/dim2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dim": "2",
"additional_features": ["serde-serialize", "debug-render"],
"target_dir": "../rapier2d/",
"template_dir": "./templates/",
"additional_rust_flags": "",
"additional_wasm_opt_flags": [],
"js_package_name": "rapier2d",
"conditional_compilation_to_remove": ["DIM3"]
}
14 changes: 14 additions & 0 deletions builds/prepare_builds/assets/dim2_deterministic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dim": "2",
"additional_features": [
"serde-serialize",
"debug-render",
"enhanced-determinism"
],
"target_dir": "../rapier2d-deterministic",
"template_dir": "./templates/",
"additional_rust_flags": "",
"additional_wasm_opt_flags": [],
"js_package_name": "rapier2d-deterministic",
"conditional_compilation_to_remove": ["DIM3"]
}
10 changes: 10 additions & 0 deletions builds/prepare_builds/assets/dim2_simd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dim": "2",
"additional_features": ["serde-serialize", "debug-render", "simd-stable"],
"target_dir": "../rapier2d-simd",
"template_dir": "./templates/",
"additional_rust_flags": "-C target-feature=+simd128",
"additional_wasm_opt_flags": ["--enable-simd"],
"js_package_name": "rapier2d-simd",
"conditional_compilation_to_remove": ["DIM3"]
}
10 changes: 10 additions & 0 deletions builds/prepare_builds/assets/dim3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dim": "3",
"additional_features": ["serde-serialize", "debug-render"],
"target_dir": "../rapier3d/",
"template_dir": "./templates/",
"additional_rust_flags": "",
"additional_wasm_opt_flags": [],
"js_package_name": "rapier3d",
"conditional_compilation_to_remove": ["DIM2"]
}
14 changes: 14 additions & 0 deletions builds/prepare_builds/assets/dim3_deterministic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dim": "3",
"additional_features": [
"serde-serialize",
"debug-render",
"enhanced-determinism"
],
"target_dir": "../rapier3d-deterministic",
"template_dir": "./templates/",
"additional_rust_flags": "",
"additional_wasm_opt_flags": [],
"js_package_name": "rapier3d-deterministic",
"conditional_compilation_to_remove": ["DIM2"]
}
10 changes: 10 additions & 0 deletions builds/prepare_builds/assets/dim3_simd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dim": "3",
"additional_features": ["serde-serialize", "debug-render", "simd-stable"],
"target_dir": "../rapier3d-simd",
"template_dir": "./templates/",
"additional_rust_flags": "-C target-feature=+simd128",
"additional_wasm_opt_flags": ["--enable-simd"],
"js_package_name": "rapier3d-simd",
"conditional_compilation_to_remove": ["DIM2"]
}
14 changes: 14 additions & 0 deletions builds/prepare_builds/assets/example_dim2_minimal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dim": "2",
"additional_features": [],
"target_dir": "../rapier2d-minimal/",
"template_dir": "./templates/",
"additional_rust_flags": "",
"additional_wasm_opt_flags": [],
"js_package_name": "rapier2d-minimal",
"conditional_compilation_to_remove": [
"DIM3",
"SERDE_SERIALIZE",
"DEBUG_RENDER"
]
}
14 changes: 14 additions & 0 deletions builds/prepare_builds/assets/example_dim3_minimal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dim": "3",
"additional_features": [],
"target_dir": "../rapier3d-minimal/",
"template_dir": "./templates/",
"additional_rust_flags": "",
"additional_wasm_opt_flags": [],
"js_package_name": "rapier3d-minimal",
"conditional_compilation_to_remove": [
"DIM2",
"SERDE_SERIALIZE",
"DEBUG_RENDER"
]
}
2 changes: 1 addition & 1 deletion builds/prepare_builds/build_all_projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do
# FIXME: ideally we'd use `npm ci`
# but we'd need to have generated the `package-lock` beforehand and committed them in the repository.
# I'm not sure yet how to store those `package-lock`s yet though.
# They should proably be similar to all packages, but I'm not sure.
# They should probably be similar to all packages, but I'm not sure.
npm i;
npm run build;
)
Expand Down
13 changes: 6 additions & 7 deletions builds/prepare_builds/prepare_all_projects.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash

features=(non-deterministic deterministic simd)
dims=(dim2 dim3)
cd "$(dirname "$0")"

for feature in ${features[@]}; do
for dim in ${dims[@]}; do
echo "preparing dimension $dim with feature $feature"
cargo run -p prepare_builds -- -d ${dim} -f ${feature}
done
config_files=(dim2_deterministic dim2_simd dim2 dim3_deterministic dim3_simd dim3)

for config_path in ${config_files[@]}; do
echo "preparing dimension $dim with feature $feature"
cargo run -- -c assets/${config_path}.json
done
Loading