From 842b0a3e6a47a5392196ab4253579076f83b1a5a Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Sun, 6 Aug 2023 17:50:00 -0500 Subject: [PATCH] cli: 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 | 2 + cli/BUCK | 93 ++++++++++++++++++++++++++++++++++++++ cli/src/template_parser.rs | 6 +++ 3 files changed, 101 insertions(+) create mode 100644 cli/BUCK diff --git a/BUCK b/BUCK index 1f28a9478b..9d1827312f 100644 --- a/BUCK +++ b/BUCK @@ -3,6 +3,8 @@ alias(name = name, actual = actual) for (name, actual) in [ # (top-level name, fully-qualified target name) + ("jj", "//cli:jj"), + ("jj-cli", "//cli:cli"), ("jj-lib", "//lib:lib"), ("gen-protos", "//lib/gen-protos:gen-protos"), ("proc-macros", "//lib/proc-macros:proc-macros"), diff --git a/cli/BUCK b/cli/BUCK new file mode 100644 index 0000000000..3cea23842b --- /dev/null +++ b/cli/BUCK @@ -0,0 +1,93 @@ + +load("//buck/shims/jj.bzl", "jj") + +alias( + # NOTE: default target for this package + name = 'cli', + actual = ':jj', + visibility = [ 'PUBLIC' ], +) + +jj.rust_binary( + name = 'jj', + srcs = ['src/main.rs'], + visibility = [ "PUBLIC" ], + features = [ + "watchman", + "git", + ], + linker_flags = [ '-lstdc++' ], # XXX FIXME (aseipp): should be implied by `bssl` + deps = [ + ":jj-cli", + ], +) + +jj.rust_library( + name = "jj-cli", + srcs = glob([ + "src/**/*.rs", + "src/**/*.toml", + "src/**/*.json", + "src/**/*.pest", + ], exclude = [ + "**/main.rs" + ]), + + visibility = [ "PUBLIC" ], + features = [ + "watchman", + ], + + deps = [ + # first-party dependencies + "//lib:jj-lib", + ] + [ + # third-party dependencies + "third-party//rust:chrono", + "third-party//rust:clap", + "third-party//rust:clap-markdown", + "third-party//rust:clap_complete", + "third-party//rust:clap_complete_nushell", + "third-party//rust:clap_mangen", + "third-party//rust:config", + "third-party//rust:criterion", + "third-party//rust:crossterm", + "third-party//rust:dirs", + "third-party//rust:esl01-renderdag", + "third-party//rust:futures", + "third-party//rust:git2", + "third-party//rust:gix", + "third-party//rust:hex", + "third-party//rust:indexmap", + "third-party//rust:itertools", + "third-party//rust:rayon", + "third-party//rust:maplit", + "third-party//rust:minus", + "third-party//rust:once_cell", + "third-party//rust:pest", + "third-party//rust:pest_derive", + "third-party//rust:pollster", + "third-party//rust:regex", + "third-party//rust:rpassword", + "third-party//rust:scm-record", + "third-party//rust:serde", + "third-party//rust:slab", + "third-party//rust:strsim", + "third-party//rust:tempfile", + "third-party//rust:textwrap", + "third-party//rust:thiserror", + "third-party//rust:timeago", + "third-party//rust:toml_edit", + "third-party//rust:tracing", + "third-party//rust:tracing-chrome", + "third-party//rust:tracing-subscriber", + "third-party//rust:unicode-width", + + # platform-specific dependencies + ] + select({ + "config//os:windows": [], + "DEFAULT": [ + "third-party//rust:libc", + ], + }) +) diff --git a/cli/src/template_parser.rs b/cli/src/template_parser.rs index 3bb2bb5114..ccbbd70c32 100644 --- a/cli/src/template_parser.rs +++ b/cli/src/template_parser.rs @@ -28,6 +28,12 @@ use pest::Parser; use pest_derive::Parser; use thiserror::Error; +#[cfg(buck_build)] +#[derive(Parser)] +#[grammar = "cli/src/template.pest"] +struct TemplateParser; + +#[cfg(not(buck_build))] #[derive(Parser)] #[grammar = "template.pest"] struct TemplateParser;