Skip to content

Commit

Permalink
build: add bazel rules
Browse files Browse the repository at this point in the history
  • Loading branch information
TzahiTaub committed Mar 18, 2024
1 parent 033efdb commit 94821f2
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
Empty file added BUILD
Empty file.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2
resolver = "2"

members = ["crates/committer"]
members = ["crates/committer", "crates/committer_cli"]

[workspace.package]
version = "0.1.0-rc.0"
Expand Down
Empty file added WORKSPACE
Empty file.
12 changes: 12 additions & 0 deletions crates/committer_cli/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To be used together with a bazel WORKSPACE file that contains the following definitions.
load("@committer_crate//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_binary")

rust_binary(
name="committer_exe",
srcs=glob(["src/**/*.rs"]),
visibility=["//visibility:public"],
deps=all_crate_deps(),
proc_macro_deps=all_crate_deps(proc_macro=True),
edition="2021",
)
13 changes: 13 additions & 0 deletions crates/committer_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "committer_cli"
version.workspace = true
edition.workspace = true
repository.workspace = true
license-file.workspace = true
description = "Cli for the committer package."

[lints]
workspace = true

[dev-dependencies]
pretty_assertions.workspace = true
20 changes: 20 additions & 0 deletions crates/committer_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::env;
use std::path::Path;

/// Main entry point of the committer CLI.
fn main() {
// Open the input file.
let args: Vec<String> = env::args().collect();
let input_file_name = Path::new(&args[1]);
let output_file_name = Path::new(&args[2]);
assert!(
input_file_name.is_absolute() && output_file_name.is_absolute(),
"Given paths must be absolute"
);

// Business logic to be implemented here.
let output = std::fs::read(input_file_name).unwrap();

// Output to file.
std::fs::write(output_file_name, output).expect("Failed to write output");
}

0 comments on commit 94821f2

Please sign in to comment.