diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..d9fe8f3 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,2 @@ +startup --windows_enable_symlinks +build --enable_runfiles diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 257afc3..63393a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,25 +1,25 @@ -# This is a basic workflow to help you get started with Actions - name: CI -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch on: push: branches: [ master ] pull_request: branches: [ master ] -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job + runs-on: ${{ matrix.os }} + strategy: + # Keep running for other platforms when one fails + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + include: + - os: ubuntu-latest + PLATFORM: linux + - os: macos-latest + PLATFORM: darwin steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Mount bazel cache @@ -28,18 +28,17 @@ jobs: path: "/home/runner/.cache/bazel" key: bazel - # Runs a single command using the runners shell - name: Setup bazel + shell: bash run: | mkdir bin cd bin - wget https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64 - chmod +x bazelisk-linux-amd64 - mv bazelisk-linux-amd64 bazel + curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-${{matrix.PLATFORM}}-amd64 -o bazel + chmod +x bazel export PATH="$(readlink -e .):$PATH" - # Runs a set of commands using the runners shell - name: Run tests + shell: bash run: | cd $GITHUB_WORKSPACE ./tests/run.sh diff --git a/.gitignore b/.gitignore index 5bde647..2386695 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /bazel-* +*.swp diff --git a/BUILD b/BUILD index 4cfe889..13b9e96 100644 --- a/BUILD +++ b/BUILD @@ -11,6 +11,7 @@ rust_library( "@blackjack_crates_io_serde//:serde", "@blackjack_crates_io_serde_json//:serde_json", "@blackjack_crates_io_cargo_lock//:cargo_lock", + "@blackjack_crates_io_cfg_expr//:cfg_expr", ], edition = "2018", visibility = ["//visibility:public"], diff --git a/Cargo.lock b/Cargo.lock index 2647251..913142c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,7 @@ version = "0.1.0" dependencies = [ "cargo-lock", "cargo_metadata", + "cfg-expr", "serde", "serde_json", ] @@ -42,6 +43,15 @@ dependencies = [ "serde_json", ] +[[package]] +name = "cfg-expr" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2be76f06820200669a77ae59a8328c6b8fe4496e8fb7fed02f2806a442c5ff" +dependencies = [ + "smallvec", +] + [[package]] name = "fixedbitset" version = "0.2.0" @@ -197,6 +207,12 @@ dependencies = [ "serde", ] +[[package]] +name = "smallvec" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" + [[package]] name = "syn" version = "1.0.32" diff --git a/Cargo.toml b/Cargo.toml index d225fb6..00515f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ cargo_metadata = "0.10" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" cargo-lock = "4.0" +cfg-expr = "0.4" [package.metadata.blackjack] prefix = "blackjack_crates_io" diff --git a/README.md b/README.md index 319dbce..2b1483c 100644 --- a/README.md +++ b/README.md @@ -105,4 +105,4 @@ prefix = "blackjack_crates_io" Now instead of `@crates_io_serde//:serde`, use `blackjack_crates_io_serde//:serde`. # Things that don't work yet (but would gladly accept a PR for) -* Support for Windows and Mac. For the moment everything assumes your host and target is `x86_64-unknown-linux-gnu` +* Support for Windows. All that is really needed here is to add it to the list of supported platforms, and fix the platform specific workspace test. diff --git a/WORKSPACE b/WORKSPACE index ac0e23f..f6dae13 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,9 +4,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_rust", - strip_prefix = "rules_rust-fdf9655ba95616e0314b4e0ebab40bb0c5fe005c", - url = "https://github.com/bazelbuild/rules_rust/archive/fdf9655ba95616e0314b4e0ebab40bb0c5fe005c.zip", - sha256 = "83727c04706f441f8dfbfd262b0c69e19764a93ce9700167b1bdcf5831bf65e8", + strip_prefix = "rules_rust-3c9acce229b425e583dab7cf9523260bb05ecac3", + url = "https://github.com/bazelbuild/rules_rust/archive/3c9acce229b425e583dab7cf9523260bb05ecac3.zip", + sha256 = "e54a1445656fdea6b50ba5fac92433ce7ca09dc47dc627f80397e7ffe2c0bde7", ) http_archive( name = "bazel_skylib", diff --git a/blackjack.bzl b/blackjack.bzl index d481acc..a90b2d3 100644 --- a/blackjack.bzl +++ b/blackjack.bzl @@ -1,6 +1,6 @@ load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary") -def blackjack(name=None, manifest="Cargo.toml"): +def blackjack(name=None, manifest="//:Cargo.toml"): if not name: fail(msg="'name' must be set when calling blackjack(..)") @@ -8,6 +8,10 @@ def blackjack(name=None, manifest="Cargo.toml"): name = name, srcs = ["@blackjack//:src/bin/blackjack.rs"], aliases = {"@blackjack//:blackjack_lib": "blackjack"}, + args = [ + "$(location @blackjack_cargo//:blackjack_cargo.exe)", + "$(location %s) " % manifest, + ], deps = [ "@blackjack_crates_io_cargo_metadata//:cargo_metadata", "@blackjack_crates_io_cargo_lock//:cargo_lock", @@ -16,7 +20,7 @@ def blackjack(name=None, manifest="Cargo.toml"): edition = "2018", visibility = ["//visibility:public"], data = [ - "@blackjack_cargo//:cargo", + "@blackjack_cargo//:blackjack_cargo.exe", manifest, ], ) diff --git a/cargo_dependencies.bzl b/cargo_dependencies.bzl index a1300b7..066f11d 100644 --- a/cargo_dependencies.bzl +++ b/cargo_dependencies.bzl @@ -83,6 +83,31 @@ rust_library( ) + http_archive( + name = "blackjack_crates_io_cfg_expr", + url = "https://crates.io/api/v1/crates/cfg-expr/0.4.1/download", + sha256 = "6c2be76f06820200669a77ae59a8328c6b8fe4496e8fb7fed02f2806a442c5ff", + strip_prefix = "cfg-expr-0.4.1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "cfg_expr", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@blackjack_crates_io_smallvec_1.4.2//:smallvec"], + proc_macro_deps = [], + edition = "2018", + crate_features = ["default"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "blackjack_crates_io_fixedbitset_0.2.0", url = "https://crates.io/api/v1/crates/fixedbitset/0.2.0/download", @@ -533,6 +558,31 @@ rust_library( ) + http_archive( + name = "blackjack_crates_io_smallvec_1.4.2", + url = "https://crates.io/api/v1/crates/smallvec/1.4.2/download", + sha256 = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252", + strip_prefix = "smallvec-1.4.2", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "smallvec", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "blackjack_crates_io_syn_1.0.32", url = "https://crates.io/api/v1/crates/syn/1.0.32/download", diff --git a/src/bin/blackjack.rs b/src/bin/blackjack.rs index 84d7d19..c424e60 100644 --- a/src/bin/blackjack.rs +++ b/src/bin/blackjack.rs @@ -2,46 +2,31 @@ use blackjack::Blackjack; use cargo_lock::Lockfile; use cargo_metadata::MetadataCommand; use std::io::Write; -use std::path::{Path, PathBuf}; - -const CARGO_TOML_RUNFILES_PATH: &str = "Cargo.toml"; -const CARGO_RUNFILES_PATH: &str = "external/blackjack_cargo/cargo"; - -fn workspace_path() -> PathBuf { - // This is somewhat of an implementation detail - let mut cargo_toml_path = std::fs::read_link(CARGO_TOML_RUNFILES_PATH) - .unwrap_or_else(|_| PathBuf::from("Cargo.toml")); - cargo_toml_path.pop(); - cargo_toml_path -} - -fn set_cargo_path(metadata: &mut MetadataCommand) { - let cargo_runfiles_path = Path::new(CARGO_RUNFILES_PATH); - if cargo_runfiles_path.exists() { - eprintln!("Found cargo in runfiles: {}", cargo_runfiles_path.display()); - metadata.cargo_path(cargo_runfiles_path); - } else { - eprintln!( - "Using default cargo in path. Working dir: {}", - std::env::current_dir().unwrap().display() - ); - } -} +use std::path::PathBuf; fn main() { - let workspace_path = workspace_path(); - let cargo_toml_path = workspace_path.join("Cargo.toml"); + let mut args = std::env::args().skip(1); + let cargo_path = args.next().expect("No cargo path provided (1st argument)"); + let mut cargo_toml_path: PathBuf = args + .next() + .expect("No Cargo.toml path provided (2nd argument)") + .into(); + // If the Cargo.toml path is a symlink, resolve it first + if let Ok(p) = std::fs::read_link(&cargo_toml_path) { + cargo_toml_path = p; + } let mut metadata = MetadataCommand::new(); - metadata.manifest_path(&cargo_toml_path).other_options(vec![ - // TODO make this configurable - "--filter-platform".to_string(), - "x86_64-unknown-linux-gnu".to_string(), - ]); - set_cargo_path(&mut metadata); + metadata + .cargo_path(cargo_path) + .manifest_path(&cargo_toml_path); eprintln!("Blackjack will run `cargo metadata`, which may update your `Cargo.lock` file if it is not up to date"); + let workspace_path = { + cargo_toml_path.pop(); + cargo_toml_path + }; let output_path = workspace_path.join("cargo_dependencies.bzl"); eprintln!("Writing output to {}", output_path.display()); eprintln!("Press enter to continue, or Ctrl-C to abort"); diff --git a/src/lib.rs b/src/lib.rs index a4e266d..fbb6632 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,9 @@ use cargo_lock::Lockfile; -use cargo_metadata::{DependencyKind, Metadata, Node, NodeDep, Package, PackageId, Target}; +use cargo_metadata::{DependencyKind, Metadata, Node, Package, PackageId, Target}; +use cfg_expr::targets::get_builtin_target_by_triple; use serde::Deserialize; -use std::collections::{HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap, HashSet}; +use std::fmt; use std::io::Write; #[derive(Debug, Deserialize, Default)] @@ -29,6 +31,7 @@ struct BlackjackMetadata { } const DEFAULT_PREFIX: &str = "crates_io"; +const SUPPORTED_TARGETS: &[&str] = &["x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]; fn default_crate_opts() -> Vec<(String, CrateOpts)> { vec![ @@ -68,6 +71,13 @@ fn default_crate_opts() -> Vec<(String, CrateOpts)> { ..Default::default() }, ), + ( + "typenum".to_string(), + CrateOpts { + build_script: true, + ..Default::default() + }, + ), ] } @@ -187,13 +197,7 @@ def cargo_dependencies(): self.metadata.resolve.as_ref().unwrap().nodes.iter() } - fn crate_type(&self, package_id: &PackageId) -> CrateType { - let package = self - .metadata - .packages - .iter() - .find(|p| &p.id == package_id) - .unwrap(); + fn crate_type(&self, package: &Package) -> CrateType { match package.targets[0].crate_types[0].as_ref() { "proc-macro" => CrateType::ProcMacro, _ => CrateType::Lib, @@ -267,39 +271,100 @@ def cargo_dependencies(): } } - fn render_build_file(&self, node: &Node, package: &Package) -> String { - let target = library_target(package); - let all_deps: Vec = node - .deps - .iter() - .filter(|d| d.dep_kinds.iter().any(|k| k.kind == DependencyKind::Normal)) - .cloned() - .collect(); + // Add a package to the given DependencySet, with an optional target predicate. + fn add_dep( + &self, + dep_set: &mut DependencySet, + target: &Option, + package: &Package, + ) { + let dep_label = self.dep_label(package); + if let Some(target_expr) = target { + if let Some(_) = get_builtin_target_by_triple(&target_expr.to_string()) { + // The target expr is a target triple + if SUPPORTED_TARGETS.contains(&target_expr.to_string().as_str()) { + dep_set + .platform_specific_deps + .entry(triple_to_condition(target_expr)) + .or_insert_with(Vec::new) + .push(dep_label); + } + } else { + // The target triple is a more complex cfg(..) expression + let target_expr = cfg_expr::Expression::parse(&target_expr.to_string()) + .expect("Failed to parse target"); + // Check to which targets the target expression applies + for target in SUPPORTED_TARGETS { + let target = get_builtin_target_by_triple(target).unwrap(); + let uses_dep = target_expr.eval(|pred| match pred { + cfg_expr::Predicate::Target(tp) => tp.matches(target), + _ => false, + }); + if uses_dep { + dep_set + .platform_specific_deps + .entry(triple_to_condition(target.triple)) + .or_insert_with(Vec::new) + .push(dep_label.clone()); + } + } + } + } else { + // No target specified, add to the common dependencies for all platforms + dep_set.common_deps.push(dep_label); + } + } - let aliases: HashMap = all_deps - .iter() - .filter_map(|d| { - let dep_name = sanitize_name(&d.name); - let package = &self.packages.get(&d.pkg).unwrap(); + fn crate_deps(&self, node: &Node) -> CrateDependencies { + let mut crate_deps = CrateDependencies::default(); + for dep in &node.deps { + let package = self.packages.get(&dep.pkg).unwrap(); + let mut use_dep = false; + for dep_kind in &dep.dep_kinds { + // The dependency kind determines to which dependency set we need to add the + // package. + let dep_set = match dep_kind.kind { + DependencyKind::Build => Some(&mut crate_deps.build_deps), + DependencyKind::Normal if self.crate_type(&package) == CrateType::ProcMacro => { + Some(&mut crate_deps.proc_macro_deps) + } + DependencyKind::Normal => Some(&mut crate_deps.normal_deps), + _ => None, + }; + if let Some(dep_set) = dep_set { + use_dep = true; + self.add_dep(dep_set, &dep_kind.target, &package); + } + } + if use_dep { + let dep_name = sanitize_name(&dep.name); let package_name = sanitize_name(&package.name); - if dep_name == package_name { - None - } else { - Some((self.dep_label(package), dep_name)) + if dep_name != package_name { + crate_deps.aliases.insert(self.dep_label(package), dep_name); } - }) - .collect(); + } + } + // If any dependency sets have platform specific dependencies, they need to have a default + // condition for platforms that do not need any platform specific dependencies. + for dep_set in [ + &mut crate_deps.build_deps, + &mut crate_deps.proc_macro_deps, + &mut crate_deps.normal_deps, + ] + .iter_mut() + .filter(|ds| !ds.platform_specific_deps.is_empty()) + { + // If there are any platform specific deps, add the default empty condition + dep_set + .platform_specific_deps + .insert("//conditions:default".to_string(), Vec::new()); + } + crate_deps + } - let mut deps: Vec = all_deps - .iter() - .filter(|d| self.crate_type(&d.pkg) == CrateType::Lib) - .map(|d| self.dep_label(self.packages.get(&d.pkg).unwrap())) - .collect(); - let proc_macro_deps: Vec = all_deps - .iter() - .filter(|d| self.crate_type(&d.pkg) == CrateType::ProcMacro) - .map(|d| self.dep_label(self.packages.get(&d.pkg).unwrap())) - .collect(); + fn render_build_file(&self, node: &Node, package: &Package) -> String { + let target = library_target(package); + let mut crate_deps = self.crate_deps(node); let crate_opts = self .blackjack_metadata .crate_opts @@ -307,17 +372,24 @@ def cargo_dependencies(): .cloned() .unwrap_or_default(); let build_script = if crate_opts.build_script { - deps.push(":build_script".to_string()); - r#" + crate_deps + .normal_deps + .common_deps + .push(":build_script".to_string()); + format!( + r#" load("@io_bazel_rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script") cargo_build_script( name = "build_script", - srcs = ["build.rs"], + srcs = glob(["build.rs", "build/*.rs"]), + deps = {build_deps}, ) - "# + "#, + build_deps = crate_deps.build_deps + ) } else { - "" + "".to_string() }; format!( r#" @@ -328,8 +400,8 @@ rust_library( aliases = {aliases:?}, srcs = glob(["**/*.rs"]), crate_type = "{crate_type}", - deps = {deps:?}, - proc_macro_deps = {proc_macro_deps:?}, + deps = {deps}, + proc_macro_deps = {proc_macro_deps}, edition = "{edition}", crate_features = {crate_features:?}, rustc_flags = ["--cap-lints=allow"] + {rustc_flags:?}, @@ -338,10 +410,10 @@ rust_library( "#, build_script = build_script, name = sanitize_name(&package.name), - aliases = aliases, + aliases = crate_deps.aliases, crate_type = target.crate_types[0], - deps = deps, - proc_macro_deps = proc_macro_deps, + deps = crate_deps.normal_deps, + proc_macro_deps = crate_deps.proc_macro_deps, edition = target.edition, crate_features = node.features, rustc_flags = crate_opts.rustc_flags, @@ -363,6 +435,38 @@ rust_library( } } +/// All dependencies of a crate +#[derive(Default)] +struct CrateDependencies { + aliases: BTreeMap, + normal_deps: DependencySet, + proc_macro_deps: DependencySet, + build_deps: DependencySet, +} + +/// Represents the common and platform specific dependencies of a particular class (normal, +/// proc_macro, build) for a crate. +#[derive(Default)] +struct DependencySet { + common_deps: Vec, + platform_specific_deps: BTreeMap>, +} + +// Renders the dependencies as a valid bazel dependency set +impl fmt::Display for DependencySet { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.platform_specific_deps.is_empty() { + write!(f, "{:?}", self.common_deps) + } else { + write!( + f, + "{:?} + select({:?})", + self.common_deps, self.platform_specific_deps + ) + } + } +} + #[derive(PartialEq)] enum CrateType { Lib, @@ -387,7 +491,7 @@ fn library_target(package: &Package) -> &Target { .iter() .any(|kind| kind == "lib" || kind == "proc-macro") }) - .expect("dependency provides not lib or proc-macro target") + .expect("dependency provides no lib or proc-macro target") } fn direct_dependencies(metadata: &Metadata) -> HashSet { @@ -402,3 +506,7 @@ fn direct_dependencies(metadata: &Metadata) -> HashSet { .flat_map(|n| n.deps.iter().map(|d| d.pkg.clone())) .collect() } + +fn triple_to_condition(triple: T) -> String { + format!("@io_bazel_rules_rust//rust/platform:{}", triple) +} diff --git a/tests/linkc/.bazelrc b/tests/linkc/.bazelrc new file mode 100644 index 0000000..d9fe8f3 --- /dev/null +++ b/tests/linkc/.bazelrc @@ -0,0 +1,2 @@ +startup --windows_enable_symlinks +build --enable_runfiles diff --git a/tests/linkc/WORKSPACE b/tests/linkc/WORKSPACE index 6632efc..c789314 100644 --- a/tests/linkc/WORKSPACE +++ b/tests/linkc/WORKSPACE @@ -2,9 +2,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_rust", - sha256 = "83727c04706f441f8dfbfd262b0c69e19764a93ce9700167b1bdcf5831bf65e8", - strip_prefix = "rules_rust-fdf9655ba95616e0314b4e0ebab40bb0c5fe005c", - url = "https://github.com/bazelbuild/rules_rust/archive/fdf9655ba95616e0314b4e0ebab40bb0c5fe005c.zip", + strip_prefix = "rules_rust-3c9acce229b425e583dab7cf9523260bb05ecac3", + url = "https://github.com/bazelbuild/rules_rust/archive/3c9acce229b425e583dab7cf9523260bb05ecac3.zip", + sha256 = "e54a1445656fdea6b50ba5fac92433ce7ca09dc47dc627f80397e7ffe2c0bde7", ) http_archive( name = "bazel_skylib", diff --git a/tests/linkc/cargo_dependencies.bzl b/tests/linkc/cargo_dependencies.bzl index f742ffb..e677309 100644 --- a/tests/linkc/cargo_dependencies.bzl +++ b/tests/linkc/cargo_dependencies.bzl @@ -8,6 +8,31 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def cargo_dependencies(): + http_archive( + name = "crates_io_adler_0.2.3", + url = "https://crates.io/api/v1/crates/adler/0.2.3/download", + sha256 = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e", + strip_prefix = "adler-0.2.3", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "adler", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_cc_1.0.59", url = "https://crates.io/api/v1/crates/cc/1.0.59/download", @@ -158,6 +183,31 @@ rust_library( ) + http_archive( + name = "crates_io_miniz_oxide_0.4.1", + url = "https://crates.io/api/v1/crates/miniz_oxide/0.4.1/download", + sha256 = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722", + strip_prefix = "miniz_oxide-0.4.1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "miniz_oxide", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_adler_0.2.3//:adler"], + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_pkg_config_0.3.18", url = "https://crates.io/api/v1/crates/pkg-config/0.3.18/download", @@ -182,3 +232,28 @@ rust_library( """, ) + + http_archive( + name = "crates_io_vcpkg_0.2.10", + url = "https://crates.io/api/v1/crates/vcpkg/0.2.10/download", + sha256 = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c", + strip_prefix = "vcpkg-0.2.10", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "vcpkg", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + diff --git a/tests/platform_specific/.gitignore b/tests/platform_specific/.gitignore new file mode 100644 index 0000000..5bde647 --- /dev/null +++ b/tests/platform_specific/.gitignore @@ -0,0 +1,2 @@ +/target +/bazel-* diff --git a/tests/platform_specific/BUILD b/tests/platform_specific/BUILD new file mode 100644 index 0000000..f8b14d0 --- /dev/null +++ b/tests/platform_specific/BUILD @@ -0,0 +1,14 @@ +load("@blackjack//:blackjack.bzl", "blackjack") +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary") + +blackjack(name = "blackjack") + +rust_binary( + name = "main", + srcs = ["src/main.rs"], + deps = ["@crates_io_battery//:battery"], + rustc_flags = select({ + "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["-lframework=IOKit", "-lframework=CoreFoundation"], + "//conditions:default": [], + }), +) diff --git a/tests/platform_specific/Cargo.lock b/tests/platform_specific/Cargo.lock new file mode 100644 index 0000000..4cb2a1b --- /dev/null +++ b/tests/platform_specific/Cargo.lock @@ -0,0 +1,120 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "battery" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba81abd3ec70c6ef1d7a85c85cfcbab52b6b9536ea97e5ab7948d971603d2b" +dependencies = [ + "cfg-if", + "core-foundation", + "lazycell", + "libc", + "mach", + "num-traits", + "uom", + "winapi", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "num-traits" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +dependencies = [ + "autocfg", +] + +[[package]] +name = "platform_specific" +version = "0.1.0" +dependencies = [ + "battery", +] + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "uom" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed" +dependencies = [ + "num-traits", + "typenum", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/tests/platform_specific/Cargo.toml b/tests/platform_specific/Cargo.toml new file mode 100644 index 0000000..cb571b0 --- /dev/null +++ b/tests/platform_specific/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "platform_specific" +version = "0.1.0" +authors = ["Daan de Graaf "] +edition = "2018" + +[dependencies] +battery = "0.7" diff --git a/tests/platform_specific/WORKSPACE b/tests/platform_specific/WORKSPACE new file mode 100644 index 0000000..521f2f2 --- /dev/null +++ b/tests/platform_specific/WORKSPACE @@ -0,0 +1,29 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_rust", + strip_prefix = "rules_rust-3c9acce229b425e583dab7cf9523260bb05ecac3", + url = "https://github.com/bazelbuild/rules_rust/archive/3c9acce229b425e583dab7cf9523260bb05ecac3.zip", + sha256 = "e54a1445656fdea6b50ba5fac92433ce7ca09dc47dc627f80397e7ffe2c0bde7", +) +http_archive( + name = "bazel_skylib", + sha256 = "605dde26ddac0f3439e74801ab79f9dbf1c6e3854d4c3cb2c0b9d73119c56a14", + strip_prefix = "bazel-skylib-2ec2e6d715e993d96ad6222770805b5bd25399ae", + url = "https://github.com/bazelbuild/bazel-skylib/archive/2ec2e6d715e993d96ad6222770805b5bd25399ae.zip", # 2020-09-04 +) +load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version") +bazel_version(name = "bazel_version") +load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories") +rust_repositories() + +local_repository( + name = "blackjack", + path = "../..", +) + +load("@blackjack//:workspace.bzl", "blackjack_cargo") +blackjack_cargo() + +load("//:cargo_dependencies.bzl", "cargo_dependencies") +cargo_dependencies() diff --git a/tests/platform_specific/cargo_dependencies.bzl b/tests/platform_specific/cargo_dependencies.bzl new file mode 100644 index 0000000..bd2d7b3 --- /dev/null +++ b/tests/platform_specific/cargo_dependencies.bzl @@ -0,0 +1,367 @@ +""" +DO NOT EDIT! + +This file is automatically @generated by blackjack. +""" +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def cargo_dependencies(): + + + http_archive( + name = "crates_io_autocfg_1.0.1", + url = "https://crates.io/api/v1/crates/autocfg/1.0.1/download", + sha256 = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a", + strip_prefix = "autocfg-1.0.1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "autocfg", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_battery", + url = "https://crates.io/api/v1/crates/battery/0.7.7/download", + sha256 = "e3ba81abd3ec70c6ef1d7a85c85cfcbab52b6b9536ea97e5ab7948d971603d2b", + strip_prefix = "battery-0.7.7", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "battery", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_cfg_if_1.0.0//:cfg_if", "@crates_io_num_traits_0.2.12//:num_traits", "@crates_io_uom_0.30.0//:uom"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_core_foundation_0.7.0//:core_foundation", "@crates_io_libc_0.2.79//:libc", "@crates_io_mach_0.3.2//:mach"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_lazycell_1.3.0//:lazycell"]}), + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_cfg_if_1.0.0", + url = "https://crates.io/api/v1/crates/cfg-if/1.0.0/download", + sha256 = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd", + strip_prefix = "cfg-if-1.0.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "cfg_if", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_core_foundation_0.7.0", + url = "https://crates.io/api/v1/crates/core-foundation/0.7.0/download", + sha256 = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171", + strip_prefix = "core-foundation-0.7.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "core_foundation", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_core_foundation_sys_0.7.0//:core_foundation_sys", "@crates_io_libc_0.2.79//:libc"], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_core_foundation_sys_0.7.0", + url = "https://crates.io/api/v1/crates/core-foundation-sys/0.7.0/download", + sha256 = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac", + strip_prefix = "core-foundation-sys-0.7.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "core_foundation_sys", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_lazycell_1.3.0", + url = "https://crates.io/api/v1/crates/lazycell/1.3.0/download", + sha256 = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55", + strip_prefix = "lazycell-1.3.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "lazycell", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_libc_0.2.79", + url = "https://crates.io/api/v1/crates/libc/0.2.79/download", + sha256 = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743", + strip_prefix = "libc-0.2.79", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "libc", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = ["default", "std"], + rustc_flags = ["--cap-lints=allow"] + ["--cfg=libc_priv_mod_use", "--cfg=libc_union", "--cfg=libc_const_size_of", "--cfg=libc_align", "--cfg=libc_core_cvoid", "--cfg=libc_packedN", "--cfg=libc_cfg_target_vendor"], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_mach_0.3.2", + url = "https://crates.io/api/v1/crates/mach/0.3.2/download", + sha256 = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa", + strip_prefix = "mach-0.3.2", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "mach", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.79//:libc"]}), + proc_macro_deps = [], + edition = "2015", + crate_features = ["default"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_num_traits_0.2.12", + url = "https://crates.io/api/v1/crates/num-traits/0.2.12/download", + sha256 = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611", + strip_prefix = "num-traits-0.2.12", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "num_traits", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = ["std"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_typenum_1.12.0", + url = "https://crates.io/api/v1/crates/typenum/1.12.0/download", + sha256 = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33", + strip_prefix = "typenum-1.12.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +load("@io_bazel_rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script") + +cargo_build_script( + name = "build_script", + srcs = glob(["build.rs", "build/*.rs"]), + deps = [], +) + +rust_library( + name = "typenum", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [":build_script"], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_uom_0.30.0", + url = "https://crates.io/api/v1/crates/uom/0.30.0/download", + sha256 = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed", + strip_prefix = "uom-0.30.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "uom", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_num_traits_0.2.12//:num_traits", "@crates_io_typenum_1.12.0//:typenum"], + proc_macro_deps = [], + edition = "2018", + crate_features = ["autoconvert", "default", "f32", "f64", "si", "std"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_0.3.9", + url = "https://crates.io/api/v1/crates/winapi/0.3.9/download", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + strip_prefix = "winapi-0.3.9", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = ["devguid", "errhandlingapi", "handleapi", "impl-default", "ioapiset", "ntdef", "setupapi", "winbase", "winerror"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_i686_pc_windows_gnu_0.4.0", + url = "https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/0.4.0/download", + sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi_i686_pc_windows_gnu", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_x86_64_pc_windows_gnu_0.4.0", + url = "https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download", + sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + diff --git a/tests/platform_specific/src/main.rs b/tests/platform_specific/src/main.rs new file mode 100644 index 0000000..c8642ac --- /dev/null +++ b/tests/platform_specific/src/main.rs @@ -0,0 +1,7 @@ +fn main() -> battery::Result<()> { + println!( + "Batteries detected: {}", + battery::Manager::new()?.batteries()?.count() + ); + Ok(()) +} diff --git a/tests/popular_crates/.bazelrc b/tests/popular_crates/.bazelrc new file mode 100644 index 0000000..d9fe8f3 --- /dev/null +++ b/tests/popular_crates/.bazelrc @@ -0,0 +1,2 @@ +startup --windows_enable_symlinks +build --enable_runfiles diff --git a/tests/popular_crates/WORKSPACE b/tests/popular_crates/WORKSPACE index d4b927a..1bed3f2 100644 --- a/tests/popular_crates/WORKSPACE +++ b/tests/popular_crates/WORKSPACE @@ -2,9 +2,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_rust", - sha256 = "83727c04706f441f8dfbfd262b0c69e19764a93ce9700167b1bdcf5831bf65e8", - strip_prefix = "rules_rust-fdf9655ba95616e0314b4e0ebab40bb0c5fe005c", - url = "https://github.com/bazelbuild/rules_rust/archive/fdf9655ba95616e0314b4e0ebab40bb0c5fe005c.zip", + strip_prefix = "rules_rust-3c9acce229b425e583dab7cf9523260bb05ecac3", + url = "https://github.com/bazelbuild/rules_rust/archive/3c9acce229b425e583dab7cf9523260bb05ecac3.zip", + sha256 = "e54a1445656fdea6b50ba5fac92433ce7ca09dc47dc627f80397e7ffe2c0bde7", ) http_archive( name = "bazel_skylib", diff --git a/tests/popular_crates/cargo_dependencies.bzl b/tests/popular_crates/cargo_dependencies.bzl index 234d1f9..4606073 100644 --- a/tests/popular_crates/cargo_dependencies.bzl +++ b/tests/popular_crates/cargo_dependencies.bzl @@ -808,6 +808,31 @@ rust_library( ) + http_archive( + name = "crates_io_cloudabi_0.1.0", + url = "https://crates.io/api/v1/crates/cloudabi/0.1.0/download", + sha256 = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467", + strip_prefix = "cloudabi-0.1.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "cloudabi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_bitflags_1.2.1//:bitflags"], + proc_macro_deps = [], + edition = "2018", + crate_features = ["bitflags", "default"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_copyless_0.1.5", url = "https://crates.io/api/v1/crates/copyless/0.1.5/download", @@ -1133,6 +1158,56 @@ rust_library( ) + http_archive( + name = "crates_io_fuchsia_zircon_0.3.3", + url = "https://crates.io/api/v1/crates/fuchsia-zircon/0.3.3/download", + sha256 = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82", + strip_prefix = "fuchsia-zircon-0.3.3", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "fuchsia_zircon", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_bitflags_1.2.1//:bitflags", "@crates_io_fuchsia_zircon_sys_0.3.3//:fuchsia_zircon_sys"], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_fuchsia_zircon_sys_0.3.3", + url = "https://crates.io/api/v1/crates/fuchsia-zircon-sys/0.3.3/download", + sha256 = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7", + strip_prefix = "fuchsia-zircon-sys-0.3.3", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "fuchsia_zircon_sys", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_futures_0.3.5", url = "https://crates.io/api/v1/crates/futures/0.3.5/download", @@ -1397,7 +1472,7 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_libc_0.2.76//:libc"], + deps = ["@crates_io_cfg_if_0.1.10//:cfg_if"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2018", crate_features = ["std"], @@ -1508,6 +1583,31 @@ rust_library( ) + http_archive( + name = "crates_io_hermit_abi_0.1.15", + url = "https://crates.io/api/v1/crates/hermit-abi/0.1.15/download", + sha256 = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9", + strip_prefix = "hermit-abi-0.1.15", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "hermit_abi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_libc_0.2.76//:libc"], + proc_macro_deps = [], + edition = "2018", + crate_features = ["default"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_hostname_0.3.1", url = "https://crates.io/api/v1/crates/hostname/0.3.1/download", @@ -1522,7 +1622,7 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_libc_0.2.76//:libc", "@crates_io_match_cfg_0.1.0//:match_cfg"], + deps = ["@crates_io_match_cfg_0.1.0//:match_cfg"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2015", crate_features = ["default"], @@ -1672,7 +1772,7 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_libc_0.2.76//:libc"], + deps = [] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2015", crate_features = [], @@ -1683,6 +1783,31 @@ rust_library( ) + http_archive( + name = "crates_io_ipconfig_0.2.2", + url = "https://crates.io/api/v1/crates/ipconfig/0.2.2/download", + sha256 = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7", + strip_prefix = "ipconfig-0.2.2", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "ipconfig", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_itoa_0.4.6", url = "https://crates.io/api/v1/crates/itoa/0.4.6/download", @@ -1708,6 +1833,31 @@ rust_library( ) + http_archive( + name = "crates_io_kernel32_sys_0.2.2", + url = "https://crates.io/api/v1/crates/kernel32-sys/0.2.2/download", + sha256 = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d", + strip_prefix = "kernel32-sys-0.2.2", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "kernel32_sys", + aliases = {"@crates_io_winapi_build_0.1.1//:winapi_build": "build"}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_winapi_0.2.8//:winapi"], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_language_tags_0.2.2", url = "https://crates.io/api/v1/crates/language-tags/0.2.2/download", @@ -2019,10 +2169,10 @@ load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") rust_library( name = "mio", - aliases = {}, + aliases = {"@crates_io_kernel32_sys_0.2.2//:kernel32_sys": "kernel32"}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_iovec_0.1.4//:iovec", "@crates_io_libc_0.2.76//:libc", "@crates_io_log_0.4.11//:log", "@crates_io_net2_0.2.34//:net2", "@crates_io_slab_0.4.2//:slab"], + deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_iovec_0.1.4//:iovec", "@crates_io_log_0.4.11//:log", "@crates_io_net2_0.2.34//:net2", "@crates_io_slab_0.4.2//:slab"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2015", crate_features = ["default", "with-deprecated"], @@ -2047,7 +2197,32 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_iovec_0.1.4//:iovec", "@crates_io_libc_0.2.76//:libc", "@crates_io_mio_0.6.22//:mio"], + deps = [] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_iovec_0.1.4//:iovec", "@crates_io_libc_0.2.76//:libc", "@crates_io_mio_0.6.22//:mio"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_iovec_0.1.4//:iovec", "@crates_io_libc_0.2.76//:libc", "@crates_io_mio_0.6.22//:mio"]}), + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_miow_0.2.1", + url = "https://crates.io/api/v1/crates/miow/0.2.1/download", + sha256 = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919", + strip_prefix = "miow-0.2.1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "miow", + aliases = {"@crates_io_kernel32_sys_0.2.2//:kernel32_sys": "kernel32", "@crates_io_ws2_32_sys_0.2.1//:ws2_32_sys": "ws2_32"}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_kernel32_sys_0.2.2//:kernel32_sys", "@crates_io_net2_0.2.34//:net2", "@crates_io_winapi_0.2.8//:winapi", "@crates_io_ws2_32_sys_0.2.1//:ws2_32_sys"], proc_macro_deps = [], edition = "2015", crate_features = [], @@ -2072,7 +2247,7 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_libc_0.2.76//:libc"], + deps = ["@crates_io_cfg_if_0.1.10//:cfg_if"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2015", crate_features = ["default", "duration"], @@ -2244,10 +2419,10 @@ load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") rust_library( name = "parking_lot_core", - aliases = {}, + aliases = {"@crates_io_redox_syscall_0.1.57//:redox_syscall": "syscall"}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_instant_0.1.6//:instant", "@crates_io_libc_0.2.76//:libc", "@crates_io_smallvec_1.4.2//:smallvec"], + deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_instant_0.1.6//:instant", "@crates_io_smallvec_1.4.2//:smallvec"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2018", crate_features = [], @@ -2446,7 +2621,8 @@ load("@io_bazel_rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script") cargo_build_script( name = "build_script", - srcs = ["build.rs"], + srcs = glob(["build.rs", "build/*.rs"]), + deps = [], ) rust_library( @@ -2554,7 +2730,7 @@ rust_library( aliases = {"@crates_io_getrandom_0.1.14//:getrandom": "getrandom_package"}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_getrandom_0.1.14//:getrandom", "@crates_io_libc_0.2.76//:libc", "@crates_io_rand_chacha_0.2.2//:rand_chacha", "@crates_io_rand_core_0.5.1//:rand_core"], + deps = ["@crates_io_getrandom_0.1.14//:getrandom", "@crates_io_rand_core_0.5.1//:rand_core"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc", "@crates_io_rand_chacha_0.2.2//:rand_chacha"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc", "@crates_io_rand_chacha_0.2.2//:rand_chacha"]}), proc_macro_deps = [], edition = "2018", crate_features = ["alloc", "default", "getrandom", "getrandom_package", "libc", "std"], @@ -2615,6 +2791,56 @@ rust_library( ) + http_archive( + name = "crates_io_rand_hc_0.2.0", + url = "https://crates.io/api/v1/crates/rand_hc/0.2.0/download", + sha256 = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c", + strip_prefix = "rand_hc-0.2.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "rand_hc", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_rand_core_0.5.1//:rand_core"], + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_redox_syscall_0.1.57", + url = "https://crates.io/api/v1/crates/redox_syscall/0.1.57/download", + sha256 = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce", + strip_prefix = "redox_syscall-0.1.57", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "redox_syscall", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + http_archive( name = "crates_io_regex_1.3.9", url = "https://crates.io/api/v1/crates/regex/1.3.9/download", @@ -2976,10 +3202,10 @@ load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") rust_library( name = "socket2", - aliases = {}, + aliases = {"@crates_io_redox_syscall_0.1.57//:redox_syscall": "syscall"}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_libc_0.2.76//:libc"], + deps = [] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2018", crate_features = [], @@ -3154,7 +3380,7 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_bytes_0.5.6//:bytes", "@crates_io_futures_core_0.3.5//:futures_core", "@crates_io_iovec_0.1.4//:iovec", "@crates_io_lazy_static_1.4.0//:lazy_static", "@crates_io_libc_0.2.76//:libc", "@crates_io_memchr_2.3.3//:memchr", "@crates_io_mio_0.6.22//:mio", "@crates_io_mio_uds_0.6.8//:mio_uds", "@crates_io_pin_project_lite_0.1.7//:pin_project_lite", "@crates_io_signal_hook_registry_1.2.1//:signal_hook_registry", "@crates_io_slab_0.4.2//:slab"], + deps = ["@crates_io_bytes_0.5.6//:bytes", "@crates_io_futures_core_0.3.5//:futures_core", "@crates_io_iovec_0.1.4//:iovec", "@crates_io_lazy_static_1.4.0//:lazy_static", "@crates_io_memchr_2.3.3//:memchr", "@crates_io_mio_0.6.22//:mio", "@crates_io_pin_project_lite_0.1.7//:pin_project_lite", "@crates_io_slab_0.4.2//:slab"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc", "@crates_io_mio_uds_0.6.8//:mio_uds", "@crates_io_signal_hook_registry_1.2.1//:signal_hook_registry"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc", "@crates_io_mio_uds_0.6.8//:mio_uds", "@crates_io_signal_hook_registry_1.2.1//:signal_hook_registry"]}), proc_macro_deps = [], edition = "2018", crate_features = ["default", "futures-core", "io-driver", "io-util", "iovec", "lazy_static", "libc", "memchr", "mio", "mio-uds", "rt-core", "rt-util", "signal", "signal-hook-registry", "slab", "stream", "tcp", "time", "udp", "uds", "winapi"], @@ -3439,3 +3665,228 @@ rust_library( """, ) + + http_archive( + name = "crates_io_wasi_0.9.0--PLUS--wasi-snapshot-preview1", + url = "https://crates.io/api/v1/crates/wasi/0.9.0+wasi-snapshot-preview1/download", + sha256 = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519", + strip_prefix = "wasi-0.9.0+wasi-snapshot-preview1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "wasi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2018", + crate_features = ["default", "std"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_widestring_0.4.2", + url = "https://crates.io/api/v1/crates/widestring/0.4.2/download", + sha256 = "a763e303c0e0f23b0da40888724762e802a8ffefbc22de4127ef42493c2ea68c", + strip_prefix = "widestring-0.4.2", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "widestring", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = ["alloc", "default", "std"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_0.2.8", + url = "https://crates.io/api/v1/crates/winapi/0.2.8/download", + sha256 = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a", + strip_prefix = "winapi-0.2.8", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_0.3.9", + url = "https://crates.io/api/v1/crates/winapi/0.3.9/download", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + strip_prefix = "winapi-0.3.9", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = ["consoleapi", "errhandlingapi", "handleapi", "impl-debug", "impl-default", "minwinbase", "minwindef", "ntdef", "ntstatus", "profileapi", "std", "sysinfoapi", "timezoneapi", "winbase", "winerror", "winnt", "winreg", "winsock2", "ws2def", "ws2ipdef", "ws2tcpip"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_build_0.1.1", + url = "https://crates.io/api/v1/crates/winapi-build/0.1.1/download", + sha256 = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc", + strip_prefix = "winapi-build-0.1.1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi_build", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_i686_pc_windows_gnu_0.4.0", + url = "https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/0.4.0/download", + sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi_i686_pc_windows_gnu", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winapi_x86_64_pc_windows_gnu_0.4.0", + url = "https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download", + sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_winreg_0.6.2", + url = "https://crates.io/api/v1/crates/winreg/0.6.2/download", + sha256 = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9", + strip_prefix = "winreg-0.6.2", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "winreg", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_winapi_0.3.9//:winapi"], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_ws2_32_sys_0.2.1", + url = "https://crates.io/api/v1/crates/ws2_32-sys/0.2.1/download", + sha256 = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e", + strip_prefix = "ws2_32-sys-0.2.1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "ws2_32_sys", + aliases = {"@crates_io_winapi_build_0.1.1//:winapi_build": "build"}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_winapi_0.2.8//:winapi"], + proc_macro_deps = [], + edition = "2015", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + diff --git a/tests/run.sh b/tests/run.sh index 492c4be..4a8b26b 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -4,6 +4,11 @@ set -e echo | bazel run //:blackjack bazel build //:all +pushd tests/platform_specific +echo | bazel run //:blackjack +bazel run //:main +popd + pushd tests/popular_crates echo | bazel run //:blackjack bazel build //:crates @@ -19,3 +24,4 @@ echo | bazel run //:blackjack bazel run //crate1 bazel run //crate2 popd + diff --git a/tests/workspace/.bazelrc b/tests/workspace/.bazelrc new file mode 100644 index 0000000..d9fe8f3 --- /dev/null +++ b/tests/workspace/.bazelrc @@ -0,0 +1,2 @@ +startup --windows_enable_symlinks +build --enable_runfiles diff --git a/tests/workspace/WORKSPACE b/tests/workspace/WORKSPACE index b469ba0..50353f4 100644 --- a/tests/workspace/WORKSPACE +++ b/tests/workspace/WORKSPACE @@ -2,9 +2,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_rust", - sha256 = "83727c04706f441f8dfbfd262b0c69e19764a93ce9700167b1bdcf5831bf65e8", - strip_prefix = "rules_rust-fdf9655ba95616e0314b4e0ebab40bb0c5fe005c", - url = "https://github.com/bazelbuild/rules_rust/archive/fdf9655ba95616e0314b4e0ebab40bb0c5fe005c.zip", + strip_prefix = "rules_rust-3c9acce229b425e583dab7cf9523260bb05ecac3", + url = "https://github.com/bazelbuild/rules_rust/archive/3c9acce229b425e583dab7cf9523260bb05ecac3.zip", + sha256 = "e54a1445656fdea6b50ba5fac92433ce7ca09dc47dc627f80397e7ffe2c0bde7", ) http_archive( name = "bazel_skylib", diff --git a/tests/workspace/cargo_dependencies.bzl b/tests/workspace/cargo_dependencies.bzl index 0f750fa..02ae1fd 100644 --- a/tests/workspace/cargo_dependencies.bzl +++ b/tests/workspace/cargo_dependencies.bzl @@ -72,7 +72,7 @@ rust_library( aliases = {}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_cfg_if_0.1.10//:cfg_if", "@crates_io_libc_0.2.76//:libc"], + deps = ["@crates_io_cfg_if_0.1.10//:cfg_if"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc"]}), proc_macro_deps = [], edition = "2018", crate_features = ["std"], @@ -147,7 +147,7 @@ rust_library( aliases = {"@crates_io_getrandom_0.1.14//:getrandom": "getrandom_package"}, srcs = glob(["**/*.rs"]), crate_type = "lib", - deps = ["@crates_io_getrandom_0.1.14//:getrandom", "@crates_io_libc_0.2.76//:libc", "@crates_io_rand_chacha_0.2.2//:rand_chacha", "@crates_io_rand_core_0.5.1//:rand_core"], + deps = ["@crates_io_getrandom_0.1.14//:getrandom", "@crates_io_rand_core_0.5.1//:rand_core"] + select({"//conditions:default": [], "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin": ["@crates_io_libc_0.2.76//:libc", "@crates_io_rand_chacha_0.2.2//:rand_chacha"], "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu": ["@crates_io_libc_0.2.76//:libc", "@crates_io_rand_chacha_0.2.2//:rand_chacha"]}), proc_macro_deps = [], edition = "2018", crate_features = ["alloc", "default", "getrandom", "getrandom_package", "libc", "std"], @@ -207,3 +207,53 @@ rust_library( """, ) + + http_archive( + name = "crates_io_rand_hc_0.2.0", + url = "https://crates.io/api/v1/crates/rand_hc/0.2.0/download", + sha256 = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c", + strip_prefix = "rand_hc-0.2.0", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "rand_hc", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = ["@crates_io_rand_core_0.5.1//:rand_core"], + proc_macro_deps = [], + edition = "2018", + crate_features = [], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + + + http_archive( + name = "crates_io_wasi_0.9.0--PLUS--wasi-snapshot-preview1", + url = "https://crates.io/api/v1/crates/wasi/0.9.0+wasi-snapshot-preview1/download", + sha256 = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519", + strip_prefix = "wasi-0.9.0+wasi-snapshot-preview1", + type = "tar.gz", + build_file_content = """ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "wasi", + aliases = {}, + srcs = glob(["**/*.rs"]), + crate_type = "lib", + deps = [], + proc_macro_deps = [], + edition = "2018", + crate_features = ["default", "std"], + rustc_flags = ["--cap-lints=allow"] + [], + visibility = ["//visibility:public"], +) + """, + ) + diff --git a/workspace.bzl b/workspace.bzl index dc7c728..88ea696 100644 --- a/workspace.bzl +++ b/workspace.bzl @@ -1,14 +1,33 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@blackjack//:cargo_dependencies.bzl", "cargo_dependencies") -def blackjack_cargo(): - http_archive( - name = "blackjack_cargo", - # Taken from https://static.rust-lang.org/dist/channel-rust-stable.toml. - url = "https://static.rust-lang.org/dist/2020-08-03/cargo-0.46.1-x86_64-unknown-linux-gnu.tar.gz", - sha256 = "ac2746e3d3bab7301b8aa747eff7c4d66f9c88a61f9117a4d6669c40317b69cc", - strip_prefix = "cargo-0.46.1-x86_64-unknown-linux-gnu/cargo/bin", - build_file_content = """exports_files(["cargo"], visibility = ["//visibility:public"])""", +def _cargo_target(os_name): + if os_name.startswith("mac os"): + return "x86_64-apple-darwin" + if os_name.find("windows") != -1: + return "x86_64-pc-windows-msvc" + else: + return "x86_64-unknown-linux-gnu" + +def _cargo_binary_name(os_name): + if os_name.find("windows") != -1: + return "cargo.exe" + else: + return "cargo" + +def _blackjack_cargo_impl(ctx): + os_name = ctx.os.name.lower() + target = _cargo_target(os_name) + ctx.download_and_extract( + url = "https://static.rust-lang.org/dist/2020-08-03/cargo-0.46.1-%s.tar.gz" % target, + stripPrefix = "cargo-0.46.1-%s/cargo/bin" % target, ) + ctx.file("BUILD.bazel", """alias(name="blackjack_cargo.exe", actual = "%s", visibility = ["//visibility:public"])""" % _cargo_binary_name(os_name)) +_blackjack_cargo = repository_rule( + implementation = _blackjack_cargo_impl, +) + +def blackjack_cargo(): + _blackjack_cargo(name = "blackjack_cargo") cargo_dependencies()