diff --git a/examples/remote/complicated_cargo_library/Cargo.toml b/examples/remote/complicated_cargo_library/Cargo.toml index 6a64b7763..4f4617667 100644 --- a/examples/remote/complicated_cargo_library/Cargo.toml +++ b/examples/remote/complicated_cargo_library/Cargo.toml @@ -19,6 +19,7 @@ workspace_path = "//remote/complicated_cargo_library/cargo" gen_workspace_prefix = "remote_complicated_cargo_library" genmode = "Remote" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.proc-macro2.'0.4.30'] additional_flags = [ diff --git a/examples/remote/no_deps/Cargo.toml b/examples/remote/no_deps/Cargo.toml index fe020873a..278456cc4 100644 --- a/examples/remote/no_deps/Cargo.toml +++ b/examples/remote/no_deps/Cargo.toml @@ -12,3 +12,4 @@ workspace_path = "//remote/no_deps/cargo" genmode = "Remote" gen_workspace_prefix = "remote_no_deps" package_aliases_dir = "cargo" +default_gen_buildrs = true diff --git a/examples/remote/non_cratesio/Cargo.toml b/examples/remote/non_cratesio/Cargo.toml index 74f96d48f..3f82dedd1 100644 --- a/examples/remote/non_cratesio/Cargo.toml +++ b/examples/remote/non_cratesio/Cargo.toml @@ -17,10 +17,17 @@ path = "src/main.rs" [package.metadata.raze] workspace_path = "//remote/non_cratesio/cargo" -target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", +] genmode = "Remote" gen_workspace_prefix = "remote_non_cratesio" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.log.'0.4.11'] additional_flags = [ diff --git a/examples/remote/non_cratesio/cargo/remote/BUILD.atty-0.2.14.bazel b/examples/remote/non_cratesio/cargo/remote/BUILD.atty-0.2.14.bazel index 55a61524f..c2cd423a3 100644 --- a/examples/remote/non_cratesio/cargo/remote/BUILD.atty-0.2.14.bazel +++ b/examples/remote/non_cratesio/cargo/remote/BUILD.atty-0.2.14.bazel @@ -57,24 +57,20 @@ rust_library( # cfg(unix) ( "@io_bazel_rules_rust//rust/platform:aarch64-apple-darwin", - "@io_bazel_rules_rust//rust/platform:aarch64-apple-ios", - "@io_bazel_rules_rust//rust/platform:aarch64-linux-android", "@io_bazel_rules_rust//rust/platform:aarch64-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:arm-unknown-linux-gnueabi", - "@io_bazel_rules_rust//rust/platform:i686-apple-darwin", - "@io_bazel_rules_rust//rust/platform:i686-linux-android", - "@io_bazel_rules_rust//rust/platform:i686-unknown-freebsd", - "@io_bazel_rules_rust//rust/platform:i686-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:powerpc-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:s390x-unknown-linux-gnu", "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin", - "@io_bazel_rules_rust//rust/platform:x86_64-apple-ios", - "@io_bazel_rules_rust//rust/platform:x86_64-linux-android", - "@io_bazel_rules_rust//rust/platform:x86_64-unknown-freebsd", "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu", ): [ "@remote_non_cratesio__libc__0_2_77//:libc", ], "//conditions:default": [], + }) + selects.with_or({ + # cfg(windows) + ( + "@io_bazel_rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@remote_non_cratesio__winapi__0_3_9//:winapi", + ], + "//conditions:default": [], }), ) diff --git a/examples/remote/non_cratesio/cargo/remote/BUILD.termcolor-0.3.6.bazel b/examples/remote/non_cratesio/cargo/remote/BUILD.termcolor-0.3.6.bazel index cc36142fb..af187f836 100644 --- a/examples/remote/non_cratesio/cargo/remote/BUILD.termcolor-0.3.6.bazel +++ b/examples/remote/non_cratesio/cargo/remote/BUILD.termcolor-0.3.6.bazel @@ -33,6 +33,8 @@ licenses([ rust_library( name = "termcolor", srcs = glob(["**/*.rs"]), + aliases = { + }, crate_features = [ ], crate_root = "src/lib.rs", @@ -49,5 +51,13 @@ rust_library( version = "0.3.6", # buildifier: leave-alone deps = [ - ], + ] + selects.with_or({ + # cfg(windows) + ( + "@io_bazel_rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@remote_non_cratesio__wincolor__0_1_6//:wincolor", + ], + "//conditions:default": [], + }), ) diff --git a/examples/vendored/complicated_cargo_library/Cargo.toml b/examples/vendored/complicated_cargo_library/Cargo.toml index 652c625e9..eb0b1a786 100644 --- a/examples/vendored/complicated_cargo_library/Cargo.toml +++ b/examples/vendored/complicated_cargo_library/Cargo.toml @@ -17,6 +17,7 @@ workspace_path = "//vendored/complicated_cargo_library/cargo" gen_workspace_prefix = "vendored_complicated_cargo_library" genmode = "Vendored" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.proc-macro2.'0.4.30'] additional_flags = [ diff --git a/examples/vendored/hello_cargo_library/Cargo.toml b/examples/vendored/hello_cargo_library/Cargo.toml index 4966e3a1d..9d41dab2d 100644 --- a/examples/vendored/hello_cargo_library/Cargo.toml +++ b/examples/vendored/hello_cargo_library/Cargo.toml @@ -13,8 +13,15 @@ path = "src/main.rs" [package.metadata.raze] workspace_path = "//vendored/hello_cargo_library/cargo" -target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", +] output_buildfile_suffix = "BUILD.bazel" gen_workspace_prefix = "vendored_hello_cargo_library" genmode = "Vendored" package_aliases_dir = "cargo" +default_gen_buildrs = false diff --git a/examples/vendored/non_cratesio_library/Cargo.toml b/examples/vendored/non_cratesio_library/Cargo.toml index b9f4aec5b..985606424 100644 --- a/examples/vendored/non_cratesio_library/Cargo.toml +++ b/examples/vendored/non_cratesio_library/Cargo.toml @@ -18,10 +18,17 @@ path = "src/main.rs" [package.metadata.raze] workspace_path = "//vendored/non_cratesio_library/cargo" -target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", +] gen_workspace_prefix = "vendored_non_cratesio_library" genmode = "Vendored" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.log.'0.4.11'] additional_flags = [ diff --git a/examples/vendored/non_cratesio_library/cargo/vendor/atty-0.2.14/BUILD.bazel b/examples/vendored/non_cratesio_library/cargo/vendor/atty-0.2.14/BUILD.bazel index 87caa3eb6..377d4d305 100644 --- a/examples/vendored/non_cratesio_library/cargo/vendor/atty-0.2.14/BUILD.bazel +++ b/examples/vendored/non_cratesio_library/cargo/vendor/atty-0.2.14/BUILD.bazel @@ -57,24 +57,20 @@ rust_library( # cfg(unix) ( "@io_bazel_rules_rust//rust/platform:aarch64-apple-darwin", - "@io_bazel_rules_rust//rust/platform:aarch64-apple-ios", - "@io_bazel_rules_rust//rust/platform:aarch64-linux-android", "@io_bazel_rules_rust//rust/platform:aarch64-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:arm-unknown-linux-gnueabi", - "@io_bazel_rules_rust//rust/platform:i686-apple-darwin", - "@io_bazel_rules_rust//rust/platform:i686-linux-android", - "@io_bazel_rules_rust//rust/platform:i686-unknown-freebsd", - "@io_bazel_rules_rust//rust/platform:i686-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:powerpc-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:s390x-unknown-linux-gnu", "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin", - "@io_bazel_rules_rust//rust/platform:x86_64-apple-ios", - "@io_bazel_rules_rust//rust/platform:x86_64-linux-android", - "@io_bazel_rules_rust//rust/platform:x86_64-unknown-freebsd", "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu", ): [ "//vendored/non_cratesio_library/cargo/vendor/libc-0.2.77:libc", ], "//conditions:default": [], + }) + selects.with_or({ + # cfg(windows) + ( + "@io_bazel_rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "//vendored/non_cratesio_library/cargo/vendor/winapi-0.3.9:winapi", + ], + "//conditions:default": [], }), ) diff --git a/examples/vendored/non_cratesio_library/cargo/vendor/iovec-0.1.4/BUILD.bazel b/examples/vendored/non_cratesio_library/cargo/vendor/iovec-0.1.4/BUILD.bazel index afbf13fca..9f6cd1f54 100644 --- a/examples/vendored/non_cratesio_library/cargo/vendor/iovec-0.1.4/BUILD.bazel +++ b/examples/vendored/non_cratesio_library/cargo/vendor/iovec-0.1.4/BUILD.bazel @@ -55,20 +55,8 @@ rust_library( # cfg(unix) ( "@io_bazel_rules_rust//rust/platform:aarch64-apple-darwin", - "@io_bazel_rules_rust//rust/platform:aarch64-apple-ios", - "@io_bazel_rules_rust//rust/platform:aarch64-linux-android", "@io_bazel_rules_rust//rust/platform:aarch64-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:arm-unknown-linux-gnueabi", - "@io_bazel_rules_rust//rust/platform:i686-apple-darwin", - "@io_bazel_rules_rust//rust/platform:i686-linux-android", - "@io_bazel_rules_rust//rust/platform:i686-unknown-freebsd", - "@io_bazel_rules_rust//rust/platform:i686-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:powerpc-unknown-linux-gnu", - "@io_bazel_rules_rust//rust/platform:s390x-unknown-linux-gnu", "@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin", - "@io_bazel_rules_rust//rust/platform:x86_64-apple-ios", - "@io_bazel_rules_rust//rust/platform:x86_64-linux-android", - "@io_bazel_rules_rust//rust/platform:x86_64-unknown-freebsd", "@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu", ): [ "//vendored/non_cratesio_library/cargo/vendor/libc-0.2.77:libc", diff --git a/examples/vendored/non_cratesio_library/cargo/vendor/termcolor-0.3.6/BUILD.bazel b/examples/vendored/non_cratesio_library/cargo/vendor/termcolor-0.3.6/BUILD.bazel index 9ba598275..381699296 100644 --- a/examples/vendored/non_cratesio_library/cargo/vendor/termcolor-0.3.6/BUILD.bazel +++ b/examples/vendored/non_cratesio_library/cargo/vendor/termcolor-0.3.6/BUILD.bazel @@ -33,6 +33,8 @@ licenses([ rust_library( name = "termcolor", srcs = glob(["**/*.rs"]), + aliases = { + }, crate_features = [ ], crate_root = "src/lib.rs", @@ -49,5 +51,13 @@ rust_library( version = "0.3.6", # buildifier: leave-alone deps = [ - ], + ] + selects.with_or({ + # cfg(windows) + ( + "@io_bazel_rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "//vendored/non_cratesio_library/cargo/vendor/wincolor-0.1.6:wincolor", + ], + "//conditions:default": [], + }), ) diff --git a/impl/src/settings.rs b/impl/src/settings.rs index f3173f2a0..677a71a0d 100644 --- a/impl/src/settings.rs +++ b/impl/src/settings.rs @@ -531,6 +531,47 @@ impl RawRazeSettings { || self.rust_rules_workspace_name.is_some() || self.vendor_dir.is_some() } + + fn print_notices_and_warnings(&self) { + if self.default_gen_buildrs.is_none() { + eprintln!( + "NOTICE: The default of `[*.raze.default_gen_buildrs]` will soon be set to `true`. Please \ + explicitly set this flag to prevent a change in behavior." + ); + } + + if self.incompatible_relative_workspace_path.unwrap_or(false) { + eprintln!( + "WARNING: `[*.raze.incompatible_relative_workspace_path]` is deprecated. Please set \ + this flag to true and make sure `workspace_path` is the label where the Cargo-raze is \ + expected to write it's output." + ); + } + + if self.target.is_some() { + eprintln!( + "WARNING: `[*.raze.target]` is deprecated. Please update your project to use \ + `[*.raze.targets]`." + ); + } + + if self.rust_rules_workspace_name.is_none() { + eprintln!( + "WARNING: The default of `[*.raze.rust_rules_workspace_name]` will soon be set to \ + `\"rules_rust\"`. Please explicitly set this flag to prevent a change in behavior or \ + upgrade your code to use the latest version of `rules_rust` and change references of \ + `io_bazel_rules_rust` to `rules_rust` in your project." + ); + } + + if self.package_aliases_dir.is_none() { + eprintln!( + "WARNING: The default of `[*.raze.package_aliases_dir]` will soon be set to `\"cargo\"`. \ + Please explicitly set this flag to `\".\"` to prevent a change in behavior or update \ + your project structure to account for this change." + ); + } + } } /** Grows a list with duplicate keys between two maps */ @@ -560,6 +601,7 @@ fn parse_raze_settings_workspace( metadata_value: &serde_json::value::Value, metadata: &Metadata, ) -> Result { + RawRazeSettings::deserialize(metadata_value)?.print_notices_and_warnings(); let mut settings = RazeSettings::deserialize(metadata_value)?; let workspace_packages: Vec<&Package> = metadata @@ -626,6 +668,7 @@ fn parse_raze_settings_root_package( metadata_value: &serde_json::value::Value, root_package: &Package, ) -> Result { + RawRazeSettings::deserialize(metadata_value)?.print_notices_and_warnings(); return RazeSettings::deserialize(metadata_value).with_context(|| { format!( "Failed to load raze settings from root package: {}", @@ -660,6 +703,7 @@ fn parse_raze_settings_any_package(metadata: &Metadata) -> Result // UNWRAP: Safe due to checks above let settings_value = settings_packages[0].metadata.get("raze").unwrap(); + RawRazeSettings::deserialize(settings_value)?.print_notices_and_warnings(); RazeSettings::deserialize(settings_value) .with_context(|| format!("Failed to deserialize raze settings: {:?}", settings_value)) } diff --git a/smoke_test/remote/complicated_cargo_library/Cargo.toml b/smoke_test/remote/complicated_cargo_library/Cargo.toml index 6a64b7763..4f4617667 100644 --- a/smoke_test/remote/complicated_cargo_library/Cargo.toml +++ b/smoke_test/remote/complicated_cargo_library/Cargo.toml @@ -19,6 +19,7 @@ workspace_path = "//remote/complicated_cargo_library/cargo" gen_workspace_prefix = "remote_complicated_cargo_library" genmode = "Remote" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.proc-macro2.'0.4.30'] additional_flags = [ diff --git a/smoke_test/remote/no_deps/Cargo.toml b/smoke_test/remote/no_deps/Cargo.toml index fe020873a..278456cc4 100644 --- a/smoke_test/remote/no_deps/Cargo.toml +++ b/smoke_test/remote/no_deps/Cargo.toml @@ -12,3 +12,4 @@ workspace_path = "//remote/no_deps/cargo" genmode = "Remote" gen_workspace_prefix = "remote_no_deps" package_aliases_dir = "cargo" +default_gen_buildrs = true diff --git a/smoke_test/remote/non_cratesio/Cargo.toml b/smoke_test/remote/non_cratesio/Cargo.toml index 74f96d48f..3f82dedd1 100644 --- a/smoke_test/remote/non_cratesio/Cargo.toml +++ b/smoke_test/remote/non_cratesio/Cargo.toml @@ -17,10 +17,17 @@ path = "src/main.rs" [package.metadata.raze] workspace_path = "//remote/non_cratesio/cargo" -target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", +] genmode = "Remote" gen_workspace_prefix = "remote_non_cratesio" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.log.'0.4.11'] additional_flags = [ diff --git a/smoke_test/vendored/complicated_cargo_library/Cargo.toml b/smoke_test/vendored/complicated_cargo_library/Cargo.toml index 652c625e9..eb0b1a786 100644 --- a/smoke_test/vendored/complicated_cargo_library/Cargo.toml +++ b/smoke_test/vendored/complicated_cargo_library/Cargo.toml @@ -17,6 +17,7 @@ workspace_path = "//vendored/complicated_cargo_library/cargo" gen_workspace_prefix = "vendored_complicated_cargo_library" genmode = "Vendored" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.proc-macro2.'0.4.30'] additional_flags = [ diff --git a/smoke_test/vendored/hello_cargo_library/Cargo.toml b/smoke_test/vendored/hello_cargo_library/Cargo.toml index 4966e3a1d..9d41dab2d 100644 --- a/smoke_test/vendored/hello_cargo_library/Cargo.toml +++ b/smoke_test/vendored/hello_cargo_library/Cargo.toml @@ -13,8 +13,15 @@ path = "src/main.rs" [package.metadata.raze] workspace_path = "//vendored/hello_cargo_library/cargo" -target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", +] output_buildfile_suffix = "BUILD.bazel" gen_workspace_prefix = "vendored_hello_cargo_library" genmode = "Vendored" package_aliases_dir = "cargo" +default_gen_buildrs = false diff --git a/smoke_test/vendored/non_cratesio_library/Cargo.toml b/smoke_test/vendored/non_cratesio_library/Cargo.toml index b9f4aec5b..985606424 100644 --- a/smoke_test/vendored/non_cratesio_library/Cargo.toml +++ b/smoke_test/vendored/non_cratesio_library/Cargo.toml @@ -18,10 +18,17 @@ path = "src/main.rs" [package.metadata.raze] workspace_path = "//vendored/non_cratesio_library/cargo" -target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", +] gen_workspace_prefix = "vendored_non_cratesio_library" genmode = "Vendored" package_aliases_dir = "cargo" +default_gen_buildrs = false [package.metadata.raze.crates.log.'0.4.11'] additional_flags = [