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

chore(ci): make the awslc fips install script version aware #5100

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
73 changes: 73 additions & 0 deletions codebuild/bin/install_awslc_fips.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
set -eu

usage() {
echo "install_awslc_fips.sh build_dir install_dir"
exit 1
}

check_dep(){
if [[ ! -f "$(which $1)" ]]; then
echo "Could not find $1"
exit 1
fi
}

clone(){
git clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_BRANCH" --depth 1 $BUILD_DIR
cd "$BUILD_DIR"
}

build() {
echo "Building with shared library=$1"
cmake $BUILD_DIR \
-Bbuild \
-GNinja \
-DBUILD_SHARED_LIBS=$1 \
-DCMAKE_BUILD_TYPE=relwithdebinfo \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DFIPS="true"
ninja -j "$(nproc)" -C build install
ninja -C build clean
}

# main
if [ "$#" -ne "3" ]; then
usage
fi

# Ensure tooling is available
check_dep clang
check_dep ninja
check_dep go

BUILD_DIR=$1
INSTALL_DIR=$2
VERSION=$3

# Map version to a specific feature branch/tag.
case $VERSION in
"2022")
AWSLC_BRANCH=AWS-LC-FIPS-2.0.17
;;
"2024")
AWSLC_BRANCH=AWS-LC-FIPS-3.0.0
;;
*)
echo "Unknown version: $VERSION"
usage
;;
esac

clone
# Static lib
build false
# Shared lib
build true

rm -rf $BUILD_DIR

49 changes: 4 additions & 45 deletions codebuild/bin/install_awslc_fips_2022.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

# SPDX-License-Identifier: Apache-2.0
set -eu
pushd "$(pwd)"

usage() {
echo "install_awslc_fips_2022.sh build_dir install_dir"
Expand All @@ -24,38 +12,9 @@ if [ "$#" -ne "2" ]; then
usage
fi

CBPATH=$(dirname $0)
BUILD_DIR=$1
INSTALL_DIR=$2

if [[ ! -f "$(which clang)" ]]; then
echo "Could not find clang"
exit 1
fi

AWSLC_VERSION=AWS-LC-FIPS-2.0.17

mkdir -p "$BUILD_DIR" || true
cd "$BUILD_DIR"
# --branch can also take tags and detaches the HEAD at that commit in the resulting repository
# --depth 1 Create a shallow clone with a history truncated to 1 commit
git clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_VERSION" --depth 1

build() {
shared=$1
cmake . \
-Bbuild \
-GNinja \
-DBUILD_SHARED_LIBS="${shared}" \
-DCMAKE_BUILD_TYPE=relwithdebinfo \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DFIPS=1
ninja -j "$(nproc)" -C build install
ninja -C build clean
}

build 0
build 1
$CBPATH/install_awslc_fips.sh $BUILD_DIR $INSTALL_DIR 2022

exit 0
18 changes: 18 additions & 0 deletions codebuild/bin/install_awslc_fips_2024.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
set -eu

usage() {
echo "install_awslc_fips_2024.sh build_dir install_dir"
exit 1
}

if [ "$#" -ne "2" ]; then
usage
fi

CBPATH=$(dirname $0)

$CBPATH/install_awslc_fips.sh $@ 2024

Loading