diff --git a/.all-contributorsrc b/.all-contributorsrc
index c75bdc9d..1282ef95 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -15,6 +15,16 @@
"bug"
]
},
+ {
+ "login": "psengrith",
+ "name": "Sengrith",
+ "avatar_url": "https://avatars.githubusercontent.com/u/172288069?v=4",
+ "profile": "https://www.linkedin.com/in/psengrith/",
+ "contributions": [
+ "bug",
+ "doc"
+ ]
+ },
{
"login": "leisim",
"name": "Simon Leier",
@@ -211,4 +221,4 @@
"repoHost": "https://github.com",
"skipCi": true,
"commitConvention": "angular"
-}
+}
\ No newline at end of file
diff --git a/packages/isar/README.md b/packages/isar/README.md
index 1117369f..2db52c2f 100644
--- a/packages/isar/README.md
+++ b/packages/isar/README.md
@@ -243,6 +243,7 @@ Big thanks go to these wonderful people:
![](https://avatars.githubusercontent.com/u/57417802?v=4) Nelson Mutane |
![](https://avatars.githubusercontent.com/u/24822764?v=4) Peyman |
+ ![](https://avatars.githubusercontent.com/u/172288069?v=4) Sengrith |
![](https://avatars.githubusercontent.com/u/13610195?v=4) Simon Leier |
![](https://avatars.githubusercontent.com/u/42883378?v=4) Ura |
![](https://avatars.githubusercontent.com/u/32213113?v=4) blendthink |
diff --git a/packages/mdbx_sys/README.md b/packages/mdbx_sys/README.md
new file mode 100644
index 00000000..5f81e708
--- /dev/null
+++ b/packages/mdbx_sys/README.md
@@ -0,0 +1,53 @@
+# mdbx_sys
+
+Rust binding of mdbx.
+
+## Build Setup (for Windows)
+
+For triplet `x86_64-pc-windows-msvc`
+
+1. Install rust to use triplet `x86_64-pc-windows-msvc`.
+
+2. Install [MSYS2](https://www.msys2.org/).
+
+- Make sure to add `msys\usr\bin` to environment variable `PATH`.
+
+3. Use MSYS2 package manager to install neccessary build tools:
+
+ ```{bash}
+ pacman -S --needed make
+ ```
+
+- Make sure to add `msys\mingw64\bin` to environment variable `PATH`.
+
+3. Install `clang >=5.0 <= 15.0` (as a workaround for [#2500](https://github.com/rust-lang/rust-bindgen/issues/2500#issuecomment-1640545912)) from [llvm-project](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.7).
+
+- Make sure to add `path\to\bin\libclang.dll` to environment variable `LIBCLANG_PATH`.
+- Make sure option `MSVC`, `Windows SDK` and `C++ CMake tool for Windows` is selected when installing `Desktop Development with C++` build tool by using [Visual Studio Build Tools 2019](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16)
+
+1. Install [CMake](https://cmake.org/download/), and configure enivronment variable.
+
+2. Restart `VSCode` instance to reload the environment variables. Then, build the library, and it should be successfully build 😀!
+
+
+
+## Other Unix/Linux-Based OS
+
+1. Install `build-essential` and `clang >= 5.0 <=15.0` [bindgen requirements](https://rust-lang.github.io/rust-bindgen/requirements.html).
+2. Build the library, and it should be successfully build 😀!
diff --git a/packages/mdbx_sys/build.rs b/packages/mdbx_sys/build.rs
index 34b860dd..40582cf0 100644
--- a/packages/mdbx_sys/build.rs
+++ b/packages/mdbx_sys/build.rs
@@ -58,25 +58,31 @@ fn main() {
let is_android = env::var("CARGO_CFG_TARGET_OS").unwrap() == "android";
- let _ = fs::remove_dir_all("libmdbx");
+ let mut mdbx = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
+ mdbx.push("libmdbx");
- Command::new("git")
- .arg("clone")
- .arg(LIBMDBX_REPO)
- .arg("--branch")
- .arg(LIBMDBX_TAG)
- .output()
- .unwrap();
+ if !mdbx.exists() {
+ Command::new("git")
+ .arg("clone")
+ .arg(LIBMDBX_REPO)
+ .arg("--branch")
+ .arg(LIBMDBX_TAG)
+ .output()
+ .unwrap();
+ }
+
+ mdbx.push("dist-check");
+ let _ = fs::remove_dir_all(mdbx.as_path());
+ mdbx.pop();
+
+ mdbx.push("dist");
+ let _ = fs::remove_dir_all(mdbx.as_path());
Command::new("make")
.arg("release-assets")
.current_dir("libmdbx")
.output()
- .unwrap();
-
- let mut mdbx = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
- mdbx.push("libmdbx");
- mdbx.push("dist");
+ .expect(mdbx.as_path().to_str().unwrap());
let core_path = mdbx.join("mdbx.c");
let mut core = fs::read_to_string(core_path.as_path()).unwrap();
@@ -95,6 +101,14 @@ fn main() {
}
fs::write(core_path.as_path(), core).unwrap();
+ if env::var("TARGET").unwrap().contains("windows") {
+ let h_path = mdbx.join("mdbx.h");
+ let mut headers = fs::read_to_string(h_path.as_path()).expect("dist/mdbx.h was not found!");
+ // A temporary workaround since -DMDBX_LOCK_SUFFIX has no effect.
+ headers = headers.replace("\"-lck\"", "\".lock\"");
+ fs::write(h_path.as_path(), headers).unwrap();
+ }
+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let bindings = bindgen::Builder::default()
@@ -111,6 +125,9 @@ fn main() {
.generate_comments(true)
.disable_header_comment()
.rustfmt_bindings(true)
+ .clang_arg("-Wno-ignored-attributes")
+ .clang_arg("-DNDEBUG 1")
+ .clang_arg("-DMDBX_WITHOUT_MSVC_CRT 1")
.generate()
.expect("Unable to generate bindings");
@@ -122,6 +139,10 @@ fn main() {
let flags = format!("{:?}", cc_builder.get_compiler().cflags_env());
cc_builder.flag_if_supported("-Wno-everything");
+ if env::var("TARGET").unwrap().ends_with("-musl") {
+ cc_builder.define("MDBX_HAVE_BUILTIN_CPU_SUPPORTS", "0");
+ }
+
if cfg!(windows) {
let dst = cmake::Config::new(&mdbx)
.define("MDBX_INSTALL_STATIC", "1")