From 717731dcb02897bedd6e68a4acbfd164dafb332d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 2 May 2023 15:10:36 -0700 Subject: Switch to buck2 prelude's cargo package macros --- third-party/BUCK | 100 ++++++++++++++++++++++++++++------ third-party/fixups/winapi/fixups.toml | 1 + third-party/reindeer.toml | 5 -- tools/buck/prelude | 2 +- tools/buck/third_party.bzl | 5 -- 5 files changed, 84 insertions(+), 29 deletions(-) create mode 100644 third-party/fixups/winapi/fixups.toml delete mode 100644 tools/buck/third_party.bzl diff --git a/third-party/BUCK b/third-party/BUCK index 29efee6e..945ad9b7 100644 --- a/third-party/BUCK +++ b/third-party/BUCK @@ -1,7 +1,7 @@ # @generated by `reindeer buckify` -load("//tools/buck:third_party.bzl", "third_party_rust_library") load("@prelude//rust:cargo_buildscript.bzl", "buildscript_run") +load("@prelude//rust:cargo_package.bzl", "cargo") http_archive( name = "bitflags-1.3.2.crate", @@ -11,7 +11,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "bitflags-1.3.2", srcs = [":bitflags-1.3.2.crate"], crate = "bitflags", @@ -36,7 +36,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "cc-1.0.79", srcs = [":cc-1.0.79.crate"], crate = "cc", @@ -60,7 +60,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "clap-4.1.13", srcs = [":clap-4.1.13.crate"], crate = "clap", @@ -88,7 +88,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "clap_lex-0.3.3", srcs = [":clap_lex-0.3.3.crate"], crate = "clap_lex", @@ -113,7 +113,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "codespan-reporting-0.11.1", srcs = [":codespan-reporting-0.11.1.crate"], crate = "codespan_reporting", @@ -141,7 +141,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "once_cell-1.17.1", srcs = [":once_cell-1.17.1.crate"], crate = "once_cell", @@ -165,7 +165,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "os_str_bytes-6.5.0", srcs = [":os_str_bytes-6.5.0.crate"], crate = "os_str_bytes", @@ -190,7 +190,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "proc-macro2-1.0.53", srcs = [":proc-macro2-1.0.53.crate"], crate = "proc_macro2", @@ -209,7 +209,7 @@ third_party_rust_library( deps = [":unicode-ident-1.0.8"], ) -rust_binary( +cargo.rust_binary( name = "proc-macro2-1.0.53-build-script-build", srcs = [":proc-macro2-1.0.53.crate"], crate = "build_script_build", @@ -250,7 +250,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "quote-1.0.26", srcs = [":quote-1.0.26.crate"], crate = "quote", @@ -268,7 +268,7 @@ third_party_rust_library( deps = [":proc-macro2-1.0.53"], ) -rust_binary( +cargo.rust_binary( name = "quote-1.0.26-build-script-build", srcs = [":quote-1.0.26.crate"], crate = "build_script_build", @@ -307,7 +307,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "scratch-1.0.5", srcs = [":scratch-1.0.5.crate"], crate = "scratch", @@ -320,7 +320,7 @@ third_party_rust_library( visibility = [], ) -rust_binary( +cargo.rust_binary( name = "scratch-1.0.5-build-script-build", srcs = [":scratch-1.0.5.crate"], crate = "build_script_build", @@ -351,7 +351,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "syn-2.0.10", srcs = [":syn-2.0.10.crate"], crate = "syn", @@ -384,12 +384,20 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "termcolor-1.2.0", srcs = [":termcolor-1.2.0.crate"], crate = "termcolor", crate_root = "termcolor-1.2.0.crate/src/lib.rs", edition = "2018", + platform = { + "windows-gnu": dict( + deps = [":winapi-util-0.1.5"], + ), + "windows-msvc": dict( + deps = [":winapi-util-0.1.5"], + ), + }, rustc_flags = ["--cap-lints=allow"], visibility = [], ) @@ -402,7 +410,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "unicode-ident-1.0.8", srcs = [":unicode-ident-1.0.8.crate"], crate = "unicode_ident", @@ -420,7 +428,7 @@ http_archive( visibility = [], ) -third_party_rust_library( +cargo.rust_library( name = "unicode-width-0.1.10", srcs = [":unicode-width-0.1.10.crate"], crate = "unicode_width", @@ -430,3 +438,59 @@ third_party_rust_library( rustc_flags = ["--cap-lints=allow"], visibility = [], ) + +http_archive( + name = "winapi-0.3.9.crate", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + strip_prefix = "winapi-0.3.9", + urls = ["https://crates.io/api/v1/crates/winapi/0.3.9/download"], + visibility = [], +) + +cargo.rust_library( + name = "winapi-0.3.9", + srcs = [":winapi-0.3.9.crate"], + crate = "winapi", + crate_root = "winapi-0.3.9.crate/src/lib.rs", + edition = "2015", + features = [ + "consoleapi", + "errhandlingapi", + "fileapi", + "minwindef", + "processenv", + "std", + "winbase", + "wincon", + "winerror", + "winnt", + ], + rustc_flags = ["--cap-lints=allow"], + visibility = [], +) + +http_archive( + name = "winapi-util-0.1.5.crate", + sha256 = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178", + strip_prefix = "winapi-util-0.1.5", + urls = ["https://crates.io/api/v1/crates/winapi-util/0.1.5/download"], + visibility = [], +) + +cargo.rust_library( + name = "winapi-util-0.1.5", + srcs = [":winapi-util-0.1.5.crate"], + crate = "winapi_util", + crate_root = "winapi-util-0.1.5.crate/src/lib.rs", + edition = "2018", + platform = { + "windows-gnu": dict( + deps = [":winapi-0.3.9"], + ), + "windows-msvc": dict( + deps = [":winapi-0.3.9"], + ), + }, + rustc_flags = ["--cap-lints=allow"], + visibility = [], +) diff --git a/third-party/fixups/winapi/fixups.toml b/third-party/fixups/winapi/fixups.toml new file mode 100644 index 00000000..db40d72c --- /dev/null +++ b/third-party/fixups/winapi/fixups.toml @@ -0,0 +1 @@ +buildscript = [] diff --git a/third-party/reindeer.toml b/third-party/reindeer.toml index 1f9fef51..8415d647 100644 --- a/third-party/reindeer.toml +++ b/third-party/reindeer.toml @@ -5,8 +5,3 @@ vendor = false generated_file_header = """ # \u0040generated by `reindeer buckify` """ -buckfile_imports = """ -load("//tools/buck:third_party.bzl", "third_party_rust_library") -load("@prelude//rust:cargo_buildscript.bzl", "buildscript_run") -""" -rust_library = "third_party_rust_library" diff --git a/tools/buck/prelude b/tools/buck/prelude index 8c6024dc..b21e3586 160000 --- a/tools/buck/prelude +++ b/tools/buck/prelude @@ -1 +1 @@ -Subproject commit 8c6024dc786bab9ac15967cfefdd94c0b0a45eb7 +Subproject commit b21e3586138a9fe672da8ca3b18361d78d46d695 diff --git a/tools/buck/third_party.bzl b/tools/buck/third_party.bzl deleted file mode 100644 index 84e5ca8f..00000000 --- a/tools/buck/third_party.bzl +++ /dev/null @@ -1,5 +0,0 @@ -def third_party_rust_library(**kwargs): - native.rust_library( - doctests = False, - **kwargs - ) -- cgit v1.2.3