| 1 | #!/bin/bash |
| 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | # You may not use this file except in compliance with the License. |
| 6 | # A copy of the License is located at |
| 7 | # |
| 8 | # http://aws.amazon.com/apache2.0 |
| 9 | # |
| 10 | # or in the "license" file accompanying this file. This file is distributed |
| 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | # express or implied. See the License for the specific language governing |
| 13 | # permissions and limitations under the License. |
| 14 | |
| 15 | set -ex |
| 16 | pushd "$(pwd)" |
| 17 | |
| 18 | usage() { |
| 19 | echo "install_boringssl.sh build_dir install_dir" |
| 20 | exit 1 |
| 21 | } |
| 22 | |
| 23 | if [ "$#" -ne "2" ]; then |
| 24 | usage |
| 25 | fi |
| 26 | |
| 27 | BUILD_DIR=$1 |
| 28 | INSTALL_DIR=$2 |
| 29 | source codebuild/bin/jobs.sh |
| 30 | cd "$BUILD_DIR" |
| 31 | |
| 32 | # Disable go proxy. see https://github.com/golang/go/issues/33985 |
| 33 | go env GOPRIVATE=* |
| 34 | |
| 35 | # BoringSSL doesn't have tags or versions in the Github repo. |
| 36 | # This commit represents the latest version that S2N is compatible |
| 37 | # with. It prevents our build system from breaking when BoringSSL |
| 38 | # is updated, last done on 2022-12-30. |
| 39 | BSSL_VERSION=31bad2514d21f6207f3925ba56754611c462a873 |
| 40 | mkdir boringssl |
| 41 | cd boringssl |
| 42 | git init |
| 43 | git remote add origin https://github.com/google/boringssl.git |
| 44 | git fetch origin --depth=1 $BSSL_VERSION |
| 45 | git reset --hard FETCH_HEAD |
| 46 | |
| 47 | git checkout $BSSL_VERSION |
| 48 | mkdir ../build |
| 49 | cd ../build |
| 50 | |
| 51 | cmake ../boringssl -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release |
| 52 | make -j $JOBS |
| 53 | |
| 54 | # BoringSSL does not define any install configuration in their CMake config, copy the stuff we know we need |
| 55 | mkdir -p "${INSTALL_DIR}/lib" |
| 56 | mkdir -p "${INSTALL_DIR}/bin" |
| 57 | cp crypto/libcrypto.so "${INSTALL_DIR}/lib/libcrypto.so" |
| 58 | cp tool/bssl "${INSTALL_DIR}/bin/bssl" |
| 59 | cp -r ../boringssl/include "$INSTALL_DIR" |
| 60 | |
| 61 | popd |
| 62 | |
| 63 | exit 0 |