Skip to content

Commit

Permalink
cli: add BUILD files
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Austin Seipp <[email protected]>
  • Loading branch information
thoughtpolice committed Jun 25, 2024
1 parent ff8c768 commit 40dd167
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
90 changes: 90 additions & 0 deletions cli/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

load("//buck/shims/jj.bzl", "jj")

alias(
# NOTE: default target for this package
name = 'cli',
actual = ':jj',
)

ALL_DEPS = [
# CARGO-SYNC-START: dependencies
'//lib:jj-lib',
'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: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:rayon',
'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',
# CARGO-SYNC-END
] + select({
"config//os:windows": [],
"DEFAULT": [
# CARGO-SYNC-START: dependencies@cfg(unix)
'third-party//rust:libc',
# CARGO-SYNC-END
],
})

jj.rust_binary(
name = 'jj',
srcs = ['src/main.rs'],
features = [
"watchman",
"git",
],
linker_flags = [ '-lstdc++' ], # XXX FIXME (aseipp): should be implied by `bssl`
deps = [ ":jj-cli" ] + ALL_DEPS,
)

jj.rust_library(
name = "jj-cli",
srcs = glob([
"src/**/*.rs",
"src/**/*.toml",
"src/**/*.json",
"src/**/*.pest",
], exclude = [
"**/main.rs"
]),

features = [
"watchman",
"git",
],

deps = ALL_DEPS,
)
3 changes: 3 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ include = [
"/tests/[email protected]"
]

[lints]
workspace = true

[[bin]]
name = "jj"
path = "src/main.rs"
Expand Down
4 changes: 4 additions & 0 deletions cli/PACKAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

package(
visibility = [ 'PUBLIC' ],
)
6 changes: 6 additions & 0 deletions cli/src/template_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 40dd167

Please sign in to comment.