Skip to content

Commit

Permalink
[lang] Add feature to control JSON api description generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed Mar 22, 2019
1 parent 930361f commit d2c6c74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ test-env = [
"pdsl_core/test-env",
"pdsl_model/test-env",
]
generate-api-description = []
12 changes: 11 additions & 1 deletion lang/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ pub fn contract(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
#[macro_use]
mod errors;

#[cfg(features = "generate-api-description")]
mod api;

mod ast;
mod gen;
mod hir;
Expand Down Expand Up @@ -61,7 +63,15 @@ pub(crate) fn contract_gen_impl2(
) -> Result<proc_macro2::TokenStream> {
let ast_contract = parser::parse_contract(input.clone())?;
let hir_contract = hir::Contract::from_ast(&ast_contract)?;
api::generate_api_description(&hir_contract);
generate_api_description(&hir_contract);
let tokens = gen::codegen(&hir_contract);
Ok(tokens.into())
}

#[cfg(features = "generate-api-description")]
fn generate_api_description(contract: &hir::Contract) {
api::generate_api_description(&hir_contract);
}

#[cfg(not(features = "generate-api-description"))]
fn generate_api_description(_contract: &hir::Contract) {}

0 comments on commit d2c6c74

Please sign in to comment.