Skip to content

Commit

Permalink
buck: add some BUCK files for jj crates
Browse files Browse the repository at this point in the history
Summary: Now we can build the top-level with:

    $ buck2 build //:jj

From anywhere in the repository. `//...` will build all `jj-*` related code,
since all non-first-party code is separated into different cells.

Signed-off-by: Austin Seipp <[email protected]>
Change-Id: I93fa821894f9e13e061d0cf4f8030b3a
  • Loading branch information
thoughtpolice committed May 12, 2024
1 parent 80ebd71 commit 46d8715
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 0 deletions.
5 changes: 5 additions & 0 deletions BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

alias(
name = 'jj',
actual = "//cli:jj",
)
100 changes: 100 additions & 0 deletions cli/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

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

rust_binary(
name = 'jj',
srcs = ['src/main.rs'],
edition = "2021",
visibility = [ "PUBLIC" ],
rustc_flags = [
'--cfg=buck_build',
],
features = [
"watchman",
],
linker_flags = [ '-lstdc++' ], # XXX FIXME (aseipp): should be implied by `bssl`
env = {
'JJ_VERSION': '0.17.0',
},
deps = [
":jj-cli",
],
)

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

edition = "2021",
visibility = [ "PUBLIC" ],
rustc_flags = [
'--cfg=buck_build',
],
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: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",
],
})
)
88 changes: 88 additions & 0 deletions lib/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

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/...' ],
)

rust_library(
name = "jj-lib",
srcs = glob([
"src/**/*.pest",
"src/**/*.rs",
], exclude = [
"src/protos/*.rs"
]),
mapped_srcs = {
"//lib/gen-protos:protos.rs": "src/protos",
},

edition = "2021",
visibility = [ "PUBLIC" ],
rustc_flags = [
'--cfg=buck_build',
],
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": [],
})
)
21 changes: 21 additions & 0 deletions lib/gen-protos/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

rust_binary(
name = 'gen-protos',
srcs = ['src/main.rs'],
edition = "2021",
visibility = [ ],
rustc_flags = [
'--cfg=buck_build',
],
deps = [ 'third-party//rust:prost-build' ],
env = {
'CARGO_MANIFEST_DIR': '$(location //lib:protos.pb)',
},
)

genrule(
name = 'protos.rs',
cmd = "$(exe :gen-protos)",
out = ".",
visibility = [ '//lib/...' ],
)
23 changes: 23 additions & 0 deletions lib/proc-macros/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

alias(
# NOTE: default target for this package
name = 'proc-macros',
actual = ':jj-lib-proc-macros',
visibility = [ 'PUBLIC' ],
)

rust_library(
name = 'jj-lib-proc-macros',
srcs = glob(["src/**/*.rs"]),
edition = "2021",
visibility = [ "PUBLIC" ],
proc_macro = True,
rustc_flags = [
'--cfg=buck_build',
],
deps = [
'third-party//rust:proc-macro2',
'third-party//rust:quote',
'third-party//rust:syn',
]
)

0 comments on commit 46d8715

Please sign in to comment.