diff --git a/.github/workflows/rust-documentation.yml b/.github/workflows/rust-documentation.yml
index ffb2fd12b1..b85b567ba8 100644
--- a/.github/workflows/rust-documentation.yml
+++ b/.github/workflows/rust-documentation.yml
@@ -24,9 +24,7 @@ jobs:
toolchain: stable
- name: Build documentation
run: |
- cd rust
- cargo doc --all --no-deps
- cd ..
+ cargo doc --package libceed-sys --package libceed --no-deps
touch ./target/doc/.nojekyll
echo "" > ./target/doc/index.html
- name: Deploy documentation
diff --git a/Cargo.toml b/Cargo.toml
index 916a2cfe94..99aa809ec6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,7 @@
[workspace]
members = [
- "rust",
+ "rust/libceed",
+ "rust/libceed-sys",
"examples/rust/ex1-volume",
"examples/rust/ex2-surface",
]
diff --git a/doc/sphinx/source/ffi.rst b/doc/sphinx/source/ffi.rst
index f313843d22..714e484d92 100644
--- a/doc/sphinx/source/ffi.rst
+++ b/doc/sphinx/source/ffi.rst
@@ -9,7 +9,7 @@ documentation `_.
Usage of the Python interface is illustrated through a sequence of `Jupyter
Notebook tutorials
-`_. More
+`_. More
information on the Python interface is available in the `SciPy paper
`_.
diff --git a/examples/tutorials/img/QFunctionSketch.svg b/examples/python/img/QFunctionSketch.svg
similarity index 100%
rename from examples/tutorials/img/QFunctionSketch.svg
rename to examples/python/img/QFunctionSketch.svg
diff --git a/examples/tutorials/tutorial-0-ceed.ipynb b/examples/python/tutorial-0-ceed.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-0-ceed.ipynb
rename to examples/python/tutorial-0-ceed.ipynb
diff --git a/examples/tutorials/tutorial-1-vector.ipynb b/examples/python/tutorial-1-vector.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-1-vector.ipynb
rename to examples/python/tutorial-1-vector.ipynb
diff --git a/examples/tutorials/tutorial-2-elemrestriction.ipynb b/examples/python/tutorial-2-elemrestriction.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-2-elemrestriction.ipynb
rename to examples/python/tutorial-2-elemrestriction.ipynb
diff --git a/examples/tutorials/tutorial-3-basis.ipynb b/examples/python/tutorial-3-basis.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-3-basis.ipynb
rename to examples/python/tutorial-3-basis.ipynb
diff --git a/examples/tutorials/tutorial-4-qfunction.ipynb b/examples/python/tutorial-4-qfunction.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-4-qfunction.ipynb
rename to examples/python/tutorial-4-qfunction.ipynb
diff --git a/examples/tutorials/tutorial-5-operator.ipynb b/examples/python/tutorial-5-operator.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-5-operator.ipynb
rename to examples/python/tutorial-5-operator.ipynb
diff --git a/examples/tutorials/tutorial-6-shell.ipynb b/examples/python/tutorial-6-shell.ipynb
similarity index 100%
rename from examples/tutorials/tutorial-6-shell.ipynb
rename to examples/python/tutorial-6-shell.ipynb
diff --git a/examples/rust/ex1-volume/Cargo.toml b/examples/rust/ex1-volume/Cargo.toml
index c91091a708..b53a007b88 100644
--- a/examples/rust/ex1-volume/Cargo.toml
+++ b/examples/rust/ex1-volume/Cargo.toml
@@ -8,5 +8,5 @@ edition = "2018"
[dependencies]
structopt = { version = "0.3", default-features = false }
-libceed = { path = "../../../rust" }
+libceed = { path = "../../../rust/libceed" }
mesh = { path = "../mesh" }
diff --git a/examples/rust/ex2-surface/Cargo.toml b/examples/rust/ex2-surface/Cargo.toml
index 264b4f1da2..d2c14afd9f 100644
--- a/examples/rust/ex2-surface/Cargo.toml
+++ b/examples/rust/ex2-surface/Cargo.toml
@@ -8,5 +8,5 @@ edition = "2018"
[dependencies]
structopt = { version = "0.3", default-features = false }
-libceed = { path = "../../../rust" }
+libceed = { path = "../../../rust/libceed" }
mesh = { path = "../mesh" }
diff --git a/examples/rust/mesh/Cargo.toml b/examples/rust/mesh/Cargo.toml
index 7c48e62a13..4cba573c3f 100644
--- a/examples/rust/mesh/Cargo.toml
+++ b/examples/rust/mesh/Cargo.toml
@@ -7,4 +7,4 @@ authors = [
edition = "2018"
[dependencies]
-libceed = { path = "../../../rust" }
+libceed = { path = "../../../rust/libceed" }
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
deleted file mode 100644
index dffc4cd993..0000000000
--- a/rust/Cargo.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-[package]
-authors = [
- "Jed Brown ",
- "Yohann Dudouit ",
- "Jeremy L Thompson ",
-]
-build = "build.rs"
-name = "libceed"
-version = "0.8.0"
-links = "libceed"
-edition = "2018"
-
-[lib]
-name = "libceed"
-
-[features]
-default = ["static"]
-static = []
-system = []
-
-[build-dependencies]
-bindgen = "*"
-pkg-config = "0.3.19"
-
-[dev-dependencies]
-version-sync = "*"
diff --git a/rust/.gitignore b/rust/libceed-sys/.gitignore
similarity index 100%
rename from rust/.gitignore
rename to rust/libceed-sys/.gitignore
diff --git a/rust/libceed-sys/Cargo.toml b/rust/libceed-sys/Cargo.toml
new file mode 100644
index 0000000000..120263973a
--- /dev/null
+++ b/rust/libceed-sys/Cargo.toml
@@ -0,0 +1,37 @@
+[package]
+authors = [
+ "Jed Brown ",
+ "Yohann Dudouit ",
+ "Jeremy L Thompson ",
+]
+build = "build.rs"
+name = "libceed-sys"
+version = "0.8.0"
+links = "libceed-sys"
+edition = "2018"
+license = "BSD-2-Clause"
+repository = "https://github.com/CEED/libCEED"
+documentation = "https://libceed.readthedocs.io/en/latest/"
+description = """
+Low-level bindings for libCEED library.
+"""
+keywords = ["libceed", "exascale", "high-order"]
+categories = ["science"]
+include = [
+ "build.rs",
+ "README.md",
+ "src/**",
+ "c-src/**",
+]
+
+[features]
+default = ["static"]
+static = []
+system = []
+
+[build-dependencies]
+bindgen = "0.58.1"
+pkg-config = "0.3.19"
+
+[dev-dependencies]
+version-sync = "0.9.2"
diff --git a/rust/libceed-sys/README.md b/rust/libceed-sys/README.md
new file mode 100644
index 0000000000..ef14034fc3
--- /dev/null
+++ b/rust/libceed-sys/README.md
@@ -0,0 +1,75 @@
+# libceed-sys: unsafe bindings to libCEED
+
+This is the documentation for the low level (unsafe) Rust bindings to the libCEED C
+interface. See the [libCEED user manual](https://libceed.readthedocs.io) for usage
+information. Note that most Rust users will prefer the higher level (safe) Rust
+interface in the [`libceed` crate](https://docs.rs/libceed).
+
+libCEED is a low-level API for for the efficient high-order discretization methods
+developed by the ECP co-design Center for Efficient Exascale Discretizations (CEED).
+While our focus is on high-order finite elements, the approach is mostly algebraic
+and thus applicable to other discretizations in factored form.
+
+## Usage
+
+To use low level libCEED bindings in a Rust package, the following `Cargo.toml`
+can be used.
+```toml
+[dependencies]
+libceed-sys = "0.8.0"
+```
+
+For a development version of the libCEED Rust bindings, use the following `Cargo.toml`.
+```toml
+[dependencies]
+libceed-sys = { git = "https://github.com/CEED/libCEED", branch = "main" }
+```
+
+Supported features:
+* `static` (default): link to static libceed.a
+* `system`: use libceed from a system directory (otherwise, install from source)
+
+## Development
+
+To develop libCEED, use `cargo build` in the `rust/libceed-sys` directory to
+install a local copy and build the bindings.
+
+If you need custom flags for the C project, we recommend using `make -C c-src
+configure` to cache arguments in `c-src/config.mk`. If that file exists during
+`cargo build` then edits will prompt recompilation of the bindings.
+
+### Shared libraries
+If one is developing libCEED C source and testing multiple language bindings at
+once, a few seconds can be cut out of the edit/compile/test loop by disabling
+the `static` feature and using
+
+```bash
+export LD_LIBRARY_PATH=$CEED_DIR/lib
+export PKG_CONFIG_PATH=$CEED_DIR/lib/pkgconfig
+```
+
+#### Without system
+If you disable the `static` feature and are not using a system version from a
+standard path/somewhere that can be found by pkg-config, then you'll need to set
+`LD_LIBRARY_PATH` to the appropriate target directory for doctests to be able to
+find it. This might look like
+
+```bash
+export LD_LIBRARY_PATH=$CEED_DIR/target/debug/build/libceed-sys-d1ea22c6e1ad3f23/out/lib
+```
+
+where the precise hash value is printed during `cargo build --verbose` or you
+can find it with `find target -name libceed.so`. This mode of development is
+more fragile than the default (which uses static libraries).
+
+Note that the `LD_LIBRARY_PATH` workarounds will become unnecessary if [this
+issue](https://github.com/rust-lang/cargo/issues/1592) is resolved -- it's
+currently closed, but the problem still exists.
+
+## License: BSD-2-Clause
+
+## Contributing
+
+The `libceed-sys` crate is developed within the [libCEED
+repository](https://github.com/CEED/libCEED). See the [contributing
+guidelines](https://libceed.readthedocs.io/en/latest/CONTRIBUTING/) for details.
diff --git a/rust/build.rs b/rust/libceed-sys/build.rs
similarity index 67%
rename from rust/build.rs
rename to rust/libceed-sys/build.rs
index edcc285d01..ad661eead3 100644
--- a/rust/build.rs
+++ b/rust/libceed-sys/build.rs
@@ -1,7 +1,7 @@
extern crate bindgen;
extern crate pkg_config;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::process::Command;
fn main() {
@@ -17,8 +17,16 @@ fn main() {
let mut make = Command::new("make");
make.arg("install")
.arg(format!("prefix={}", out_dir.to_string_lossy()))
+ .arg(format!(
+ "OBJDIR={}",
+ out_dir.join("build").to_string_lossy()
+ ))
+ .arg(format!(
+ "LIBDIR={}",
+ out_dir.join("build").join("lib").to_string_lossy()
+ ))
.env("MAKEFLAGS", makeflags)
- .current_dir("..");
+ .current_dir("c-src");
if statik {
make.arg("STATIC=1");
}
@@ -37,9 +45,11 @@ fn main() {
.unwrap();
// Tell cargo to invalidate the built crate whenever the wrapper changes
- println!("cargo:rerun-if-changed=../include/ceed/ceed.h");
- println!("cargo:rerun-if-changed=../Makefile");
- println!("cargo:rerun-if-changed=../config.mk");
+ println!("cargo:rerun-if-changed=c-src/include/ceed/ceed.h");
+ println!("cargo:rerun-if-changed=c-src/Makefile");
+ if Path::new("c-src/config.mk").is_file() {
+ println!("cargo:rerun-if-changed=c-src/config.mk");
+ }
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
@@ -47,7 +57,17 @@ fn main() {
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
- .header("../include/ceed/ceed.h")
+ .header("c-src/include/ceed/ceed.h")
+ .allowlist_function("Ceed.*")
+ .allowlist_type("Ceed.*")
+ .allowlist_var("Ceed.*")
+ .allowlist_var("CEED_.*")
+ // Don't chase recursive definitions of these system types
+ .opaque_type("FILE")
+ .opaque_type("va_list")
+ // Accessing directly here, but perhaps should use libc crate
+ .allowlist_function("fclose")
+ .allowlist_function("open_memstream")
// Tell cargo to not mangle the function names
.trust_clang_mangling(false)
// Tell cargo to invalidate the built crate whenever any of the
diff --git a/rust/libceed-sys/c-src/Makefile b/rust/libceed-sys/c-src/Makefile
new file mode 120000
index 0000000000..62a7b627cb
--- /dev/null
+++ b/rust/libceed-sys/c-src/Makefile
@@ -0,0 +1 @@
+../../../Makefile
\ No newline at end of file
diff --git a/rust/libceed-sys/c-src/backends b/rust/libceed-sys/c-src/backends
new file mode 120000
index 0000000000..ed68dbd766
--- /dev/null
+++ b/rust/libceed-sys/c-src/backends
@@ -0,0 +1 @@
+../../../backends
\ No newline at end of file
diff --git a/rust/libceed-sys/c-src/ceed.pc.template b/rust/libceed-sys/c-src/ceed.pc.template
new file mode 120000
index 0000000000..ce3ca148bd
--- /dev/null
+++ b/rust/libceed-sys/c-src/ceed.pc.template
@@ -0,0 +1 @@
+../../../ceed.pc.template
\ No newline at end of file
diff --git a/rust/libceed-sys/c-src/common.mk b/rust/libceed-sys/c-src/common.mk
new file mode 120000
index 0000000000..87cff4ccc2
--- /dev/null
+++ b/rust/libceed-sys/c-src/common.mk
@@ -0,0 +1 @@
+../../../common.mk
\ No newline at end of file
diff --git a/rust/libceed-sys/c-src/gallery b/rust/libceed-sys/c-src/gallery
new file mode 120000
index 0000000000..aee43a7d52
--- /dev/null
+++ b/rust/libceed-sys/c-src/gallery
@@ -0,0 +1 @@
+../../../gallery
\ No newline at end of file
diff --git a/rust/libceed-sys/c-src/include b/rust/libceed-sys/c-src/include
new file mode 120000
index 0000000000..8a5dba6c4b
--- /dev/null
+++ b/rust/libceed-sys/c-src/include
@@ -0,0 +1 @@
+../../../include
\ No newline at end of file
diff --git a/rust/libceed-sys/c-src/interface b/rust/libceed-sys/c-src/interface
new file mode 120000
index 0000000000..309ed01799
--- /dev/null
+++ b/rust/libceed-sys/c-src/interface
@@ -0,0 +1 @@
+../../../interface
\ No newline at end of file
diff --git a/rust/libceed-sys/src/lib.rs b/rust/libceed-sys/src/lib.rs
new file mode 100644
index 0000000000..98b0cb9576
--- /dev/null
+++ b/rust/libceed-sys/src/lib.rs
@@ -0,0 +1,30 @@
+// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
+// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
+// reserved. See files LICENSE and NOTICE for details.
+//
+// This file is part of CEED, a collection of benchmarks, miniapps, software
+// libraries and APIs for efficient high-order finite element and spectral
+// element discretizations for exascale applications. For more information and
+// source code availability see http://github.com/ceed.
+//
+// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
+// a collaborative effort of two U.S. Department of Energy organizations (Office
+// of Science and the National Nuclear Security Administration) responsible for
+// the planning and preparation of a capable exascale ecosystem, including
+// software, applications, hardware, advanced system engineering and early
+// testbed platforms, in support of the nation's exascale computing imperative
+
+#![doc = include_str!("../README.md")]
+
+/**
+Bindings generated from libCEED's C headers using bindgen.
+
+See `build.rs` to customize the process and refer to the [libCEED API
+docs](https://libceed.readthedocs.io/en/latest/api/) for usage.
+*/
+pub mod bind_ceed {
+ #![allow(non_upper_case_globals)]
+ #![allow(non_camel_case_types)]
+ #![allow(dead_code)]
+ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
+}
diff --git a/rust/libceed-sys/tests/register.rs b/rust/libceed-sys/tests/register.rs
new file mode 100644
index 0000000000..259eec110b
--- /dev/null
+++ b/rust/libceed-sys/tests/register.rs
@@ -0,0 +1,8 @@
+/// Basic smoke test to confirm that the library is callable.
+#[test]
+fn test_import() {
+ use libceed_sys::bind_ceed;
+ unsafe {
+ bind_ceed::CeedRegisterAll();
+ }
+}
diff --git a/rust/libceed-sys/tests/version-numbers.rs b/rust/libceed-sys/tests/version-numbers.rs
new file mode 100644
index 0000000000..8403975756
--- /dev/null
+++ b/rust/libceed-sys/tests/version-numbers.rs
@@ -0,0 +1,18 @@
+use std::path::{Path, PathBuf};
+
+fn get_rel_path(rel: impl AsRef) -> PathBuf {
+ let path = std::env::current_dir().unwrap();
+ if path.ends_with("rust/libceed-sys") {
+ rel.as_ref().to_path_buf()
+ } else {
+ Path::new("rust/libceed-sys").join(rel)
+ }
+}
+
+#[test]
+fn test_doc_version() {
+ version_sync::assert_contains_regex!(
+ get_rel_path("README.md").to_str().unwrap(),
+ "{name} = \"{version}\""
+ );
+}
diff --git a/rust/libceed/.gitignore b/rust/libceed/.gitignore
new file mode 100644
index 0000000000..a9d37c560c
--- /dev/null
+++ b/rust/libceed/.gitignore
@@ -0,0 +1,2 @@
+target
+Cargo.lock
diff --git a/rust/libceed/Cargo.toml b/rust/libceed/Cargo.toml
new file mode 100644
index 0000000000..58f90f9362
--- /dev/null
+++ b/rust/libceed/Cargo.toml
@@ -0,0 +1,23 @@
+[package]
+authors = [
+ "Jed Brown ",
+ "Yohann Dudouit ",
+ "Jeremy L Thompson ",
+]
+name = "libceed"
+version = "0.8.0"
+edition = "2018"
+license = "BSD-2-Clause"
+repository = "https://github.com/CEED/libCEED"
+documentation = "https://libceed.readthedocs.io/en/latest/"
+description = """
+High-level interface for libCEED - the efficient high-order discretization library developed by the ECP co-design center CEED.
+"""
+keywords = ["libceed", "exascale", "high-order"]
+categories = ["science"]
+
+[dependencies]
+libceed-sys = { version = "0.8", path = "../libceed-sys" }
+
+[dev-dependencies]
+version-sync = "0.9.2"
diff --git a/rust/libceed/README.md b/rust/libceed/README.md
new file mode 100644
index 0000000000..1f93315730
--- /dev/null
+++ b/rust/libceed/README.md
@@ -0,0 +1,57 @@
+# libceed: efficient, extensible discretization
+
+This crate provides an interface to [libCEED](https://libceed.readthedocs.io),
+which is a performance-portable library for extensible element-based
+discretization for partial differential equations and related computational
+problems. The formulation is algebraic and intended to be lightweight and easy
+to incorporate in higher level abstractions. See the [libCEED user
+manual](https://libceed.readthedocs.io) for details on [interface
+concepts](https://libceed.readthedocs.io/en/latest/libCEEDapi/) and extensive
+examples.
+
+![libCEED operator decomposition](https://libceed.readthedocs.io/en/latest/_images/libCEED.png)
+
+## Usage
+
+To call libCEED from a Rust package, the following `Cargo.toml` can be used.
+```toml
+[dependencies]
+libceed = "0.8.0"
+```
+
+For a development version of the libCEED Rust bindings, use the following `Cargo.toml`.
+```toml
+[dependencies]
+libceed = { git = "https://github.com/CEED/libCEED", branch = "main" }
+```
+
+```rust
+extern crate libceed;
+
+fn main() {
+ let ceed = libceed::Ceed::init("/cpu/self/ref");
+ let xc = ceed.vector_from_slice(&[0., 0.5, 1.0]).unwrap();
+ let xs = xc.view();
+ assert_eq!(xs[..], [0., 0.5, 1.0]);
+}
+```
+
+This crate provides modules for each object, but they are usually created from
+the `Ceed` object as with the vector above. The resource string passed to
+`Ceed::init` is used to identify the "backend", which includes algorithmic
+strategies and hardware such as NVIDIA and AMD GPUs. See the [libCEED
+documentation](https://libceed.readthedocs.io/en/latest/gettingstarted/#backends)
+for more information on available backends.
+
+## Examples
+
+Examples of libCEED can be found in the [libCEED repository](https://github.com/CEED/libCEED) under the
+`examples/rust` directory.
+
+## License: BSD-2-Clause
+
+## Contributing
+
+The `libceed` crate is developed within the [libCEED
+repository](https://github.com/CEED/libCEED). See the [contributing
+guidelines](https://libceed.readthedocs.io/en/latest/CONTRIBUTING/) for details.
diff --git a/rust/src/basis.rs b/rust/libceed/src/basis.rs
similarity index 100%
rename from rust/src/basis.rs
rename to rust/libceed/src/basis.rs
diff --git a/rust/src/elem_restriction.rs b/rust/libceed/src/elem_restriction.rs
similarity index 100%
rename from rust/src/elem_restriction.rs
rename to rust/libceed/src/elem_restriction.rs
diff --git a/rust/src/lib.rs b/rust/libceed/src/lib.rs
similarity index 92%
rename from rust/src/lib.rs
rename to rust/libceed/src/lib.rs
index 0796c1b88f..6eff21f61b 100755
--- a/rust/src/lib.rs
+++ b/rust/libceed/src/lib.rs
@@ -14,57 +14,8 @@
// software, applications, hardware, advanced system engineering and early
// testbed platforms, in support of the nation's exascale computing imperative
-//! # libCEED Rust Interface
-//!
-//! This is the documentation for the high level libCEED Rust interface.
-//! See the full libCEED user manual [here](https://libceed.readthedocs.io).
-//!
-//! libCEED is a low-level API for for the efficient high-order discretization methods
-//! developed by the ECP co-design Center for Efficient Exascale Discretizations (CEED).
-//! While our focus is on high-order finite elements, the approach is mostly algebraic
-//! and thus applicable to other discretizations in factored form.
-//!
-//! ## Usage
-//!
-//! To call libCEED from a Rust package, the following `Cargo.toml` can be used.
-//! ```toml
-//! [dependencies]
-//! libceed = { git = "https://github.com/CEED/libCEED", branch = "main" }
-//! ```
-//!
-//! Supported features:
-//! * `static` (default): link to static libceed.a
-//! * `system`: use libceed from a system directory (otherwise, install from source)
-//!
-//! ```
-//! extern crate libceed;
-//!
-//! fn main() {
-//! let ceed = libceed::Ceed::init("/cpu/self/ref");
-//! let xc = ceed.vector_from_slice(&[0., 0.5, 1.0]).unwrap();
-//! let xs = xc.view();
-//! assert_eq!(xs[..], [0., 0.5, 1.0]);
-//! }
-//! ```
-//!
-//! ## Examples
-//!
-//! Examples of libCEED can be found in the libCEED GitHub repository under the
-//! `examples/rust` folder.
-//!
-//! ## Development
-//!
-//! To develop libCEED, use `cargo build` in the `rust/` directory to install a
-//! local copy and build the bindings. If you need custom flags for the C
-//! project, we recommend using `make configure` to cache arguments. If you
-//! disable the `static` feature, then you'll need to set `LD_LIBRARY_PATH` for
-//! doctests to be able to find it. You can do this in `$CEED_DIR/lib` and set
-//! `PKG_CONFIG_PATH`.
-//!
-//! Note: the `LD_LIBRARY_PATH` workarounds will become unnecessary if [this
-//! issue](https://github.com/rust-lang/cargo/issues/1592) is resolved -- it's
-//! currently closed, but the problem still exists.
-
+// Fenced `rust` code blocks included from README.md are executed as part of doctests.
+#![doc = include_str!("../README.md")]
// -----------------------------------------------------------------------------
// Exceptions
// -----------------------------------------------------------------------------
@@ -77,12 +28,6 @@ use crate::prelude::*;
use std::sync::Once;
pub mod prelude {
- pub(crate) mod bind_ceed {
- #![allow(non_upper_case_globals)]
- #![allow(non_camel_case_types)]
- #![allow(dead_code)]
- include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
- }
pub use crate::{
basis::{self, Basis, BasisOpt},
elem_restriction::{self, ElemRestriction, ElemRestrictionOpt},
@@ -94,6 +39,7 @@ pub mod prelude {
ElemTopology, EvalMode, MemType, NormType, QuadMode, TransposeMode, CEED_STRIDES_BACKEND,
MAX_QFUNCTION_FIELDS,
};
+ pub(crate) use libceed_sys::bind_ceed;
pub(crate) use std::convert::TryFrom;
pub(crate) use std::ffi::CString;
pub(crate) use std::fmt;
@@ -303,7 +249,7 @@ impl Ceed {
let mut ptr = std::ptr::null_mut();
let mut ierr = unsafe { bind_ceed::CeedInit(c_resource.as_ptr() as *const i8, &mut ptr) };
if ierr != 0 {
- panic!(format!("Error initializing backend resource: {}", resource))
+ panic!("Error initializing backend resource: {}", resource)
}
ierr = unsafe { bind_ceed::CeedSetErrorHandler(ptr, Some(eh)) };
let ceed = Ceed { ptr };
@@ -335,7 +281,7 @@ impl Ceed {
let message = c_str.to_string_lossy().to_string();
// Panic if negative code, otherwise return error
if ierr < bind_ceed::CeedErrorType_CEED_ERROR_SUCCESS {
- panic!(message);
+ panic!("{}", message);
}
Err(CeedError { message })
}
diff --git a/rust/src/operator.rs b/rust/libceed/src/operator.rs
similarity index 100%
rename from rust/src/operator.rs
rename to rust/libceed/src/operator.rs
diff --git a/rust/src/qfunction.rs b/rust/libceed/src/qfunction.rs
similarity index 100%
rename from rust/src/qfunction.rs
rename to rust/libceed/src/qfunction.rs
diff --git a/rust/src/vector.rs b/rust/libceed/src/vector.rs
similarity index 100%
rename from rust/src/vector.rs
rename to rust/libceed/src/vector.rs
diff --git a/rust/libceed/tests/version-numbers.rs b/rust/libceed/tests/version-numbers.rs
new file mode 100644
index 0000000000..afb9d3112a
--- /dev/null
+++ b/rust/libceed/tests/version-numbers.rs
@@ -0,0 +1,33 @@
+use std::path::{Path, PathBuf};
+
+#[test]
+fn test_readme_deps() {
+ let path = std::env::current_dir().unwrap();
+ version_sync::assert_markdown_deps_updated!(if path.ends_with("rust/libceed") {
+ "../../README.rst"
+ } else {
+ "README.rst"
+ });
+}
+
+fn get_rel_path(rel: impl AsRef) -> PathBuf {
+ let path = std::env::current_dir().unwrap();
+ if path.ends_with("rust/libceed") {
+ rel.as_ref().to_path_buf()
+ } else {
+ Path::new("rust/libceed").join(rel)
+ }
+}
+
+#[test]
+fn test_html_root_url() {
+ version_sync::assert_html_root_url_updated!(get_rel_path("src/lib.rs").to_str().unwrap());
+}
+
+#[test]
+fn test_doc_version() {
+ version_sync::assert_contains_regex!(
+ get_rel_path("README.md").to_str().unwrap(),
+ "{name} = \"{version}\""
+ );
+}
diff --git a/rust/tests/version-numbers.rs b/rust/tests/version-numbers.rs
deleted file mode 100644
index 5e1c61a2af..0000000000
--- a/rust/tests/version-numbers.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-#[test]
-fn test_readme_deps() {
- let path = std::env::current_dir().unwrap();
- let path = path.to_str().unwrap();
- version_sync::assert_markdown_deps_updated!(if &path[path.len() - 4..path.len()] == "rust" {
- "../README.rst"
- } else {
- "README.rst"
- });
-}
-
-#[test]
-fn test_html_root_url() {
- let path = std::env::current_dir().unwrap();
- let path = path.to_str().unwrap();
- version_sync::assert_html_root_url_updated!(if &path[path.len() - 4..path.len()] == "rust" {
- "src/lib.rs"
- } else {
- "rust/src/lib.rs"
- });
-}