Skip to content

Commit

Permalink
lib: add BUCK 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.
  • Loading branch information
thoughtpolice committed May 15, 2024
1 parent d817b93 commit 33f6e9c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
alias(name = name, actual = actual)
for (name, actual) in [
# (top-level name, fully-qualified target name)
("jj-lib", "//lib:lib"),
("proc-macros", "//lib/proc-macros:proc-macros"),
]
]
86 changes: 86 additions & 0 deletions lib/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

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",
],
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": [],
})
)
6 changes: 6 additions & 0 deletions lib/src/fileset_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ use thiserror::Error;

use crate::dsl_util::StringLiteralParser;

#[cfg(buck_build)]
#[derive(Parser)]
#[grammar = "lib/src/fileset.pest"]
struct FilesetParser;

#[cfg(not(buck_build))]
#[derive(Parser)]
#[grammar = "fileset.pest"]
struct FilesetParser;
Expand Down
6 changes: 6 additions & 0 deletions lib/src/revset_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ use crate::op_store::WorkspaceId;
// TODO: remove reverse dependency on revset module
use crate::revset::{ParseState, RevsetExpression, RevsetModifier};

#[cfg(buck_build)]
#[derive(Parser)]
#[grammar = "lib/src/revset.pest"]
struct RevsetParser;

#[cfg(not(buck_build))]
#[derive(Parser)]
#[grammar = "revset.pest"]
struct RevsetParser;
Expand Down

0 comments on commit 33f6e9c

Please sign in to comment.