| 1 | #!/usr/bin/env bash |
| 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | set -xe |
| 6 | |
| 7 | # cd into the script directory so it can be executed from anywhere |
| 8 | pushd "$(dirname "${BASH_SOURCE[0]}")" |
| 9 | |
| 10 | # delete the existing copy in case we have extra files |
| 11 | rm -rf s2n-tls-sys/lib |
| 12 | mkdir -p s2n-tls-sys/lib |
| 13 | mkdir -p s2n-tls-sys/lib/tests |
| 14 | mkdir -p s2n-tls-sys/src/features |
| 15 | |
| 16 | # we copy the C sources into the `lib` directory so they get published in the |
| 17 | # actual crate artifact. |
| 18 | cp -r \ |
| 19 | ../../../api \ |
| 20 | ../../../crypto \ |
| 21 | ../../../error \ |
| 22 | ../../../stuffer \ |
| 23 | ../../../tls \ |
| 24 | ../../../utils \ |
| 25 | s2n-tls-sys/lib/ |
| 26 | |
| 27 | cp -r \ |
| 28 | ../../../tests/features \ |
| 29 | s2n-tls-sys/lib/tests/ |
| 30 | |
| 31 | cp -r \ |
| 32 | ../../../CMakeLists.txt \ |
| 33 | ../../../cmake \ |
| 34 | s2n-tls-sys/lib/ |
| 35 | |
| 36 | # generate the bindings modules from the copied sources |
| 37 | pushd generate |
| 38 | # Behavior change from https://github.com/rust-lang/rustup/pull/3985 |
| 39 | rustc --version || rustup toolchain install |
| 40 | rustup component add rustfmt |
| 41 | cargo run -- ../s2n-tls-sys |
| 42 | popd |
| 43 | |
| 44 | if [ "$1" == "--skip-tests" ]; then |
| 45 | echo "skipping tests" |
| 46 | exit; |
| 47 | fi; |
| 48 | |
| 49 | # make sure everything builds and passes sanity checks |
| 50 | pushd s2n-tls-sys |
| 51 | cargo test |
| 52 | cargo test --all-features |
| 53 | cargo test --release |
| 54 | cargo publish --dry-run --allow-dirty |
| 55 | cargo publish --dry-run --allow-dirty --all-features |
| 56 | popd |
| 57 | |
| 58 | pushd ../standard/integration |
| 59 | rustc --version || rustup toolchain install |
| 60 | cargo run |
| 61 | popd |
| 62 | |
| 63 | popd |