Skip to content

Commit

Permalink
generate protobuf in OUT_DIR
Browse files Browse the repository at this point in the history
We should not create build time generated files under src/, with the
latest rust version this seems to cause problems on cargo publish.

Instead just default to the OUT_DIR env that is always set by cargo.

Fixes #1137

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
  • Loading branch information
Luap99 committed Dec 13, 2024
1 parent 7a5e830 commit 6217c49
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ targets/
netavark.1
vendor/
.idea/*
src/proto-build/netavark_proxy.rs
contrib/systemd/*/*.service
.vscode*
5 changes: 2 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chrono::{DateTime, Utc};
use std::env;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::process::Command;

fn main() {
Expand Down Expand Up @@ -32,8 +32,7 @@ fn main() {
.type_attribute(
"netavark_proxy.NetworkConfig",
"#[derive(serde::Serialize)]",
)
.out_dir(PathBuf::from("src/proto-build"));
);

builder
.compile_protos(&[Path::new("src/proto/proxy.proto")], &[Path::new("proto")])
Expand Down
2 changes: 1 addition & 1 deletion src/dhcp_proxy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tower::service_fn;

#[allow(clippy::unwrap_used)]
pub mod g_rpc {
include!("../proto-build/netavark_proxy.rs");
include!(concat!(env!("OUT_DIR"), "/netavark_proxy.rs"));
use crate::dhcp_proxy::lib::VectorConv;
use crate::dhcp_proxy::types::{CustomErr, ProxyError};
use mozim::DhcpV4Lease;
Expand Down
Empty file removed src/proto-build/.proto-build
Empty file.

0 comments on commit 6217c49

Please sign in to comment.