Browse Source

Got mingw32 build working

Caleb James DeLisle 3 years ago
parent
commit
b862f19264

+ 2 - 12
Cargo.lock

@@ -26,7 +26,6 @@ name = "cjdroute"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
@@ -38,8 +37,7 @@ checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
 [[package]]
 name = "libsodium-sys"
 version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a685b64f837b339074115f2e7f7b431ac73681d08d75b389db7498b8892b8a58"
+source = "git+https://github.com/cjdelisle/sodiumoxide?branch=mingw32-build#c1581f06bb1d436124fc29baa653d0310232cd6d"
 dependencies = [
  "cc",
  "libc",
@@ -51,7 +49,6 @@ name = "makekeys"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
@@ -59,7 +56,6 @@ name = "mkpasswd"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
@@ -73,7 +69,6 @@ name = "privatetopublic"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
@@ -81,7 +76,6 @@ name = "publictoip6"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
@@ -89,14 +83,12 @@ name = "randombytes"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
 name = "sodiumoxide"
 version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7038b67c941e23501573cb7242ffb08709abe9b11eb74bceff875bbda024a6a8"
+source = "git+https://github.com/cjdelisle/sodiumoxide?branch=mingw32-build#c1581f06bb1d436124fc29baa653d0310232cd6d"
 dependencies = [
  "libc",
  "libsodium-sys",
@@ -107,7 +99,6 @@ name = "sybilsim"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]
 
 [[package]]
@@ -115,5 +106,4 @@ name = "testcjdroute"
 version = "0.1.0"
 dependencies = [
  "cjdns_sys",
- "sodiumoxide",
 ]

+ 1 - 1
rust/cjdns_sys/Cargo.toml

@@ -6,7 +6,7 @@ edition = "2018"
 build = "build.rs"
 
 [dependencies]
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+sodiumoxide = { git = "https://github.com/cjdelisle/sodiumoxide", branch = "mingw32-build", version = "0.2", default-features = false, features = ["std"] }
 
 [build_dependencies]
 cc = "1.0"

+ 12 - 2
rust/cjdns_sys/build.rs

@@ -49,7 +49,8 @@ fn main() -> Result<()> {
         if Path::new(&p).exists() {
             println!(
                 "cargo:rustc-link-search={}/dependencies/libuv/out/Release{}",
-                out_dir, x);
+                out_dir, x
+            );
             println!("cargo:rustc-link-lib=static=uv");
             ok = true;
             break;
@@ -59,8 +60,17 @@ fn main() -> Result<()> {
         panic!("Unable to find libuv");
     }
 
+    let target = env::var("TARGET").unwrap();
+    if target.contains("-windows-gnu") {
+        println!("cargo:rustc-link-lib=iphlpapi"); // ConvertInterfaceAliasToLuid (cjdns)
+        println!("cargo:rustc-link-lib=psapi"); // GetProcessMemoryInfo (libuv)
+        println!("cargo:rustc-link-lib=ssp"); // memcpy_chk (libuv)
+    }
+
     let mut build = cc::Build::new();
-    let mut paths = std::fs::read_dir(out_dir)?.map(|x|x.unwrap().path()).collect::<Vec<PathBuf>>();
+    let mut paths = std::fs::read_dir(out_dir)?
+        .map(|x| x.unwrap().path())
+        .collect::<Vec<PathBuf>>();
     paths.sort();
     for path in paths {
         if !path.is_dir() && path.extension().unwrap() == "o" {

+ 1 - 2
rust/cjdroute/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/makekeys/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/mkpasswd/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/privatetopublic/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/publictoip6/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/randombytes/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/sybilsim/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 1 - 2
rust/testcjdroute/Cargo.toml

@@ -7,5 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-cjdns_sys = { path = "../cjdns_sys" }
-sodiumoxide = { version = "0.2", default-features = false, features = ["std"] }
+cjdns_sys = { path = "../cjdns_sys" }

+ 6 - 0
util/events/libuv/UvWrapper.h

@@ -22,8 +22,14 @@
 #endif
 #ifdef win32
     #define _WIN32_WINNT 0x0600 // CHECKFILES_IGNORE
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
 
 #include <uv.h>
 
+#ifdef win32
+    #pragma GCC diagnostic pop
+#endif
+
 #endif

+ 34 - 0
windows_do

@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# OSX
+# brew install mingw-w64
+
+build() {
+    ARCH=$1
+    # libuv
+    export CC="$ARCH-w64-mingw32-gcc"
+
+    if ! command -v "$CC" > /dev/null; then
+        echo "Skipping build for $ARCH because $CC is not installed"
+        return
+    fi
+    if ! [ -d "$(rustc --target "$ARCH-pc-windows-gnu" --print target-libdir)" ]; then
+        echo "Skipping build for $ARCH because rust target $ARCH-pc-windows-gnu is not installed"
+        echo "You can install it with rustup using: \`rustup target add $ARCH-pc-windows-gnu\`"
+        return
+    fi
+
+    # Used by cjdns libuv build
+    export AR="$ARCH-w64-mingw32-ar"
+    export RANLIB="$ARCH-w64-mingw32-gcc-ranlib"
+    export TARGET="$ARCH-w64-mingw32"
+
+    # Used by cjdns nodejs build
+    export CROSS=1
+    export SYSTEM=win32
+
+    cargo build --release -vv --target="$ARCH-pc-windows-gnu"
+}
+
+# build i686 - impossible because rust: https://github.com/rust-lang/rust/issues/12859
+build x86_64