Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build mono with buck2 #881

Merged
merged 16 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions ceres/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
rust_library (
name = "ceres",
srcs = glob(["src/**/*.rs"]),
crate_root = "src/lib.rs",
deps = [
"//jupiter/callisto:callisto",
"//common:common",
"//mercury:mercury",
"//jupiter:jupiter",
"//third-party:anyhow",
"//third-party:tokio",
"//third-party:tokio-stream",
"//third-party:axum",
"//third-party:tracing",
"//third-party:serde",
"//third-party:serde_json",
"//third-party:clap",
"//third-party:chrono",
"//third-party:futures",
"//third-party:bytes",
"//third-party:async-trait",
"//third-party:rand",
"//third-party:sea-orm",
"//third-party:ring",
"//third-party:hex",
"//third-party:sysinfo",
],
visibility = [
'PUBLIC',
],
)
3 changes: 2 additions & 1 deletion ceres/src/lfs/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ pub async fn lfs_upload_object(
/// when server enable split, if OID is a complete object, then splice the object and return it.
pub async fn lfs_download_object(
context: Context,
oid: &String,
oid: String,
) -> Result<impl Stream<Item = Result<Bytes, GitLFSError>>, GitLFSError> {
let oid = &oid;
let config = context.config.lfs;
let stg = context.services.lfs_db_storage.clone();
let lfs_storage = context.services.lfs_storage.clone();
Expand Down
30 changes: 30 additions & 0 deletions common/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
rust_library (
name = "common",
srcs = [
"src/lib.rs",
"src/config.rs",
"src/enums.rs",
"src/errors.rs",
"src/model.rs",
"src/utils.rs",
"config.toml",
],
crate_root = "src/lib.rs",
deps = [
"//third-party:axum",
"//third-party:anyhow",
"//third-party:sea-orm",
"//third-party:thiserror",
"//third-party:clap",
"//third-party:idgenerator",
"//third-party:serde",
"//third-party:config",
"//third-party:envsubst",
"//third-party:rand",
"//third-party:serde_json",
"//third-party:regex",
],
visibility = [
'PUBLIC',
],
)
1 change: 1 addition & 0 deletions common/config.toml
2 changes: 1 addition & 1 deletion common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Default for Config {
std::fs::create_dir_all(&base_dir).unwrap();

// use mega/config.toml because mega use sqlite as default db
let default_config = include_str!("../../mega/config.toml");
let default_config = include_str!("../config.toml");
let default_config = default_config
.lines()
.map(|line| {
Expand Down
25 changes: 25 additions & 0 deletions jupiter/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
rust_library (
name = "jupiter",
srcs = glob(["src/**/*.rs", "sqlite_20241204_init.sql"]), # soft link must be file, not directory, for buck2 reason
crate_root = "src/lib.rs",
deps = [
"//jupiter/callisto:callisto",
"//common:common",
"//mercury:mercury",
"//saturn:saturn",
"//third-party:sea-orm",
"//third-party:tracing",
"//third-party:bytes",
"//third-party:chrono",
"//third-party:async-trait",
"//third-party:futures",
"//third-party:serde_json",
"//third-party:idgenerator",
"//third-party:serde",
"//third-party:tokio",
"//third-party:uuid",
],
visibility = [
'PUBLIC',
],
)
12 changes: 12 additions & 0 deletions jupiter/callisto/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
rust_library (
name = "callisto",
srcs = glob(["src/**/*.rs"]),
crate_root = "src/lib.rs",
deps = [
"//third-party:serde",
"//third-party:sea-orm",
],
visibility = [
'PUBLIC',
],
)
1 change: 1 addition & 0 deletions jupiter/sqlite_20241204_init.sql
5 changes: 2 additions & 3 deletions jupiter/src/storage/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ async fn setup_sql(conn: &DatabaseConnection) -> Result<(), TransactionError<DbE
let backend = txn.get_database_backend();

// `include_str!` will expand the file while compiling, so `.sql` is not needed after that
const SETUP_SQL: &str = include_str!("../../../sql/sqlite/sqlite_20241204_init.sql");
txn.execute(Statement::from_string(backend, SETUP_SQL))
.await?;
const SETUP_SQL: &str = include_str!("../../sqlite_20241204_init.sql");
txn.execute(Statement::from_string(backend, SETUP_SQL)).await?;
Ok(())
})
})
Expand Down
38 changes: 38 additions & 0 deletions mercury/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
rust_library (
name = "mercury",
srcs = glob(["src/**/*.rs"]),
crate_root = "src/lib.rs",
deps = [
"//mercury/delta:delta",
"//common:common",
"//jupiter/callisto:callisto",
"//third-party:flate2",
"//third-party:serde",
"//third-party:bstr",
"//third-party:hex",
"//third-party:thiserror",
"//third-party:tracing",
"//third-party:sha1",
"//third-party:colored",
"//third-party:chrono",
"//third-party:tracing-subscriber",
"//third-party:uuid",
"//third-party:threadpool",
"//third-party:num_cpus",
"//third-party:dashmap",
"//third-party:tokio",
"//third-party:lru-mem",
"//third-party:bincode",
"//third-party:byteorder",
"//third-party:futures-util",
"//third-party:bytes",
"//third-party:axum",
"//third-party:memchr",
"//third-party:encoding_rs",
"//third-party:rayon",
"//third-party:tokio-util",
],
visibility = [
'PUBLIC',
],
)
14 changes: 14 additions & 0 deletions mercury/delta/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rust_library (
name = "delta",
srcs = glob(["src/**/*.rs"]),
crate_root = "src/lib.rs",
features = ["diff_mydrs"],
deps = [
"//third-party:diffs",
"//third-party:thiserror",
"//third-party:flate2",
],
visibility = [
'PUBLIC',
],
)
65 changes: 63 additions & 2 deletions mono/BUCK
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
rust_binary(
load("@prelude//rust:cargo_package.bzl", "cargo")

cargo.rust_binary(
name = "mono",
srcs = glob(["src/**/*.rs"]),
crate_root = "src/main.rs",
)
deps = [
"//jupiter/callisto:callisto",
"//common:common",
"//jupiter:jupiter",
"//ceres:ceres",
"//taurus:taurus",
"//saturn:saturn",
"//vault:vault",
"//third-party:anyhow",
"//third-party:axum",
"//third-party:axum-server",
"//third-party:tower",
"//third-party:tracing",
"//third-party:tracing-subscriber",
"//third-party:tracing-appender",
"//third-party:russh",
"//third-party:serde",
"//third-party:serde_json",
"//third-party:chrono",
"//third-party:futures",
"//third-party:bytes",
"//third-party:clap",
"//third-party:tower-http",
"//third-party:axum-extra",
"//third-party:tokio",
"//third-party:tokio-stream",
"//third-party:async-stream",
"//third-party:reqwest",
"//third-party:uuid",
"//third-party:regex",
"//third-party:ed25519-dalek",
"//third-party:lazy_static",
"//third-party:ctrlc",
"//third-party:shadow-rs",
"//third-party:oauth2",
"//third-party:base64",
"//third-party:async-session",
"//third-party:http",
"//third-party:cedar-policy",
"//third-party:jemallocator"
],
platform = {
"linux": dict(deps = ["//third-party:jemallocator"]),
"macos": dict(deps = ["//third-party:jemallocator"]),
"windows": dict(deps = ["//third-party:mimalloc"]),
},
env = {
"CARGO_MANIFEST_DIR": ".",
"CARGO_PKG_AUTHORS": "Quanyi Ma <[email protected]>",
"CARGO_PKG_DESCRIPTION": "Mega-mono",
"CARGO_PKG_NAME": "mono",
"CARGO_PKG_VERSION": "0.1.0",
"CARGO_PKG_VERSION_MAJOR": "0",
"CARGO_PKG_VERSION_MINOR": "1",
"CARGO_PKG_VERSION_PATCH": "0",
},
visibility = [
"PUBLIC",
],
)
5 changes: 2 additions & 3 deletions mono/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ authors = ["Quanyi Ma <[email protected]>"]
keywords = ["git", "monorepo", "decentralized"]
license = "MIT OR Apache-2.0"
readme = "README.md"
build = "src/build.rs"

[[bin]]
name = "mono"
Expand Down Expand Up @@ -50,7 +49,7 @@ regex = { workspace = true }
ed25519-dalek = { workspace = true, features = ["pkcs8"] }
lazy_static = { workspace = true }
ctrlc = { workspace = true }
shadow-rs = { workspace = true }
# shadow-rs = { workspace = true }
oauth2 = { workspace = true }
base64 = { workspace = true }
async-session = "3.0.0"
Expand All @@ -66,7 +65,7 @@ mimalloc = "0.1.43"
[dev-dependencies]

[build-dependencies]
shadow-rs = { workspace = true }
# shadow-rs = { workspace = true }

# [target.'cfg(not(target_env = "msvc"))'.dependencies]
# tikv-jemallocator = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion mono/src/api/lfs/lfs_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ pub async fn lfs_download_object(
state: State<MonoApiServiceState>,
Path(oid): Path<String>,
) -> Result<Response, (StatusCode, String)> {
let result = handler::lfs_download_object(state.context.clone(), &oid).await;
let result = handler::lfs_download_object(state.context.clone(), oid.clone()).await;
match result {
Ok(byte_stream) => Ok(Response::builder()
.header("Content-Type", LFS_CONTENT_TYPE)
Expand Down
12 changes: 0 additions & 12 deletions mono/src/build.rs

This file was deleted.

10 changes: 0 additions & 10 deletions mono/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//!
//! And this is the main entry point for the application.

use shadow_rs::shadow;
shadow!(build);

mod cli;
mod commands;
Expand All @@ -28,13 +26,5 @@ fn main() {
// If there was an error, print it
if let Err(e) = result {
e.print();
eprintln!("Version:{}", build::VERSION);
eprintln!("Version:{}", build::CLAP_LONG_VERSION);
eprintln!("Version:{}", build::PKG_VERSION);
eprintln!("OS:{}", build::BUILD_OS);
eprintln!("Rust Version:{}", build::RUST_VERSION);
eprintln!("Rust Channel:{}", build::RUST_CHANNEL);
eprintln!("Cargo Version:{}", build::CARGO_VERSION);
eprintln!("Build Time:{}", build::BUILD_TIME);
}
}
17 changes: 17 additions & 0 deletions saturn/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rust_library (
name = "saturn",
srcs = glob(["src/**/*.rs", "mega_policies.cedar", "mega.cedarschema"]),
crate_root = "src/lib.rs",
deps = [
"//third-party:serde",
"//third-party:serde_json",
"//third-party:tracing",
"//third-party:tracing-subscriber",
"//third-party:thiserror",
"//third-party:cedar-policy",
"//third-party:itertools",
],
visibility = [
'PUBLIC',
],
)
23 changes: 23 additions & 0 deletions taurus/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
rust_library (
name = "taurus",
srcs = glob(["src/**/*.rs"]),
crate_root = "src/lib.rs",
deps = [
"//jupiter/callisto:callisto",
"//common:common",
"//jupiter:jupiter",
"//third-party:axum",
"//third-party:async-trait",
"//third-party:tokio",
"//third-party:tracing",
"//third-party:thiserror",
"//third-party:serde",
"//third-party:serde_json",
"//third-party:chrono",
"//third-party:crossbeam-channel",

],
visibility = [
'PUBLIC',
],
)
Loading
Loading