Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tinrab committed Nov 14, 2023
1 parent f0b6b21 commit ccce51f
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 24 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bomboni"
version = "0.1.3"
version = "0.1.4"
authors = ["Tin Rabzelj <tin@flinect.com>"]
description = "Utility Library for Rust"
repository = "https://github.com/tinrab/bomboni"
Expand Down Expand Up @@ -30,9 +30,9 @@ proto = ["prost", "dep:bomboni_proto"]
request = ["dep:bomboni_request"]

[dependencies]
bomboni_common = { path = "bomboni_common", version = "0.1.3" }
bomboni_derive = { path = "bomboni_derive", version = "0.1.3" }
bomboni_common = { path = "bomboni_common", version = "0.1.4" }
bomboni_derive = { path = "bomboni_derive", version = "0.1.4" }

bomboni_prost = { path = "bomboni_prost", version = "0.1.3", optional = true }
bomboni_proto = { path = "bomboni_proto", version = "0.1.3", optional = true }
bomboni_request = { path = "bomboni_request", version = "0.1.3", optional = true }
bomboni_prost = { path = "bomboni_prost", version = "0.1.4", optional = true }
bomboni_proto = { path = "bomboni_proto", version = "0.1.4", optional = true }
bomboni_request = { path = "bomboni_request", version = "0.1.4", optional = true }
2 changes: 1 addition & 1 deletion bomboni_common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bomboni_common"
version = "0.1.3"
version = "0.1.4"
authors = ["Tin Rabzelj <tin@flinect.com>"]
description = "Common things for Bomboni library."
repository = "https://github.com/tinrab/bomboni"
Expand Down
2 changes: 1 addition & 1 deletion bomboni_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bomboni_derive"
version = "0.1.3"
version = "0.1.4"
authors = ["Tin Rabzelj <tin@flinect.com>"]
description = "Provides derive implementations for Bomboni library."
repository = "https://github.com/tinrab/bomboni"
Expand Down
2 changes: 1 addition & 1 deletion bomboni_prost/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bomboni_prost"
version = "0.1.3"
version = "0.1.4"
authors = ["Tin Rabzelj <tin@flinect.com>"]
description = "Utilities for working with prost. Part of Bomboni library."
repository = "https://github.com/tinrab/bomboni"
Expand Down
4 changes: 2 additions & 2 deletions bomboni_prost/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pub struct ApiConfig {
impl Default for CompileConfig {
fn default() -> Self {
Self {
file_descriptor_set_path: PathBuf::from(std::env::var("OUT_DIR").unwrap())
file_descriptor_set_path: PathBuf::from(std::env::var_os("OUT_DIR").unwrap())
.join("fd.pb"),
output_path: std::env::var("OUT_DIR").unwrap().into(),
output_path: std::env::var_os("OUT_DIR").unwrap().into(),
format: true,
api: Default::default(),
}
Expand Down
17 changes: 12 additions & 5 deletions bomboni_prost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ mod utility;

pub fn compile(config: CompileConfig) -> Result<(), Box<dyn Error>> {
let mut buf = Vec::new();
File::open(&config.file_descriptor_set_path)?.read_to_end(&mut buf)?;
File::open(&config.file_descriptor_set_path)
.map_err(|err| {
format!(
"failed to open file descriptor set at `{}`: {}",
config.file_descriptor_set_path.display(),
err
)
})?
.read_to_end(&mut buf)?;
let descriptor = FileDescriptorSet::decode(buf.as_slice())?;

let flush = |package: &str, content: TokenStream| {
let output_path = config.output_path.join(format!("{}.plus.rs", package));
let flush = |package: &str, content: TokenStream| -> Result<(), Box<dyn Error>> {
let output_path = config.output_path.join(format!("./{}.plus.rs", package));
println!(
"writing package `{}` to file `{}`",
package,
output_path.display()
);
// let mut output_file = File::create(output_path)?;
let mut output_file = OpenOptions::new()
.write(true)
.append(true)
Expand All @@ -45,7 +52,7 @@ pub fn compile(config: CompileConfig) -> Result<(), Box<dyn Error>> {
} else {
output_file.write_all(content.to_string().as_bytes())?;
}
Result::<(), Box<dyn Error>>::Ok(())
Ok(())
};

// Clear files
Expand Down
4 changes: 2 additions & 2 deletions bomboni_proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bomboni_proto"
version = "0.1.3"
version = "0.1.4"
authors = ["Tin Rabzelj <tin@flinect.com>"]
description = "Utilities for working with Protobuf/gRPC. Part of Bomboni library."
repository = "https://github.com/tinrab/bomboni"
Expand Down Expand Up @@ -28,5 +28,5 @@ pot = "3.0.0"
serde_json = "1.0.108"

[build-dependencies]
bomboni_prost = { path = "../bomboni_prost", version = "0.1.3" }
bomboni_prost = { path = "../bomboni_prost", version = "0.1.4" }
prost-build = "0.12.1"
9 changes: 7 additions & 2 deletions bomboni_proto/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::{error::Error, path::PathBuf};
use std::{error::Error, io::Write, path::PathBuf};

use bomboni_prost::{
compile,
config::{ApiConfig, CompileConfig},
};

fn main() -> Result<(), Box<dyn Error + 'static>> {
let fd_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("fd.pb");
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
let fd_path = out_dir.join("fd.pb");

#[cfg(feature = "testing")]
{
Expand Down Expand Up @@ -80,11 +81,15 @@ fn main() -> Result<(), Box<dyn Error + 'static>> {
);

config.compile_protos(&proto_paths, &["./proto"])?;

std::io::stdout().flush().unwrap();

compile(CompileConfig {
api: ApiConfig {
domain: Some("type.googleapis.com".into()),
..Default::default()
},
file_descriptor_set_path: out_dir.join("fd.pb"),
..Default::default()
})?;

Expand Down
6 changes: 3 additions & 3 deletions bomboni_request/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bomboni_request"
version = "0.1.3"
version = "0.1.4"
authors = ["Tin Rabzelj <tin@flinect.com>"]
description = "Utilities for working with API requests. Part of Bomboni library."
repository = "https://github.com/tinrab/bomboni"
Expand All @@ -17,8 +17,8 @@ path = "src/lib.rs"
testing = []

[dependencies]
bomboni_common = { path = "../bomboni_common", version = "0.1.3" }
bomboni_derive = { path = "../bomboni_derive", version = "0.1.3" }
bomboni_common = { path = "../bomboni_common", version = "0.1.4" }
bomboni_derive = { path = "../bomboni_derive", version = "0.1.4" }
thiserror = "1.0.50"
itertools = "0.11.0"
chrono = "0.4.31"
Expand Down
20 changes: 19 additions & 1 deletion develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ function test() {
cargo test --doc --all-features -- --nocapture
}

function publish() {
if [[ $2 =~ ^(--actually-do-it)$ ]]; then
cargo publish -p bomboni_common
cargo publish -p bomboni_prost
cargo publish -p bomboni_proto
cargo publish -p bomboni_derive
cargo publish -p bomboni_request
cargo publish -p bomboni
else
cargo publish -p bomboni_common --dry-run --allow-dirty
cargo publish -p bomboni_prost --dry-run --allow-dirty
cargo publish -p bomboni_proto --dry-run --allow-dirty
cargo publish -p bomboni_derive --dry-run --allow-dirty
cargo publish -p bomboni_request --dry-run --allow-dirty
cargo publish -p bomboni --dry-run --allow-dirty
fi
}

function help() {
echo "Usage: $(basename "$0") [OPTIONS]
Expand All @@ -37,7 +55,7 @@ Commands:
"
}

if [[ $1 =~ ^(format|lint|test|help)$ ]]; then
if [[ $1 =~ ^(format|lint|test|publish|help)$ ]]; then
"$@"
else
help
Expand Down

0 comments on commit ccce51f

Please sign in to comment.