Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional compilation #1707

Merged
merged 28 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ examples-test:
script:
- for example in integration-tests/*/; do
if [ "$example" = "integration-tests/lang-err-integration-tests/" ]; then continue; fi;
if [ "$example" = "integration-tests/conditional-compilation/" ]; then
cargo test --verbose --manifest-path ${example}/Cargo.toml --features "foo";
cargo test --verbose --manifest-path ${example}/Cargo.toml --features "bar";
cargo test --verbose --manifest-path ${example}/Cargo.toml --features "foo, bar";
fi;
if grep -q "e2e-tests = \[\]" "${example}/Cargo.toml"; then
cargo test --verbose --manifest-path ${example}/Cargo.toml --features e2e-tests;
else
Expand All @@ -400,6 +405,17 @@ examples-contract-build:
- cargo contract -V
- for example in integration-tests/*/; do
if [ "$example" = "integration-tests/lang-err-integration-tests/" ]; then continue; fi;
if [ "$example" = "integration-tests/conditional-compilation/" ]; then
pushd $example &&
cargo +stable contract build --features "foo" &&
popd;
pushd $example &&
cargo +stable contract build --features "bar" &&
popd;
pushd $example &&
cargo +stable contract build --features "foo, bar" &&
SkymanOne marked this conversation as resolved.
Show resolved Hide resolved
popd;
fi;
pushd $example &&
cargo +stable contract build &&
popd;
Expand All @@ -421,7 +437,7 @@ examples-no-std-check:
- rustup component add rust-src --toolchain stable
- cargo contract -V
# We skip some examples for those reasons:
# There are no manifests in those two directories and hence it would fall back to the workspace.
# There are no manifests in those two directories and hence it would fall back to the workspace.
# - lang-err-integration-tests
# - upgradeable-contracts
# This uses dlmalloc which is only supported on select targets.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Basic support for `dyn Trait` to allow cross-contract calls only with trait - [#1673](https://github.com/paritytech/ink/pull/1673)
- E2E: auto detect contracts to be built - [#1691](https://github.com/paritytech/ink/pull/1691)
- Add `set_code_hash` to `EnvAccess` - [#1698](https://github.com/paritytech/ink/pull/1698)
- Support conditional compilation - [#1707](https://github.com/paritytech/ink/pull/1707)
SkymanOne marked this conversation as resolved.
Show resolved Hide resolved

## Version 4.0.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ impl CallBuilder<'_> {
let span = message.span();
let message_ident = message.ident();
let output_ident = generator::output_ident(message_ident);
let cfg_attrs = message.get_cfg_attrs(span);
let trait_info_id = generator::generate_reference_to_trait_info(span, trait_path);
let (input_bindings, input_types): (Vec<_>, Vec<_>) = message
.callable()
Expand All @@ -295,6 +296,7 @@ impl CallBuilder<'_> {
.whitelisted_attributes()
.filter_attr(message.attrs().to_vec());
quote_spanned!(span=>
#( #cfg_attrs )*
type #output_ident = <<<
Self
as ::ink::codegen::TraitCallForwarderFor<{#trait_info_id}>>::Forwarder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,14 @@ impl ContractRef<'_> {
let mut_token = message.receiver().is_ref_mut().then(|| quote! { mut });
let input_bindings = message.inputs().map(|input| &input.pat).collect::<Vec<_>>();
let input_types = message.inputs().map(|input| &input.ty).collect::<Vec<_>>();
let cfg_attrs = message.get_cfg_attrs(span);
quote_spanned!(span=>
#( #cfg_attrs )*
type #output_ident =
<<Self::__ink_TraitInfo as ::ink::codegen::TraitCallForwarder>::Forwarder as #trait_path>::#output_ident;

#[inline]
#( #cfg_attrs )*
fn #message_ident(
& #mut_token self
#( , #input_bindings : #input_types )*
Expand Down
Loading