[package.metadata.raze.crates.libsodium-sys.'*']\r
buildrs_additional_environment_variables = { PATH = "/usr/sbin:/usr/bin:/sbin:/bin", "NUM_JOBS" = "2" }\r
compile_data_attr = "glob([\"*/**\"])"\r
+additional_build_file = "bazel/patch/BUILD_script_patch"\r
gen_buildrs = false\r
-additional_build_file = ["bazel/patch/libsodium_buildrs.rs"]
\ No newline at end of file
+additional_deps = [":libsodium_sys_build_script"]
\ No newline at end of file
+workspace(name = "nova")
+
#@unused
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
http_archive(
name = "com_google_protobuf",
sha256 = "d0f5f605d0d656007ce6c8b5a82df3037e1d8fe8b121ed42e536f569dec16113",
--- /dev/null
+exports_files(["libsodium_sys_build_script_script_.rs"])
\ No newline at end of file
--- /dev/null
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# Generated Targets
+# buildifier: disable=out-of-order-load
+# buildifier: disable=load-on-top
+load(
+ "@rules_rust//cargo:cargo_build_script.bzl",
+ "cargo_build_script",
+)
+
+cargo_build_script(
+ name = "libsodium_sys_build_script",
+ srcs = ["@nova//bazel/patch:libsodium_sys_build_script_script_.rs"],
+ build_script_env = {
+ "NUM_JOBS": "2",
+ "PATH": "/usr/sbin:/usr/bin:/sbin:/bin",
+ },
+ data = glob(["**"]),
+ edition = "2015",
+ links = "sodium",
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ tags = [
+ "cargo-raze",
+ "manual",
+ ],
+ version = "0.2.7",
+ visibility = ["//visibility:private"],
+ deps = [
+ "@raze__pkg_config__0_3_19//:pkg_config",
+ "@raze__walkdir__2_3_2//:walkdir",
+ ] + selects.with_or({
+ # cfg(not(target_env = "msvc"))
+ (
+ "@rules_rust//rust/platform:aarch64-apple-darwin",
+ "@rules_rust//rust/platform:aarch64-apple-ios",
+ "@rules_rust//rust/platform:aarch64-linux-android",
+ "@rules_rust//rust/platform:aarch64-unknown-linux-gnu",
+ "@rules_rust//rust/platform:arm-unknown-linux-gnueabi",
+ "@rules_rust//rust/platform:i686-apple-darwin",
+ "@rules_rust//rust/platform:i686-linux-android",
+ "@rules_rust//rust/platform:i686-unknown-freebsd",
+ "@rules_rust//rust/platform:i686-unknown-linux-gnu",
+ "@rules_rust//rust/platform:powerpc-unknown-linux-gnu",
+ "@rules_rust//rust/platform:s390x-unknown-linux-gnu",
+ "@rules_rust//rust/platform:wasm32-unknown-unknown",
+ "@rules_rust//rust/platform:wasm32-wasi",
+ "@rules_rust//rust/platform:x86_64-apple-darwin",
+ "@rules_rust//rust/platform:x86_64-apple-ios",
+ "@rules_rust//rust/platform:x86_64-linux-android",
+ "@rules_rust//rust/platform:x86_64-unknown-freebsd",
+ "@rules_rust//rust/platform:x86_64-unknown-linux-gnu",
+ ): [
+ "@raze__cc__1_0_70//:cc",
+ ],
+ "//conditions:default": [],
+ }) + selects.with_or({
+ # cfg(target_env = "msvc")
+ (
+ "@rules_rust//rust/platform:i686-pc-windows-msvc",
+ "@rules_rust//rust/platform:x86_64-pc-windows-msvc",
+ ): [
+ "@raze__libc__0_2_101//:libc",
+ ],
+ "//conditions:default": [],
+ }),
+)
+++ /dev/null
-#[cfg(not(windows))]\r
-extern crate cc;\r
-\r
-#[cfg(target_env = "msvc")]\r
-extern crate libc;\r
-\r
-extern crate pkg_config;\r
-extern crate walkdir;\r
-\r
-use std::{\r
- env,\r
- path::{Path, PathBuf},\r
-};\r
-\r
-static VERSION: &str = "1.0.18";\r
-\r
-fn main() {\r
- println!("cargo:rerun-if-env-changed=SODIUM_LIB_DIR");\r
- println!("cargo:rerun-if-env-changed=SODIUM_SHARED");\r
- println!("cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG");\r
-\r
- if cfg!(not(windows)) {\r
- println!("cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE");\r
- }\r
-\r
- if env::var("SODIUM_STATIC").is_ok() {\r
- panic!("SODIUM_STATIC is deprecated. Use SODIUM_SHARED instead.");\r
- }\r
-\r
- let lib_dir_isset = env::var("SODIUM_LIB_DIR").is_ok();\r
- let use_pkg_isset = if cfg!(feature = "use-pkg-config") {\r
- true\r
- } else {\r
- env::var("SODIUM_USE_PKG_CONFIG").is_ok()\r
- };\r
- let shared_isset = env::var("SODIUM_SHARED").is_ok();\r
-\r
- if lib_dir_isset && use_pkg_isset {\r
- panic!("SODIUM_LIB_DIR is incompatible with SODIUM_USE_PKG_CONFIG. Set the only one env variable");\r
- }\r
-\r
- if lib_dir_isset {\r
- find_libsodium_env();\r
- } else if use_pkg_isset {\r
- if shared_isset {\r
- println!("cargo:warning=SODIUM_SHARED has no effect with SODIUM_USE_PKG_CONFIG");\r
- }\r
-\r
- find_libsodium_pkg();\r
- } else {\r
- if shared_isset {\r
- println!(\r
- "cargo:warning=SODIUM_SHARED has no effect for building libsodium from source"\r
- );\r
- }\r
-\r
- build_libsodium();\r
- }\r
-}\r
-\r
-/* Must be called when SODIUM_LIB_DIR is set to any value\r
-This function will set `cargo` flags.\r
-*/\r
-fn find_libsodium_env() {\r
- let lib_dir = env::var("SODIUM_LIB_DIR").unwrap(); // cannot fail\r
-\r
- println!("cargo:rustc-link-search=native={}", lib_dir);\r
- let mode = if env::var("SODIUM_SHARED").is_ok() {\r
- "dylib"\r
- } else {\r
- "static"\r
- };\r
- let name = if cfg!(target_env = "msvc") {\r
- "libsodium"\r
- } else {\r
- "sodium"\r
- };\r
- println!("cargo:rustc-link-lib={}={}", mode, name);\r
- println!(\r
- "cargo:warning=Using unknown libsodium version. This crate is tested against \\r
- {} and may not be fully compatible with other versions.",\r
- VERSION\r
- );\r
-}\r
-\r
-/* Must be called when no SODIUM_USE_PKG_CONFIG env var is set\r
-This function will set `cargo` flags.\r
-*/\r
-#[cfg(target_env = "msvc")]\r
-fn find_libsodium_pkg() {\r
- panic!("SODIUM_USE_PKG_CONFIG is not supported on msvc");\r
-}\r
-\r
-/* Must be called when SODIUM_USE_PKG_CONFIG env var is set\r
-This function will set `cargo` flags.\r
-*/\r
-#[cfg(not(target_env = "msvc"))]\r
-fn find_libsodium_pkg() {\r
- match pkg_config::Config::new().probe("libsodium") {\r
- Ok(lib) => {\r
- if lib.version != VERSION {\r
- println!(\r
- "cargo:warning=Using libsodium version {}. This crate is tested against {} \\r
- and may not be fully compatible with {}.",\r
- lib.version, VERSION, lib.version\r
- );\r
- }\r
- for lib_dir in &lib.link_paths {\r
- println!("cargo:lib={}", lib_dir.to_str().unwrap());\r
- }\r
- for include_dir in &lib.include_paths {\r
- println!("cargo:include={}", include_dir.to_str().unwrap());\r
- }\r
- }\r
- Err(e) => {\r
- panic!(\r
- "\r
-Failed to run pkg-config:\r
-{:?}\r
-\r
-You can try fixing this by installing pkg-config:\r
-\r
- # On Ubuntu\r
- sudo apt install pkg-config\r
- # On Arch Linux\r
- sudo pacman -S pkgconf\r
- # On Fedora\r
- sudo dnf install pkgconf-pkg-config\r
-\r
-",\r
- e\r
- );\r
- }\r
- }\r
-}\r
-\r
-#[cfg(windows)]\r
-fn make_libsodium(_: &str, _: &Path, _: &Path) -> PathBuf {\r
- // We don't build anything on windows, we simply linked to precompiled\r
- // libs.\r
- get_lib_dir()\r
-}\r
-\r
-#[cfg(not(windows))]\r
-fn make_libsodium(target: &str, source_dir: &Path, install_dir: &Path) -> PathBuf {\r
- use std::{fs, process::Command, str};\r
-\r
- // Decide on CC, CFLAGS and the --host configure argument\r
- let build_compiler = cc::Build::new().get_compiler();\r
- let mut compiler = build_compiler.path().to_str().unwrap().to_string();\r
- let mut cflags = build_compiler.cflags_env().into_string().unwrap();\r
- let mut host_arg = format!("--host={}", target);\r
- let mut cross_compiling = target != env::var("HOST").unwrap();\r
- if target.contains("-ios") {\r
- // Determine Xcode directory path\r
- let xcode_select_output = Command::new("xcode-select").arg("-p").output().unwrap();\r
- if !xcode_select_output.status.success() {\r
- panic!("Failed to run xcode-select -p");\r
- }\r
- let xcode_dir = str::from_utf8(&xcode_select_output.stdout)\r
- .unwrap()\r
- .trim()\r
- .to_string();\r
-\r
- // Determine SDK directory paths\r
- let sdk_dir_simulator = Path::new(&xcode_dir)\r
- .join("Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk")\r
- .to_str()\r
- .unwrap()\r
- .to_string();\r
- let sdk_dir_ios = Path::new(&xcode_dir)\r
- .join("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk")\r
- .to_str()\r
- .unwrap()\r
- .to_string();\r
-\r
- // Min versions\r
- let ios_simulator_version_min = "6.0.0";\r
- let ios_version_min = "6.0.0";\r
-\r
- // Roughly based on `dist-build/ios.sh` in the libsodium sources\r
- match &*target {\r
- "aarch64-apple-ios" => {\r
- cflags += " -arch arm64";\r
- cflags += &format!(" -isysroot {}", sdk_dir_ios);\r
- cflags += &format!(" -mios-version-min={}", ios_version_min);\r
- cflags += " -fembed-bitcode";\r
- host_arg = "--host=arm-apple-darwin10".to_string();\r
- }\r
- "armv7-apple-ios" => {\r
- cflags += " -arch armv7";\r
- cflags += &format!(" -isysroot {}", sdk_dir_ios);\r
- cflags += &format!(" -mios-version-min={}", ios_version_min);\r
- cflags += " -mthumb";\r
- host_arg = "--host=arm-apple-darwin10".to_string();\r
- }\r
- "armv7s-apple-ios" => {\r
- cflags += " -arch armv7s";\r
- cflags += &format!(" -isysroot {}", sdk_dir_ios);\r
- cflags += &format!(" -mios-version-min={}", ios_version_min);\r
- cflags += " -mthumb";\r
- host_arg = "--host=arm-apple-darwin10".to_string();\r
- }\r
- "i386-apple-ios" => {\r
- cflags += " -arch i386";\r
- cflags += &format!(" -isysroot {}", sdk_dir_simulator);\r
- cflags += &format!(" -mios-simulator-version-min={}", ios_simulator_version_min);\r
- host_arg = "--host=i686-apple-darwin10".to_string();\r
- }\r
- "x86_64-apple-ios" => {\r
- cflags += " -arch x86_64";\r
- cflags += &format!(" -isysroot {}", sdk_dir_simulator);\r
- cflags += &format!(" -mios-simulator-version-min={}", ios_simulator_version_min);\r
- host_arg = "--host=x86_64-apple-darwin10".to_string();\r
- }\r
- _ => panic!("Unknown iOS build target: {}", target),\r
- }\r
- cross_compiling = true;\r
- } else if target.contains("i686") {\r
- compiler += " -m32 -maes";\r
- cflags += " -march=i686";\r
- }\r
-\r
- let help = if cross_compiling {\r
- "***********************************************************\n\\r
- Possible missing dependencies.\n\\r
- See https://github.com/sodiumoxide/sodiumoxide#cross-compiling\n\\r
- ***********************************************************\n\n"\r
- } else {\r
- ""\r
- };\r
-\r
- // Run `./configure`\r
- let prefix_arg = format!("--prefix={}", install_dir.to_str().unwrap());\r
- let libdir_arg = format!("--libdir={}/lib", install_dir.to_str().unwrap());\r
- let mut configure_cmd = Command::new(fs::canonicalize(source_dir.join("configure")).expect("Failed to find configure script! Did you clone the submodule at `libsodium-sys/libsodium`?"));\r
- if !compiler.is_empty() {\r
- configure_cmd.env("CC", &compiler);\r
- }\r
- if !cflags.is_empty() {\r
- configure_cmd.env("CFLAGS", &cflags);\r
- }\r
- if env::var("SODIUM_DISABLE_PIE").is_ok() {\r
- configure_cmd.arg("--disable-pie");\r
- }\r
- let configure_status = configure_cmd\r
- .current_dir(&source_dir)\r
- .arg(&prefix_arg)\r
- .arg(&libdir_arg)\r
- .arg(&host_arg)\r
- .arg("--enable-shared=no")\r
- .status()\r
- .unwrap_or_else(|error| {\r
- panic!("Failed to run './configure': {}\n{}", error, help);\r
- });\r
- if !configure_status.success() {\r
- panic!(\r
- "\nFailed to configure libsodium using {:?}\nCFLAGS={}\nCC={}\n{}\n",\r
- configure_cmd, cflags, compiler, help\r
- );\r
- }\r
-\r
- // Run `make check`, or `make all` if we're cross-compiling\r
- let j_arg = format!("-j{}", env::var("NUM_JOBS").unwrap());\r
- let make_arg = if cross_compiling { "all" } else { "check" };\r
- let mut make_cmd = Command::new("make");\r
- let make_status = make_cmd\r
- .current_dir(&source_dir)\r
- .env("V", "1")\r
- .arg(make_arg)\r
- .arg(&j_arg)\r
- .status()\r
- .unwrap_or_else(|error| {\r
- panic!("Failed to run 'make {}': {}\n{}", make_arg, error, help);\r
- });\r
- if !make_status.success() {\r
- panic!("\nFailed to build libsodium using {:?}\n{}", make_cmd, help);\r
- }\r
-\r
- // Run `make install`\r
- let mut install_cmd = Command::new("make");\r
- let install_status = install_cmd\r
- .current_dir(&source_dir)\r
- .arg("install")\r
- .status()\r
- .unwrap_or_else(|error| {\r
- panic!("Failed to run 'make install': {}", error);\r
- });\r
- if !install_status.success() {\r
- panic!("\nFailed to install libsodium using {:?}", install_cmd);\r
- }\r
-\r
- install_dir.join("lib")\r
-}\r
-\r
-#[cfg(any(windows, target_env = "msvc"))]\r
-fn get_crate_dir() -> PathBuf {\r
- env::var("CARGO_MANIFEST_DIR").unwrap().into()\r
-}\r
-\r
-#[cfg(target_env = "msvc")]\r
-fn is_release_profile() -> bool {\r
- env::var("PROFILE").unwrap() == "release"\r
-}\r
-\r
-#[cfg(all(target_env = "msvc", target_pointer_width = "32"))]\r
-fn get_lib_dir() -> PathBuf {\r
- if is_release_profile() {\r
- get_crate_dir().join("msvc/Win32/Release/v142/")\r
- } else {\r
- get_crate_dir().join("msvc/Win32/Debug/v142/")\r
- }\r
-}\r
-\r
-#[cfg(all(target_env = "msvc", target_pointer_width = "64"))]\r
-fn get_lib_dir() -> PathBuf {\r
- if is_release_profile() {\r
- get_crate_dir().join("msvc/x64/Release/v142/")\r
- } else {\r
- get_crate_dir().join("msvc/x64/Debug/v142/")\r
- }\r
-}\r
-\r
-#[cfg(all(windows, not(target_env = "msvc"), target_pointer_width = "32"))]\r
-fn get_lib_dir() -> PathBuf {\r
- get_crate_dir().join("mingw/win32/")\r
-}\r
-\r
-#[cfg(all(windows, not(target_env = "msvc"), target_pointer_width = "64"))]\r
-fn get_lib_dir() -> PathBuf {\r
- get_crate_dir().join("mingw/win64/")\r
-}\r
-\r
-fn build_libsodium() {\r
- use std::{ffi::OsStr, fs};\r
-\r
- // Determine build target triple\r
- let mut out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());\r
- let target = env::var("TARGET").unwrap();\r
- let profile = env::var("PROFILE").unwrap();\r
-\r
- // Avoid issues with paths containing spaces by falling back to using a tempfile.\r
- // See https://github.com/jedisct1/libsodium/issues/207\r
- if out_dir.to_str().unwrap().contains(' ') {\r
- out_dir = env::temp_dir()\r
- .join("libsodium-sys")\r
- .join(&target)\r
- .join(&profile);\r
- println!(\r
- "cargo:warning=The path to the usual build directory contains spaces and hence \\r
- can't be used to build libsodium. Falling back to use {}. If running `cargo \\r
- clean`, ensure you also delete this fallback directory",\r
- out_dir.display()\r
- );\r
- }\r
-\r
- // Determine source and install dir\r
- let install_dir = out_dir.join("installed");\r
- let source_dir = out_dir.join("source").join("libsodium");\r
-\r
- // Create directories\r
- fs::create_dir_all(&install_dir).unwrap();\r
- fs::create_dir_all(&source_dir).unwrap();\r
-\r
- let paths = std::fs::read_dir("./libsodium").unwrap();\r
-\r
- for path in paths {\r
- println!("Name: {}", path.unwrap().path().display())\r
- }\r
-\r
- if !target.contains("msvc") {\r
- // Copy sources into build directory\r
- // Skip .git because it's marked read-only and that causes problems re-building\r
- for entry in walkdir::WalkDir::new("libsodium")\r
- .into_iter()\r
- .filter_entry(|e| e.file_name() != OsStr::new(".git"))\r
- .filter_map(Result::ok)\r
- {\r
- let outpath = out_dir.join("source").join(entry.path());\r
- if let Err(e) = if entry.file_type().is_dir() {\r
- fs::create_dir_all(outpath)\r
- } else {\r
- fs::copy(entry.path(), outpath).map(|_| ())\r
- } {\r
- panic!("Failed to copy sources into build directory: {}", e);\r
- }\r
- }\r
- }\r
-\r
- let lib_dir = make_libsodium(&target, &source_dir, &install_dir);\r
-\r
- if target.contains("msvc") {\r
- println!("cargo:rustc-link-lib=static=libsodium");\r
- } else {\r
- println!("cargo:rustc-link-lib=static=sodium");\r
- }\r
-\r
- println!(\r
- "cargo:rustc-link-search=native={}",\r
- lib_dir.to_str().unwrap()\r
- );\r
-\r
- let include_dir = source_dir.join("src/libsodium/include");\r
-\r
- println!("cargo:include={}", include_dir.to_str().unwrap());\r
- println!("cargo:lib={}", lib_dir.to_str().unwrap());\r
-}\r
--- /dev/null
+#[cfg(not(windows))]
+extern crate cc;
+
+#[cfg(target_env = "msvc")]
+extern crate libc;
+
+extern crate pkg_config;
+extern crate walkdir;
+
+use std::{
+ env,
+ path::{Path, PathBuf},
+};
+
+static VERSION: &str = "1.0.18";
+
+fn main() {
+ println!("cargo:rerun-if-env-changed=SODIUM_LIB_DIR");
+ println!("cargo:rerun-if-env-changed=SODIUM_SHARED");
+ println!("cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG");
+
+ if cfg!(not(windows)) {
+ println!("cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE");
+ }
+
+ if env::var("SODIUM_STATIC").is_ok() {
+ panic!("SODIUM_STATIC is deprecated. Use SODIUM_SHARED instead.");
+ }
+
+ let lib_dir_isset = env::var("SODIUM_LIB_DIR").is_ok();
+ let use_pkg_isset = if cfg!(feature = "use-pkg-config") {
+ true
+ } else {
+ env::var("SODIUM_USE_PKG_CONFIG").is_ok()
+ };
+ let shared_isset = env::var("SODIUM_SHARED").is_ok();
+
+ if lib_dir_isset && use_pkg_isset {
+ panic!("SODIUM_LIB_DIR is incompatible with SODIUM_USE_PKG_CONFIG. Set the only one env variable");
+ }
+
+ if lib_dir_isset {
+ find_libsodium_env();
+ } else if use_pkg_isset {
+ if shared_isset {
+ println!("cargo:warning=SODIUM_SHARED has no effect with SODIUM_USE_PKG_CONFIG");
+ }
+
+ find_libsodium_pkg();
+ } else {
+ if shared_isset {
+ println!(
+ "cargo:warning=SODIUM_SHARED has no effect for building libsodium from source"
+ );
+ }
+
+ build_libsodium();
+ }
+}
+
+/* Must be called when SODIUM_LIB_DIR is set to any value
+This function will set `cargo` flags.
+*/
+fn find_libsodium_env() {
+ let lib_dir = env::var("SODIUM_LIB_DIR").unwrap(); // cannot fail
+
+ println!("cargo:rustc-link-search=native={}", lib_dir);
+ let mode = if env::var("SODIUM_SHARED").is_ok() {
+ "dylib"
+ } else {
+ "static"
+ };
+ let name = if cfg!(target_env = "msvc") {
+ "libsodium"
+ } else {
+ "sodium"
+ };
+ println!("cargo:rustc-link-lib={}={}", mode, name);
+ println!(
+ "cargo:warning=Using unknown libsodium version. This crate is tested against \
+ {} and may not be fully compatible with other versions.",
+ VERSION
+ );
+}
+
+/* Must be called when no SODIUM_USE_PKG_CONFIG env var is set
+This function will set `cargo` flags.
+*/
+#[cfg(target_env = "msvc")]
+fn find_libsodium_pkg() {
+ panic!("SODIUM_USE_PKG_CONFIG is not supported on msvc");
+}
+
+/* Must be called when SODIUM_USE_PKG_CONFIG env var is set
+This function will set `cargo` flags.
+*/
+#[cfg(not(target_env = "msvc"))]
+fn find_libsodium_pkg() {
+ match pkg_config::Config::new().probe("libsodium") {
+ Ok(lib) => {
+ if lib.version != VERSION {
+ println!(
+ "cargo:warning=Using libsodium version {}. This crate is tested against {} \
+ and may not be fully compatible with {}.",
+ lib.version, VERSION, lib.version
+ );
+ }
+ for lib_dir in &lib.link_paths {
+ println!("cargo:lib={}", lib_dir.to_str().unwrap());
+ }
+ for include_dir in &lib.include_paths {
+ println!("cargo:include={}", include_dir.to_str().unwrap());
+ }
+ }
+ Err(e) => {
+ panic!(
+ "
+Failed to run pkg-config:
+{:?}
+
+You can try fixing this by installing pkg-config:
+
+ # On Ubuntu
+ sudo apt install pkg-config
+ # On Arch Linux
+ sudo pacman -S pkgconf
+ # On Fedora
+ sudo dnf install pkgconf-pkg-config
+
+",
+ e
+ );
+ }
+ }
+}
+
+#[cfg(windows)]
+fn make_libsodium(_: &str, _: &Path, _: &Path) -> PathBuf {
+ // We don't build anything on windows, we simply linked to precompiled
+ // libs.
+ get_lib_dir()
+}
+
+#[cfg(not(windows))]
+fn make_libsodium(target: &str, source_dir: &Path, install_dir: &Path) -> PathBuf {
+ use std::{fs, process::Command, str};
+
+ // Decide on CC, CFLAGS and the --host configure argument
+ let build_compiler = cc::Build::new().get_compiler();
+ let mut compiler = build_compiler.path().to_str().unwrap().to_string();
+ let mut cflags = build_compiler.cflags_env().into_string().unwrap();
+ let mut host_arg = format!("--host={}", target);
+ let mut cross_compiling = target != env::var("HOST").unwrap();
+ if target.contains("-ios") {
+ // Determine Xcode directory path
+ let xcode_select_output = Command::new("xcode-select").arg("-p").output().unwrap();
+ if !xcode_select_output.status.success() {
+ panic!("Failed to run xcode-select -p");
+ }
+ let xcode_dir = str::from_utf8(&xcode_select_output.stdout)
+ .unwrap()
+ .trim()
+ .to_string();
+
+ // Determine SDK directory paths
+ let sdk_dir_simulator = Path::new(&xcode_dir)
+ .join("Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk")
+ .to_str()
+ .unwrap()
+ .to_string();
+ let sdk_dir_ios = Path::new(&xcode_dir)
+ .join("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk")
+ .to_str()
+ .unwrap()
+ .to_string();
+
+ // Min versions
+ let ios_simulator_version_min = "6.0.0";
+ let ios_version_min = "6.0.0";
+
+ // Roughly based on `dist-build/ios.sh` in the libsodium sources
+ match &*target {
+ "aarch64-apple-ios" => {
+ cflags += " -arch arm64";
+ cflags += &format!(" -isysroot {}", sdk_dir_ios);
+ cflags += &format!(" -mios-version-min={}", ios_version_min);
+ cflags += " -fembed-bitcode";
+ host_arg = "--host=arm-apple-darwin10".to_string();
+ }
+ "armv7-apple-ios" => {
+ cflags += " -arch armv7";
+ cflags += &format!(" -isysroot {}", sdk_dir_ios);
+ cflags += &format!(" -mios-version-min={}", ios_version_min);
+ cflags += " -mthumb";
+ host_arg = "--host=arm-apple-darwin10".to_string();
+ }
+ "armv7s-apple-ios" => {
+ cflags += " -arch armv7s";
+ cflags += &format!(" -isysroot {}", sdk_dir_ios);
+ cflags += &format!(" -mios-version-min={}", ios_version_min);
+ cflags += " -mthumb";
+ host_arg = "--host=arm-apple-darwin10".to_string();
+ }
+ "i386-apple-ios" => {
+ cflags += " -arch i386";
+ cflags += &format!(" -isysroot {}", sdk_dir_simulator);
+ cflags += &format!(" -mios-simulator-version-min={}", ios_simulator_version_min);
+ host_arg = "--host=i686-apple-darwin10".to_string();
+ }
+ "x86_64-apple-ios" => {
+ cflags += " -arch x86_64";
+ cflags += &format!(" -isysroot {}", sdk_dir_simulator);
+ cflags += &format!(" -mios-simulator-version-min={}", ios_simulator_version_min);
+ host_arg = "--host=x86_64-apple-darwin10".to_string();
+ }
+ _ => panic!("Unknown iOS build target: {}", target),
+ }
+ cross_compiling = true;
+ } else if target.contains("i686") {
+ compiler += " -m32 -maes";
+ cflags += " -march=i686";
+ }
+
+ let help = if cross_compiling {
+ "***********************************************************\n\
+ Possible missing dependencies.\n\
+ See https://github.com/sodiumoxide/sodiumoxide#cross-compiling\n\
+ ***********************************************************\n\n"
+ } else {
+ ""
+ };
+
+ // Run `./configure`
+ let prefix_arg = format!("--prefix={}", install_dir.to_str().unwrap());
+ let libdir_arg = format!("--libdir={}/lib", install_dir.to_str().unwrap());
+ let mut configure_cmd = Command::new(fs::canonicalize(source_dir.join("configure")).expect("Failed to find configure script! Did you clone the submodule at `libsodium-sys/libsodium`?"));
+ if !compiler.is_empty() {
+ configure_cmd.env("CC", &compiler);
+ }
+ if !cflags.is_empty() {
+ configure_cmd.env("CFLAGS", &cflags);
+ }
+ if env::var("SODIUM_DISABLE_PIE").is_ok() {
+ configure_cmd.arg("--disable-pie");
+ }
+ let configure_status = configure_cmd
+ .current_dir(&source_dir)
+ .arg(&prefix_arg)
+ .arg(&libdir_arg)
+ .arg(&host_arg)
+ .arg("--enable-shared=no")
+ .status()
+ .unwrap_or_else(|error| {
+ panic!("Failed to run './configure': {}\n{}", error, help);
+ });
+ if !configure_status.success() {
+ panic!(
+ "\nFailed to configure libsodium using {:?}\nCFLAGS={}\nCC={}\n{}\n",
+ configure_cmd, cflags, compiler, help
+ );
+ }
+
+ // Run `make check`, or `make all` if we're cross-compiling
+ let j_arg = format!("-j{}", env::var("NUM_JOBS").unwrap());
+ let make_arg = if cross_compiling { "all" } else { "check" };
+ let mut make_cmd = Command::new("make");
+ let make_status = make_cmd
+ .current_dir(&source_dir)
+ .env("V", "1")
+ .arg(make_arg)
+ .arg(&j_arg)
+ .status()
+ .unwrap_or_else(|error| {
+ panic!("Failed to run 'make {}': {}\n{}", make_arg, error, help);
+ });
+ if !make_status.success() {
+ panic!("\nFailed to build libsodium using {:?}\n{}", make_cmd, help);
+ }
+
+ // Run `make install`
+ let mut install_cmd = Command::new("make");
+ let install_status = install_cmd
+ .current_dir(&source_dir)
+ .arg("install")
+ .status()
+ .unwrap_or_else(|error| {
+ panic!("Failed to run 'make install': {}", error);
+ });
+ if !install_status.success() {
+ panic!("\nFailed to install libsodium using {:?}", install_cmd);
+ }
+
+ install_dir.join("lib")
+}
+
+#[cfg(any(windows, target_env = "msvc"))]
+fn get_crate_dir() -> PathBuf {
+ env::var("CARGO_MANIFEST_DIR").unwrap().into()
+}
+
+#[cfg(target_env = "msvc")]
+fn is_release_profile() -> bool {
+ env::var("PROFILE").unwrap() == "release"
+}
+
+#[cfg(all(target_env = "msvc", target_pointer_width = "32"))]
+fn get_lib_dir() -> PathBuf {
+ if is_release_profile() {
+ get_crate_dir().join("msvc/Win32/Release/v142/")
+ } else {
+ get_crate_dir().join("msvc/Win32/Debug/v142/")
+ }
+}
+
+#[cfg(all(target_env = "msvc", target_pointer_width = "64"))]
+fn get_lib_dir() -> PathBuf {
+ if is_release_profile() {
+ get_crate_dir().join("msvc/x64/Release/v142/")
+ } else {
+ get_crate_dir().join("msvc/x64/Debug/v142/")
+ }
+}
+
+#[cfg(all(windows, not(target_env = "msvc"), target_pointer_width = "32"))]
+fn get_lib_dir() -> PathBuf {
+ get_crate_dir().join("mingw/win32/")
+}
+
+#[cfg(all(windows, not(target_env = "msvc"), target_pointer_width = "64"))]
+fn get_lib_dir() -> PathBuf {
+ get_crate_dir().join("mingw/win64/")
+}
+
+fn build_libsodium() {
+ use std::{ffi::OsStr, fs};
+
+ // Determine build target triple
+ let mut out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
+ let target = env::var("TARGET").unwrap();
+ let profile = env::var("PROFILE").unwrap();
+
+ // Avoid issues with paths containing spaces by falling back to using a tempfile.
+ // See https://github.com/jedisct1/libsodium/issues/207
+ if out_dir.to_str().unwrap().contains(' ') {
+ out_dir = env::temp_dir()
+ .join("libsodium-sys")
+ .join(&target)
+ .join(&profile);
+ println!(
+ "cargo:warning=The path to the usual build directory contains spaces and hence \
+ can't be used to build libsodium. Falling back to use {}. If running `cargo \
+ clean`, ensure you also delete this fallback directory",
+ out_dir.display()
+ );
+ }
+
+ // Determine source and install dir
+ let install_dir = out_dir.join("installed");
+ let source_dir = out_dir.join("source").join("libsodium");
+
+ // Create directories
+ fs::create_dir_all(&install_dir).unwrap();
+ fs::create_dir_all(&source_dir).unwrap();
+
+ let paths = std::fs::read_dir("./libsodium").unwrap();
+
+ for path in paths {
+ println!("Name: {}", path.unwrap().path().display())
+ }
+
+ if !target.contains("msvc") {
+ // Copy sources into build directory
+ // Skip .git because it's marked read-only and that causes problems re-building
+ for entry in walkdir::WalkDir::new("libsodium")
+ .into_iter()
+ .filter_entry(|e| e.file_name() != OsStr::new(".git"))
+ .filter_map(Result::ok)
+ {
+ let outpath = out_dir.join("source").join(entry.path());
+ if let Err(e) = if entry.file_type().is_dir() {
+ fs::create_dir_all(outpath)
+ } else {
+ fs::copy(entry.path(), outpath).map(|_| ())
+ } {
+ panic!("Failed to copy sources into build directory: {}", e);
+ }
+ }
+ }
+
+ let lib_dir = make_libsodium(&target, &source_dir, &install_dir);
+
+ if target.contains("msvc") {
+ println!("cargo:rustc-link-lib=static=libsodium");
+ } else {
+ println!("cargo:rustc-link-lib=static=sodium");
+ }
+
+ println!(
+ "cargo:rustc-link-search=native={}",
+ lib_dir.to_str().unwrap()
+ );
+
+ let include_dir = source_dir.join("src/libsodium/include");
+
+ println!("cargo:include={}", include_dir.to_str().unwrap());
+ println!("cargo:lib={}", lib_dir.to_str().unwrap());
+}
])
# Generated Targets
-# buildifier: disable=out-of-order-load
-# buildifier: disable=load-on-top
-load(
- "@rules_rust//cargo:cargo_build_script.bzl",
- "cargo_build_script",
-)
-cargo_build_script(
- name = "libsodium_sys_build_script",
+# Unsupported target "build-script-build" with type "custom-build" omitted
+
+rust_library(
+ name = "libsodium_sys",
srcs = glob(["**/*.rs"]),
- build_script_env = {
- "NUM_JOBS": "2",
- "PATH": "/usr/sbin:/usr/bin:/sbin:/bin",
+ aliases = {
},
crate_features = [
],
- crate_root = "build.rs",
- data = glob(["**"]),
+ crate_root = "src/lib.rs",
+ crate_type = "lib",
+ data = [],
+ compile_data = glob(["*/**"]),
edition = "2015",
- links = "sodium",
rustc_flags = [
"--cap-lints=allow",
],
"manual",
],
version = "0.2.7",
- visibility = ["//visibility:private"],
+ # buildifier: leave-alone
deps = [
- "@raze__pkg_config__0_3_19//:pkg_config",
- "@raze__walkdir__2_3_2//:walkdir",
+ ":libsodium_sys_build_script",
+ "@raze__libc__0_2_101//:libc",
] + selects.with_or({
# cfg(not(target_env = "msvc"))
(
"@rules_rust//rust/platform:x86_64-unknown-freebsd",
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu",
): [
- "@raze__cc__1_0_70//:cc",
],
"//conditions:default": [],
}) + selects.with_or({
"@rules_rust//rust/platform:i686-pc-windows-msvc",
"@rules_rust//rust/platform:x86_64-pc-windows-msvc",
): [
- "@raze__libc__0_2_101//:libc",
],
"//conditions:default": [],
}),
)
-rust_library(
- name = "libsodium_sys",
- srcs = glob(["**/*.rs"]),
- aliases = {
+# Unsupported target "test" with type "test" omitted
+
+# Additional content from bazel/patch/BUILD_script_patch
+# buildifier: disable=load
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+# Generated Targets
+# buildifier: disable=out-of-order-load
+# buildifier: disable=load-on-top
+load(
+ "@rules_rust//cargo:cargo_build_script.bzl",
+ "cargo_build_script",
+)
+
+cargo_build_script(
+ name = "libsodium_sys_build_script",
+ srcs = ["@nova//bazel/patch:libsodium_sys_build_script_script_.rs"],
+ build_script_env = {
+ "NUM_JOBS": "2",
+ "PATH": "/usr/sbin:/usr/bin:/sbin:/bin",
},
- crate_features = [
- ],
- crate_root = "src/lib.rs",
- crate_type = "lib",
- data = [],
- compile_data = glob(["*/**"]),
+ data = glob(["**"]),
edition = "2015",
+ links = "sodium",
rustc_flags = [
"--cap-lints=allow",
],
"manual",
],
version = "0.2.7",
- # buildifier: leave-alone
+ visibility = ["//visibility:private"],
deps = [
- ":libsodium_sys_build_script",
- "@raze__libc__0_2_101//:libc",
+ "@raze__pkg_config__0_3_19//:pkg_config",
+ "@raze__walkdir__2_3_2//:walkdir",
] + selects.with_or({
# cfg(not(target_env = "msvc"))
(
"@rules_rust//rust/platform:x86_64-unknown-freebsd",
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu",
): [
+ "@raze__cc__1_0_70//:cc",
],
"//conditions:default": [],
}) + selects.with_or({
"@rules_rust//rust/platform:i686-pc-windows-msvc",
"@rules_rust//rust/platform:x86_64-pc-windows-msvc",
): [
+ "@raze__libc__0_2_101//:libc",
],
"//conditions:default": [],
}),
)
-
-# Unsupported target "test" with type "test" omitted