chore: 添加第三方依赖库
This commit is contained in:
9
thirdparty/rapier.js/builds/prepare_builds/Cargo.toml
vendored
Normal file
9
thirdparty/rapier.js/builds/prepare_builds/Cargo.toml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "prepare_builds"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5" }
|
||||
clap_derive = { version = "4.5" }
|
||||
tera = "1.20"
|
||||
17
thirdparty/rapier.js/builds/prepare_builds/README.md
vendored
Normal file
17
thirdparty/rapier.js/builds/prepare_builds/README.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Prepare builds
|
||||
|
||||
This project helps with making specific package: it takes a few parameter to create a (1) folder ready to compile.
|
||||
|
||||
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`.
|
||||
|
||||
Or use provided scripts: `./builds/prepare_builds/prepare_all_projects.sh && ./builds/prepare_builds/build_all_projects.sh`
|
||||
|
||||
## Technical considerations
|
||||
|
||||
Askama/rinja was not chosen because compiled templates make it difficult to iterate on a folder and parse all templates.
|
||||
|
||||
This folder is in `builds/` only for the workspace member glob to not complain if `builds/` is inexistent or empty.
|
||||
19
thirdparty/rapier.js/builds/prepare_builds/build_all_projects.sh
vendored
Normal file
19
thirdparty/rapier.js/builds/prepare_builds/build_all_projects.sh
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
for entry in builds/*
|
||||
do
|
||||
if [[ "$(basename "$entry")" == $(basename $(dirname "${BASH_SOURCE[0]}")) ]]; then
|
||||
echo "skipping directory: $entry"
|
||||
continue;
|
||||
fi
|
||||
(
|
||||
cd $entry
|
||||
echo "building $entry"
|
||||
# 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.
|
||||
npm i;
|
||||
npm run build;
|
||||
)
|
||||
done
|
||||
11
thirdparty/rapier.js/builds/prepare_builds/prepare_all_projects.sh
vendored
Normal file
11
thirdparty/rapier.js/builds/prepare_builds/prepare_all_projects.sh
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
features=(non-deterministic deterministic simd)
|
||||
dims=(dim2 dim3)
|
||||
|
||||
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
|
||||
done
|
||||
182
thirdparty/rapier.js/builds/prepare_builds/src/main.rs
vendored
Normal file
182
thirdparty/rapier.js/builds/prepare_builds/src/main.rs
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
use std::{
|
||||
error::Error,
|
||||
fs::{self, File},
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use clap::Parser;
|
||||
use clap_derive::{Parser, ValueEnum};
|
||||
use tera::{Context, Tera};
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
/// Dimension to use
|
||||
#[arg(short, long)]
|
||||
dim: Dimension,
|
||||
|
||||
/// Features to enable
|
||||
#[arg(short, long)]
|
||||
feature_set: FeatureSet,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Debug, Clone, Copy)]
|
||||
pub enum Dimension {
|
||||
Dim2,
|
||||
Dim3,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Default, Debug, Clone, Copy)]
|
||||
pub enum FeatureSet {
|
||||
#[default]
|
||||
NonDeterministic,
|
||||
Deterministic,
|
||||
Simd,
|
||||
}
|
||||
|
||||
/// Values to use when creating the new build folder.
|
||||
pub struct BuildValues {
|
||||
/// Only the number of dimensions, as sometimes it will be prefixed by "dim" and sometimes post-fixed by "d".
|
||||
pub dim: String,
|
||||
/// real name of the additional features to enable in the project
|
||||
pub feature_set: Vec<String>,
|
||||
pub target_dir: PathBuf,
|
||||
pub template_dir: PathBuf,
|
||||
pub additional_rust_flags: String,
|
||||
pub additional_wasm_opt_flags: Vec<String>,
|
||||
pub js_package_name: String,
|
||||
}
|
||||
|
||||
impl BuildValues {
|
||||
pub fn new(args: Args) -> Self {
|
||||
let dim = match args.dim {
|
||||
Dimension::Dim2 => "2",
|
||||
Dimension::Dim3 => "3",
|
||||
};
|
||||
let feature_set = match args.feature_set {
|
||||
FeatureSet::NonDeterministic => vec![],
|
||||
FeatureSet::Deterministic => vec!["enhanced-determinism"],
|
||||
FeatureSet::Simd => vec!["simd-stable"],
|
||||
};
|
||||
let js_package_name = match args.feature_set {
|
||||
FeatureSet::NonDeterministic => format!("rapier{dim}d"),
|
||||
FeatureSet::Deterministic => format!("rapier{dim}d-deterministic"),
|
||||
FeatureSet::Simd => format!("rapier{dim}d-simd"),
|
||||
};
|
||||
|
||||
let root: PathBuf = env!("CARGO_MANIFEST_DIR").into();
|
||||
|
||||
Self {
|
||||
dim: dim.to_string(),
|
||||
feature_set: feature_set.iter().map(|f| f.to_string()).collect(),
|
||||
template_dir: root.join("templates/").clone(),
|
||||
target_dir: root.parent().unwrap().join(&js_package_name).into(),
|
||||
additional_rust_flags: match args.feature_set {
|
||||
FeatureSet::Simd => "RUSTFLAGS='-C target-feature=+simd128'".to_string(),
|
||||
_ => "".to_string(),
|
||||
},
|
||||
additional_wasm_opt_flags: match args.feature_set {
|
||||
FeatureSet::Simd => vec!["--enable-simd".to_string()],
|
||||
_ => vec![],
|
||||
},
|
||||
js_package_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
dbg!(&args);
|
||||
|
||||
let build_values = BuildValues::new(args);
|
||||
copy_top_level_files_in_directory(&build_values.template_dir, &build_values.target_dir)
|
||||
.expect("Failed to copy directory");
|
||||
process_templates(&build_values).expect("Failed to process templates");
|
||||
}
|
||||
|
||||
fn copy_top_level_files_in_directory(
|
||||
src: impl AsRef<Path>,
|
||||
dest: impl AsRef<std::ffi::OsStr>,
|
||||
) -> std::io::Result<()> {
|
||||
let src = src.as_ref();
|
||||
let dest = Path::new(&dest);
|
||||
if dest.exists() {
|
||||
fs::remove_dir_all(&dest)?;
|
||||
}
|
||||
fs::create_dir_all(&dest)?;
|
||||
|
||||
for entry in fs::read_dir(src)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
let dest_path = dest.join(path.file_name().unwrap());
|
||||
|
||||
if !path.is_dir() {
|
||||
fs::copy(&path, &dest_path)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Process all tera templates in the target directory:
|
||||
/// - Remove the extension
|
||||
/// - Render the templates to
|
||||
///
|
||||
fn process_templates(build_values: &BuildValues) -> std::io::Result<()> {
|
||||
let target_dir = build_values.target_dir.clone();
|
||||
|
||||
let mut context = Context::new();
|
||||
context.insert("dimension", &build_values.dim);
|
||||
context.insert("additional_features", &build_values.feature_set);
|
||||
context.insert("additional_rust_flags", &build_values.additional_rust_flags);
|
||||
context.insert(
|
||||
"additional_wasm_opt_flags",
|
||||
&build_values.additional_wasm_opt_flags,
|
||||
);
|
||||
context.insert("js_package_name", &build_values.js_package_name);
|
||||
|
||||
let tera = match Tera::new(target_dir.join("**/*.tera").to_str().unwrap()) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
eprintln!("Parsing error(s): {}", e);
|
||||
::std::process::exit(1);
|
||||
}
|
||||
};
|
||||
dbg!(tera.templates.keys(), &context);
|
||||
|
||||
for entry in fs::read_dir(target_dir)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
// For tera templates, remove extension.
|
||||
if path.extension() == Some(std::ffi::OsStr::new("tera")) {
|
||||
let mut i = path.iter();
|
||||
|
||||
// Get path from target directory
|
||||
for _ in i
|
||||
.by_ref()
|
||||
.take_while(|c| *c != build_values.target_dir.file_name().unwrap())
|
||||
{}
|
||||
let path_template = i.as_path();
|
||||
match tera.render(path_template.to_str().unwrap(), &context) {
|
||||
Ok(s) => {
|
||||
let old_path = path.clone();
|
||||
let new_path = path.with_extension("");
|
||||
let mut file = File::create(path.join(new_path))?;
|
||||
file.write_all(s.as_bytes())?;
|
||||
std::fs::remove_file(old_path)?;
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error: {}", e);
|
||||
let mut cause = e.source();
|
||||
while let Some(e) = cause {
|
||||
eprintln!("Reason: {}", e);
|
||||
cause = e.source();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
60
thirdparty/rapier.js/builds/prepare_builds/templates/Cargo.toml.tera
vendored
Normal file
60
thirdparty/rapier.js/builds/prepare_builds/templates/Cargo.toml.tera
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
[package]
|
||||
name = "dimforge_{{ js_package_name }}" # Can't be named rapier{{ dimension }}d which conflicts with the dependency.
|
||||
version = "0.19.3"
|
||||
authors = ["Sébastien Crozet <developer@crozet.re>"]
|
||||
description = "{{ dimension }}-dimensional physics engine in Rust - official JS bindings."
|
||||
documentation = "https://rapier.rs/rustdoc/rapier{{ dimension }}d/index.html"
|
||||
homepage = "https://rapier.rs"
|
||||
repository = "https://github.com/dimforge/rapier.js"
|
||||
readme = "README.md"
|
||||
keywords = ["physics", "dynamics", "rigid", "real-time", "joints"]
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = ["dim{{ dimension }}"]
|
||||
dim{{ dimension }} = []
|
||||
|
||||
[lib]
|
||||
name = "rapier_wasm{{ dimension }}d"
|
||||
path = "../../src/lib.rs"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
required-features = ["dim{{ dimension }}"]
|
||||
|
||||
[lints]
|
||||
rust.unexpected_cfgs = { level = "warn", check-cfg = [
|
||||
'cfg(feature, values("dim{% if dimension == "2" %}3{% else %}2{% endif %}"))',
|
||||
] }
|
||||
|
||||
[dependencies]
|
||||
rapier{{ dimension }}d = { version = "0.30.1", features = [
|
||||
"serde-serialize",
|
||||
"debug-render",
|
||||
"profiler",
|
||||
{%- for feature in additional_features %}
|
||||
"{{ feature }}",
|
||||
{%- endfor %}
|
||||
] }
|
||||
# The explicit dependency to parry only needed to pin the patch version.
|
||||
parry{{ dimension }}d = { version = "^0.25.3" }
|
||||
ref-cast = "1"
|
||||
wasm-bindgen = "0.2.100"
|
||||
js-sys = "0.3"
|
||||
nalgebra = "0.34"
|
||||
serde = { version = "1", features = ["derive", "rc"] }
|
||||
bincode = "1"
|
||||
palette = "0.7"
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
# add -g to keep debug symbols
|
||||
wasm-opt = [
|
||||
'-O4',
|
||||
'--dce',
|
||||
# The two options below are needed because of: https://github.com/rustwasm/wasm-pack/issues/1501
|
||||
'--enable-bulk-memory',
|
||||
'--enable-nontrapping-float-to-int',
|
||||
{%- for flag in additional_wasm_opt_flags %}
|
||||
'{{ flag }}',
|
||||
{%- endfor %}
|
||||
]
|
||||
#wasm-opt = ['-g']
|
||||
201
thirdparty/rapier.js/builds/prepare_builds/templates/LICENSE
vendored
Normal file
201
thirdparty/rapier.js/builds/prepare_builds/templates/LICENSE
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020 Dimforge EURL
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
70
thirdparty/rapier.js/builds/prepare_builds/templates/README.md.tera
vendored
Normal file
70
thirdparty/rapier.js/builds/prepare_builds/templates/README.md.tera
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<p align="center">
|
||||
<img src="https://www.rapier.rs/img/rapier_logo_color_textpath_dark.svg" alt="crates.io">
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/vt9DJSW">
|
||||
<img src="https://img.shields.io/discord/507548572338880513.svg?logo=discord&colorB=7289DA">
|
||||
</a>
|
||||
<a href="https://github.com/dimforge/rapier.js/actions">
|
||||
<img src="https://github.com/dimforge/rapier.js/workflows/main/badge.svg" alt="Build status">
|
||||
</a>
|
||||
<a href="https://crates.io/crates/rapier{{ dimension }}d">
|
||||
<img src="https://img.shields.io/crates/v/rapier{{ dimension }}d.svg?style=flat-square" alt="crates.io">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@dimforge/rapier{{ dimension }}d">
|
||||
<img src="https://badge.fury.io/js/%40dimforge%2Frapier{{ dimension }}d.svg" alt="npm version">
|
||||
</a>
|
||||
<a href="https://opensource.org/licenses/Apache-2.0">
|
||||
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg">
|
||||
</a>
|
||||
</p>
|
||||
<p align = "center">
|
||||
<strong>
|
||||
<a href="https://rapier.rs">Website</a> | <a href="https://rapier.rs/docs/">Documentation</a>
|
||||
</strong>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
<p align = "center">
|
||||
<b>{{ dimension }}D physics engine</b>
|
||||
<i>for the JavaScript programming language (official bindings).</i>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## Feature selection
|
||||
|
||||
Multiple NPM packages exist for Rapier, depending on your needs:
|
||||
- [`@dimforge/rapier2d`](https://www.npmjs.com/package/@dimforge/rapier2d) or
|
||||
[`@dimforge/rapier3d`](https://www.npmjs.com/package/@dimforge/rapier3d):
|
||||
The main build of the Rapier physics engine for 2D or 3D physics simulation. This should have wide browser
|
||||
support while offering great performances. This does **not** guarantee cross-platform determinism of the physics
|
||||
simulation (but it is still locally deterministic, on the same machine).
|
||||
- [`@dimforge/rapier2d-simd`](https://www.npmjs.com/package/@dimforge/rapier2d-simd) or
|
||||
[`@dimforge/rapier3d-simd`](https://www.npmjs.com/package/@dimforge/rapier3d-simd):
|
||||
A build with internal SIMD optimizations enabled. More limited browser support (requires support for [simd128](https://caniuse.com/?search=simd)).
|
||||
- [`@dimforge/rapier2d-deterministic`](https://www.npmjs.com/package/@dimforge/rapier2d-deterministic) or
|
||||
[`@dimforge/rapier3d-deterministic`](https://www.npmjs.com/package/@dimforge/rapier3d-deterministic):
|
||||
A less optimized build but with a guarantee of a cross-platform deterministic execution of the physics simulation.
|
||||
|
||||
## Bundler support
|
||||
|
||||
Some bundlers will struggle with the `.wasm` file package into the builds above. Alternative `-compat` versions exist
|
||||
which embed the `.wasm` file into the `.js` sources encoded with base64. This results in a bigger package size, but
|
||||
much wider bundler support.
|
||||
|
||||
Just append `-compat` to the build you are interested in:
|
||||
[`rapier2d-compat`](https://www.npmjs.com/package/@dimforge/rapier2d-compat),
|
||||
[`rapier2d-simd-compat`](https://www.npmjs.com/package/@dimforge/rapier2d-simd-compat),
|
||||
[`rapier2d-deterministic-compat`](https://www.npmjs.com/package/@dimforge/rapier2d-deterministic-compat),
|
||||
[`rapier3d-compat`](https://www.npmjs.com/package/@dimforge/rapier3d-compat),
|
||||
[`rapier3d-simd-compat`](https://www.npmjs.com/package/@dimforge/rapier3d-simd-compat),
|
||||
[`rapier3d-deterministic-compat`](https://www.npmjs.com/package/@dimforge/rapier3d-deterministic-compat).
|
||||
|
||||
## Nightly builds
|
||||
|
||||
Each time a new Pull Request is merged to the `main` branch of the [`rapier.js` repository](https://github.com/dimforge/rapier.js),
|
||||
an automatic _canary_ build is triggered. Builds published to npmjs under the _canary_ tag does not come with any
|
||||
stability guarantee and does not follow semver versioning. But it can be a useful solution to try out the latest
|
||||
features until a proper release is cut.
|
||||
15
thirdparty/rapier.js/builds/prepare_builds/templates/build_rust.sh.tera
vendored
Normal file
15
thirdparty/rapier.js/builds/prepare_builds/templates/build_rust.sh.tera
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Cleaning rust because changing rust flags may lead to different build results.
|
||||
cargo clean
|
||||
|
||||
{{ additional_rust_flags }} npx wasm-pack build
|
||||
sed -i.bak 's#dimforge_rapier#@dimforge/rapier#g' pkg/package.json
|
||||
sed -i.bak 's/"rapier_wasm{{ dimension }}d_bg.wasm"/"*"/g' pkg/package.json
|
||||
(
|
||||
cd pkg
|
||||
npm pkg delete sideEffects
|
||||
npm pkg set 'sideEffects[0]'="./*.js"
|
||||
)
|
||||
rm pkg/*.bak
|
||||
rm pkg/.gitignore
|
||||
13
thirdparty/rapier.js/builds/prepare_builds/templates/build_typescript.sh.tera
vendored
Normal file
13
thirdparty/rapier.js/builds/prepare_builds/templates/build_typescript.sh.tera
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#! /bin/sh
|
||||
|
||||
mkdir -p ./pkg/src
|
||||
cp -r ../../src.ts/* pkg/src/.
|
||||
rm -f ./pkg/raw.ts
|
||||
echo 'export * from "./rapier_wasm{{ dimension }}d"' > pkg/src/raw.ts
|
||||
# See https://serverfault.com/a/137848
|
||||
find pkg/ -type f -print0 | LC_ALL=C xargs -0 sed -i.bak '\:#if DIM{% if dimension == "2" %}3{% else %}2{% endif %}:,\:#endif:d'
|
||||
npx tsc
|
||||
# NOTE: we keep the typescripts files into the NPM package for source mapping: see #3
|
||||
sed -i.bak 's/"module": "rapier_wasm{{ dimension }}d.js"/"module": "rapier.js"/g' pkg/package.json
|
||||
sed -i.bak 's/"types": "rapier_wasm{{ dimension }}d.d.ts"/"types": "rapier.d.ts"/g' pkg/package.json
|
||||
find pkg/ -type f -name '*.bak' | xargs rm
|
||||
25
thirdparty/rapier.js/builds/prepare_builds/templates/package.json.tera
vendored
Normal file
25
thirdparty/rapier.js/builds/prepare_builds/templates/package.json.tera
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@dimforge/{{ js_package_name }}",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"exports": "./pkg",
|
||||
"types": "./pkg/rapier.d.ts",
|
||||
"scripts": {
|
||||
"build": "npm run clean && npm run build:wasm && npm run build:ts && npm run build:doc",
|
||||
"build:doc": "typedoc --tsconfig tsconfig_typedoc.json",
|
||||
"build:wasm": "sh ./build_rust.sh",
|
||||
"build:ts": "sh ./build_typescript.sh",
|
||||
"clean": "rimraf pkg"
|
||||
},
|
||||
"//": "Better keep rimraf version in sync with wasm-pack, see https://github.com/rustwasm/wasm-pack/issues/1444",
|
||||
"devDependencies": {
|
||||
"rimraf": "^3.0.2",
|
||||
"typedoc": "^0.25.13"
|
||||
},
|
||||
"dependencies": {
|
||||
"wasm-pack": "^0.12.1"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./*.js"
|
||||
]
|
||||
}
|
||||
13
thirdparty/rapier.js/builds/prepare_builds/templates/tsconfig.json
vendored
Normal file
13
thirdparty/rapier.js/builds/prepare_builds/templates/tsconfig.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./pkg",
|
||||
"module": "ES6",
|
||||
"target": "es6",
|
||||
"lib": ["es6"],
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"rootDirs": ["./pkg", "./pkg/src"]
|
||||
},
|
||||
"files": ["./pkg/src/rapier.ts"]
|
||||
}
|
||||
10
thirdparty/rapier.js/builds/prepare_builds/templates/tsconfig_typedoc.json
vendored
Normal file
10
thirdparty/rapier.js/builds/prepare_builds/templates/tsconfig_typedoc.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./pkg",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"lib": ["es6"]
|
||||
},
|
||||
"files": ["./pkg/rapier.d.ts"]
|
||||
}
|
||||
42
thirdparty/rapier.js/builds/prepare_builds/templates/typedoc.json.tera
vendored
Normal file
42
thirdparty/rapier.js/builds/prepare_builds/templates/typedoc.json.tera
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"$schema": "https://typedoc.org/schema.json",
|
||||
"entryPoints": [
|
||||
"./pkg/rapier.d.ts"
|
||||
],
|
||||
"out": "./docs",
|
||||
"readme": "none",
|
||||
"excludeExternals": true,
|
||||
"excludeNotDocumented": false,
|
||||
"intentionallyNotExported": [
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawBroadPhase",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawCCDSolver",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawColliderSet",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawEventQueue",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawImpulseJointSet",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawMultibodyJointSet",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawIntegrationParameters",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawIslandManager",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawNarrowPhase",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawPhysicsPipeline",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawRigidBodySet",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawSerializationPipeline",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawContactManifold",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawShape",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawGenericJoint",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawJointAxis",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawRotation",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawVector",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawPointColliderProjection",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawPointProjection",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawRayColliderIntersection",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawRayColliderHit",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawRayIntersection",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawColliderShapeCastHit",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawShapeContact",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawShapeCastHit",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawQueryPipeline",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawDeserializedWorld",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawDebugRenderPipeline",
|
||||
"pkg/rapier_wasm{{ dimension }}d.d.ts:RawContactForceEvent"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user