Skip to content

Commit

Permalink
Moved generated proto files into modules (#1919)
Browse files Browse the repository at this point in the history
Merge pull request #1919

Moved generated proto files into modules
  • Loading branch information
CjS77 committed May 28, 2020
2 parents 5a546d4 + f143e3a commit b1b8f09
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 26 deletions.
2 changes: 2 additions & 0 deletions base_layer/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/proto/generated/*.rs
!src/proto/generated/mod.rs
1 change: 1 addition & 0 deletions base_layer/core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

fn main() {
tari_common::protobuf_build::ProtoCompiler::new()
.out_dir("src/proto/generated")
.include_paths(&["src/transactions/proto", "src/proto"])
.proto_paths(&[
"src/mempool/proto",
Expand Down
7 changes: 1 addition & 6 deletions base_layer/core/src/base_node/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pub mod base_node {
include!(concat!(env!("OUT_DIR"), "/", "tari.base_node.rs"));
}
use crate::proto::core;
// Required for `super::types` used in generated files
use crate::transactions::proto::types;
pub use crate::proto::generated::base_node;

#[cfg(feature = "base_node")]
pub mod chain_metadata;
Expand Down
7 changes: 1 addition & 6 deletions base_layer/core/src/mempool/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Required for `super::types` used in generated files
use crate::transactions::proto::types;

pub mod mempool {
include!(concat!(env!("OUT_DIR"), "/", "tari.mempool.rs"));
}
pub use crate::proto::generated::mempool;

pub mod mempool_request;
pub mod mempool_response;
Expand Down
35 changes: 35 additions & 0 deletions base_layer/core/src/proto/generated/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020, The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

//! Imports of rust files generated from protos
#[cfg(feature = "base_node")]
#[path = "tari.base_node.rs"]
pub mod base_node;
#[path = "tari.core.rs"]
pub mod core;
#[path = "tari.mempool.rs"]
pub mod mempool;
#[path = "tari.transaction_protocol.rs"]
pub mod transaction_protocol;
#[path = "tari.types.rs"]
pub mod types;
8 changes: 2 additions & 6 deletions base_layer/core/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Required for `super::types` used in generated files
use crate::transactions::proto::types;

pub mod core {
include!(concat!(env!("OUT_DIR"), "/", "tari.core.rs"));
}
pub(crate) mod generated;
pub use generated::core;

#[cfg(feature = "base_node")]
mod block;
Expand Down
4 changes: 1 addition & 3 deletions base_layer/core/src/transactions/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pub mod types {
include!(concat!(env!("OUT_DIR"), "/", "tari.types.rs"));
}
pub use crate::proto::generated::types;

mod transaction;
mod types_impls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::transactions::proto::types;

pub mod protocol {
include!(concat!(env!("OUT_DIR"), "/", "tari.transaction_protocol.rs"));
}
pub use crate::proto::generated::transaction_protocol as protocol;

pub mod recipient_signed_message;
pub mod transaction_metadata;
Expand Down

0 comments on commit b1b8f09

Please sign in to comment.