Skip to content

Commit

Permalink
Add bazel rules
Browse files Browse the repository at this point in the history
  • Loading branch information
TzahiTaub committed Mar 17, 2024
1 parent 033efdb commit 8541a43
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Empty file added BUILD
Empty file.
Empty file added WORKSPACE
Empty file.
12 changes: 12 additions & 0 deletions crates/committer/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"]),
edition = "2021",
proc_macro_deps = all_crate_deps(proc_macro = True),
visibility = ["//visibility:public"],
deps = all_crate_deps(),
)
22 changes: 22 additions & 0 deletions crates/committer/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::env;
use std::path::Path;

/// Gets a binary input and an output file from the command line.
/// Reads the input file, adds 1 to each byte, and writes the result to the output file.
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"
);
let mut bytes = std::fs::read(input_file_name).unwrap();

// Add 1 to each byte
for byte in &mut bytes {
*byte = byte.wrapping_add(1);
}
std::fs::write(output_file_name, bytes).expect("Failed to write output");
}

0 comments on commit 8541a43

Please sign in to comment.