From 7ffd4e9e2ddd1af4bd69b5eec9c7974379f6f0b1 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Sun, 6 Aug 2023 17:50:00 -0500 Subject: [PATCH] lib: add BUCK files The `grammar` macro from `pest_derive` doesn't actually interpret the given file as relative in our case, so we have to give it the fully qualified relative path which exists in the `buck-out/` dir. --- BUCK | 1 + lib/BUCK | 87 +++++++++++++++++++++++++++++++++++++++ lib/src/fileset_parser.rs | 6 +++ lib/src/revset_parser.rs | 6 +++ 4 files changed, 100 insertions(+) create mode 100644 lib/BUCK diff --git a/BUCK b/BUCK index 2da90f1918..1f28a9478b 100644 --- a/BUCK +++ b/BUCK @@ -3,6 +3,7 @@ alias(name = name, actual = actual) for (name, actual) in [ # (top-level name, fully-qualified target name) + ("jj-lib", "//lib:lib"), ("gen-protos", "//lib/gen-protos:gen-protos"), ("proc-macros", "//lib/proc-macros:proc-macros"), ] diff --git a/lib/BUCK b/lib/BUCK new file mode 100644 index 0000000000..dfeb7c897d --- /dev/null +++ b/lib/BUCK @@ -0,0 +1,87 @@ + +load("//buck/shims/jj.bzl", "jj") + +alias( + # NOTE: default target for this package + name = 'lib', + actual = ':jj-lib', + visibility = [ 'PUBLIC' ], +) + +filegroup( + name = 'protos.pb', + srcs = glob(['src/protos/*.proto']), + visibility = [ '//lib/...' ], +) + +jj.rust_library( + name = "jj-lib", + srcs = glob([ + "src/**/*.pest", + "src/**/*.rs", + ], exclude = [ + "src/protos/*.rs" + ]), + mapped_srcs = { + "//lib/gen-protos:protos.rs": "src/protos", + }, + + visibility = [ "PUBLIC" ], + features = [ + "watchman", + "git", + ], + deps = [ + # first-party dependencies + "//lib/proc-macros:jj-lib-proc-macros", + ] + [ + # third-party dependencies + "third-party//rust:async-trait", + "third-party//rust:backoff", + "third-party//rust:blake2", + "third-party//rust:bytes", + "third-party//rust:chrono", + "third-party//rust:config", + "third-party//rust:digest", + "third-party//rust:either", + "third-party//rust:futures", + "third-party//rust:git2", + "third-party//rust:gix", + "third-party//rust:glob", + "third-party//rust:hex", + "third-party//rust:ignore", + "third-party//rust:itertools", + "third-party//rust:maplit", + "third-party//rust:once_cell", + "third-party//rust:pest", + "third-party//rust:pest_derive", + "third-party//rust:pollster", + "third-party//rust:prost", + "third-party//rust:rand", + "third-party//rust:rand_chacha", + "third-party//rust:rayon", + "third-party//rust:ref-cast", + "third-party//rust:regex", + "third-party//rust:serde", + "third-party//rust:serde_json", + "third-party//rust:smallvec", + "third-party//rust:strsim", + "third-party//rust:tempfile", + "third-party//rust:thiserror", + "third-party//rust:tokio", + "third-party//rust:tracing", + "third-party//rust:watchman_client", + "third-party//rust:whoami", + "third-party//rust:zstd", + + # platform-specific dependencies + ] + select({ + "config//os:windows": [ + "third-party//rust:winreg", + ], + "config//os:linux": [ + "third-party//rust:rustix", + ], + "DEFAULT": [], + }) +) diff --git a/lib/src/fileset_parser.rs b/lib/src/fileset_parser.rs index 7b0a30aada..39e9c09cc2 100644 --- a/lib/src/fileset_parser.rs +++ b/lib/src/fileset_parser.rs @@ -26,6 +26,12 @@ use thiserror::Error; use crate::dsl_util::{self, InvalidArguments, StringLiteralParser}; +#[cfg(buck_build)] +#[derive(Parser)] +#[grammar = "lib/src/fileset.pest"] +struct FilesetParser; + +#[cfg(not(buck_build))] #[derive(Parser)] #[grammar = "fileset.pest"] struct FilesetParser; diff --git a/lib/src/revset_parser.rs b/lib/src/revset_parser.rs index d8c439819f..7404b0ad29 100644 --- a/lib/src/revset_parser.rs +++ b/lib/src/revset_parser.rs @@ -32,6 +32,12 @@ use crate::dsl_util::{ FoldableExpression, InvalidArguments, KeywordArgument, StringLiteralParser, }; +#[cfg(buck_build)] +#[derive(Parser)] +#[grammar = "lib/src/revset.pest"] +struct RevsetParser; + +#[cfg(not(buck_build))] #[derive(Parser)] #[grammar = "revset.pest"] struct RevsetParser;