-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APT-4788: Prebuilding (and then reusing) binaries for common targets …
…to speed up builds
- Loading branch information
1 parent
70312f2
commit 37d1e8a
Showing
10 changed files
with
657 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2023 Provizio Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License 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. | ||
|
||
# Use as: | ||
# build_cache.sh [BUILD_TYPE=Release] [PYTHON=OFF|ON] [STATIC_ANALYSIS=OFF|ON] | ||
|
||
set -eu | ||
|
||
BUILD_TYPE=${1:-"Release"} | ||
PYTHON=${2:-"ON"} | ||
STATIC_ANALYSIS=${3:-"OFF"} | ||
|
||
cd "$(cd "$(dirname "$0")" && pwd -P)" | ||
|
||
source ./python_venv.sh | ||
|
||
cd ../.. | ||
|
||
BIN_CACHE_CONFIG_NAME="$(./bin_cache_config_name.sh "${BUILD_TYPE}")" | ||
BIN_CACHE_PATH="$(realpath ./cache)" | ||
TARGET_PATH="${BIN_CACHE_PATH}/${BIN_CACHE_CONFIG_NAME}" | ||
PYTHON_TARGET_PATH="${TARGET_PATH}/python" | ||
|
||
PROVIZIO_DDS_CHECK_FILE="${TARGET_PATH}/lib/libprovizio_dds.so" | ||
CACHED_PROVIZIO_DDS_PYTHON_TYPES_SO="${PYTHON_TARGET_PATH}/provizio_dds_python_types/_provizio_dds_python_types.so" | ||
|
||
# Check if it's already built | ||
ALREADY_BUILT="FALSE" | ||
if [ -f "${TARGET_PATH}.zip" ]; then | ||
ALREADY_BUILT="TRUE" | ||
unzip -q "${TARGET_PATH}.zip" -d "${BIN_CACHE_PATH}" | ||
|
||
if [ ! -f "${PROVIZIO_DDS_CHECK_FILE}" ]; then | ||
ALREADY_BUILT="FALSE" | ||
fi | ||
if [ "${PYTHON}" == "ON" ] && [ ! -f "${CACHED_PROVIZIO_DDS_PYTHON_TYPES_SO}" ]; then | ||
ALREADY_BUILT="FALSE" | ||
fi | ||
|
||
rm -rf "${TARGET_PATH}" | ||
fi | ||
|
||
if [ "${ALREADY_BUILT}" == "TRUE" ]; then | ||
echo "The bin cache is already built for ${BIN_CACHE_CONFIG_NAME}" | ||
else | ||
echo "Building bin cache for ${BIN_CACHE_CONFIG_NAME}..." | ||
|
||
# But first, let's delete any obsolete version there may be | ||
# shellcheck disable=SC2046 | ||
rm -rf "${BIN_CACHE_PATH:?}"/$(./bin_cache_config_name.sh "${BUILD_TYPE}" WILDCARD)* | ||
|
||
IGNORE_BIN_CACHE=TRUE .github/workflows/build.sh -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DSTATIC_ANALYSIS="${STATIC_ANALYSIS}" -DPYTHON_BINDINGS="${PYTHON}" -DENABLE_TESTS="OFF" -DENABLE_CHECK_FORMAT="OFF" -DCMAKE_INSTALL_PREFIX="${TARGET_PATH}" -DPYTHON_PACKAGES_INSTALL_DIR="${PYTHON_TARGET_PATH}" | ||
cd ./build | ||
cmake --install . | ||
|
||
# Delete extra copy of python-specific libs produced by Fast-DDS Python wrapper (as it's already included in dedicated Python subfolder) | ||
rm -rf "${TARGET_PATH}"/lib/python* | ||
# Delete extra cmake files | ||
rm -rf "${TARGET_PATH}/lib/cmake" | ||
|
||
# zip it now! | ||
cd "${BIN_CACHE_PATH}" | ||
zip -r -y "${BIN_CACHE_CONFIG_NAME}.zip" "${BIN_CACHE_CONFIG_NAME}" | ||
rm -rf "${TARGET_PATH}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.