Debian Codegraph @

crt/s2n/codebuild/bin/install_awslc.sh

raw symbols SCIP
1 #!/usr/bin/env 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 -eu
16 pushd "$(pwd)"
17
18 usage() {
19 echo -e "\ninstall_awslc.sh build_dir install_dir"
20 echo -e "\tIf you need FIPS, use the FIPS specific install script.\n"
21 exit 1
22 }
23
24 if [ "$#" -ne "2" ]; then
25 usage
26 fi
27
28 BUILD_DIR=$1
29 INSTALL_DIR=$2
30 GH_RELEASE_URL="https://api.github.com/repos/aws/aws-lc/releases"
31
32 if [[ ! -f "$(which clang)" ]]; then
33 echo "Could not find clang"
34 exit 1
35 fi
36
37 # Ask GitHub for the latest v1.x release.
38 AWSLC_VERSION=$(curl --silent "$GH_RELEASE_URL" | \
39 grep -Po '"tag_name": "\Kv1\..*?(?=")' |head -1)
40
41 mkdir -p "$BUILD_DIR"||true
42 cd "$BUILD_DIR"
43 echo "Checking out tag=$AWSLC_VERSION"
44 # --branch can also take tags and detaches the HEAD at that commit in the resulting repository
45 # --depth 1 Create a shallow clone with a history truncated to 1 commit
46 # If the curl above is throttled, fall back to a known version.
47 git clone https://github.com/awslabs/aws-lc.git --branch "${AWSLC_VERSION:-main}" --depth 1
48
49 install_awslc() {
50 echo "Building with shared library=$1"
51 cmake ./aws-lc \
52 -Bbuild \
53 -GNinja \
54 -DBUILD_SHARED_LIBS=$1 \
55 -DCMAKE_BUILD_TYPE=relwithdebinfo \
56 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
57 -DCMAKE_C_COMPILER=$(which clang) \
58 -DCMAKE_CXX_COMPILER=$(which clang++) \
59 -DDISABLE_GO=ON
60 ninja -j "$(nproc)" -C build install
61 ninja -C build clean
62 }
63
64 install_awslc 0
65 install_awslc 1
66
67 exit 0