Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 9 additions & 4 deletions scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ set -o errexit # Exit on error
# - CC and CXX
# - COMPILER # important for Visual Studio paths (vs-2012, vs-2013 or vs-2015)

# Input <ci-depends-on-flags> adds cmake flags for configure to handle ci-depends-on. If no ci-depends-on is used, then the string should be equal to "no-ci-depends-on"

## Checks

usage() {
echo "Usage: configure.sh <build-dir> <src-dir> <config> <build-type> <build-options>"
echo "Usage: configure.sh <build-dir> <src-dir> <config> <ci-depends-on-flags> <build-type> <build-options>"
}

if [ "$#" -ge 4 ]; then
Expand All @@ -31,9 +32,13 @@ if [ "$#" -ge 4 ]; then
PLATFORM="$(get-platform-from-config "$CONFIG")"
COMPILER="$(get-compiler-from-config "$CONFIG")"
ARCHITECTURE="$(get-architecture-from-config "$CONFIG")"
BUILD_TYPE="$4"
CI_DEPENDS_ON_FLAGS="$4"
if [ "$CI_DEPENDS_ON_FLAGS" == "no-ci-depends-on" ]; then
CI_DEPENDS_ON_FLAGS=""
fi
BUILD_TYPE="$5"
BUILD_TYPE_CMAKE="$(get-build-type-cmake "$BUILD_TYPE")"
BUILD_OPTIONS="${*:5}"
BUILD_OPTIONS="${*:6}"
if [ -z "$BUILD_OPTIONS" ]; then
BUILD_OPTIONS="$(get-build-options)" # use env vars (Jenkins)
fi
Expand Down Expand Up @@ -77,7 +82,7 @@ if vm-is-windows && [ ! -d "$SRC_DIR/lib" ]; then
)
fi

cmake_options=""
cmake_options="$CI_DEPENDS_ON_FLAGS"
add-cmake-option() {
cmake_options="$cmake_options $*"
}
Expand Down
39 changes: 25 additions & 14 deletions scripts/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ if [ -n "$DASH_COMMIT_BRANCH" ] && [ -n "$GITHUB_COMMIT_HASH" ] && [ -n "$GITHUB
fi


ci_depends_on_cmake_flags=""

# Handle [ci-depends-on]
if [[ "$DASH_COMMIT_BRANCH" == *"/PR-"* ]]; then
# Get info about this PR from GitHub API
Expand All @@ -277,18 +279,27 @@ if [[ "$DASH_COMMIT_BRANCH" == *"/PR-"* ]]; then
dependency_project_url="$(github-get-pr-project-url "$dependency_json")"
dependency_merge_commit="$(github-get-pr-merge-commit "$dependency_json")"

external_project_file="$(find "$SRC_DIR" -wholename "*/$dependency_project_name/ExternalProjectConfig.cmake.in")"
if [ -e "$external_project_file" ]; then
# Force replace GIT_REPOSITORY and GIT_TAG
sed -i'.bak' 's,GIT_REPOSITORY .*,GIT_REPOSITORY '"$dependency_project_url"',g' "$external_project_file" && rm -f "$external_project_file.bak"
sed -i'.bak' 's,GIT_TAG .*,GIT_TAG '"$dependency_merge_commit"',g' "$external_project_file" && rm -f "$external_project_file.bak"
fi
echo "[ci-depends-on] Replacing $external_project_file with"
echo " GIT_REPOSITORY $dependency_project_url"
echo " GIT_TAG $dependency_merge_commit"
# Format the CMake flags for this key and append to the result
fixed_name=$(echo "$dependency_project_name" | awk '{gsub(/\./, "_"); print toupper($0)}')
flag_repository="-D${fixed_name}_GIT_REPOSITORY=\"$dependency_project_url\""
flag_tag="-D${fixed_name}_GIT_TAG=\"$dependency_merge_commit\""


echo "[ci-depends-on] Adding following flags to cmake"
echo " $flag_repository"
echo " $flag_tag"

ci_depends_on_cmake_flags="$ci_depends_on_cmake_flags $flag_repository $flag_tag"
done < <( echo "$pr_description" | grep '\[ci-depends-on' )
fi

fi
if [ -n "$ci_depends_on_cmake_flags" ]; then
echo "[ci-depends-on] Finished ! "
echo " The followings flags will be added for the cmake call : '$ci_depends_on_cmake_flags' "
else
echo "No [ci-depends-on] detected. "
ci_depends_on_cmake_flags="no-ci-depends-on"
fi

time_millisec_git_end="$(time-millisec)"
time_sec_git="$(time-elapsed-sec $time_millisec_git_begin $time_millisec_git_end)"
Expand All @@ -298,7 +309,7 @@ echo "[END] Git work ($(time-date)) - took $time_sec_git seconds"
# Configure
echo "[BEGIN] Configure ($(time-date))"
time_millisec_configure_begin="$(time-millisec)"
. "$SCRIPT_DIR/configure.sh" "$BUILD_DIR" "$SRC_DIR" "$CONFIG" "$BUILD_TYPE" "$BUILD_OPTIONS"
. "$SCRIPT_DIR/configure.sh" "$BUILD_DIR" "$SRC_DIR" "$CONFIG" "$ci_depends_on_cmake_flags" "$BUILD_TYPE" "$BUILD_OPTIONS"
time_millisec_configure_end="$(time-millisec)"
time_sec_configure="$(time-elapsed-sec $time_millisec_configure_begin $time_millisec_configure_end)"
echo "[END] Configure ($(time-date)) - took $time_sec_configure seconds"
Expand All @@ -307,11 +318,11 @@ echo "[END] Configure ($(time-date)) - took $time_sec_configure seconds"
# Regression dir
# WARNING: source files exist only after configure, they are fetched by CMake
if in-array "run-regression-tests" "$BUILD_OPTIONS"; then # Jenkins
if [ -n "$WORKSPACE" ] && [ -d "$SRC_DIR/applications/projects/Regression" ]; then
if [ -n "$WORKSPACE" ] && [ -d "$BUILD_DIR/external_directories/fetched/Regression" ]; then
if vm-is-windows; then
export REGRESSION_DIR="$(cd "$SRC_DIR/applications/projects/Regression" && pwd -W)"
export REGRESSION_DIR="$(cd "$BUILD_DIR/external_directories/fetched/Regression" && pwd -W)"
else
export REGRESSION_DIR="$(cd "$SRC_DIR/applications/projects/Regression" && pwd)"
export REGRESSION_DIR="$(cd "$BUILD_DIR/external_directories/fetched/Regression" && pwd)"
fi
elif [ -z "$REGRESSION_DIR" ]; then # not Jenkins and no REGRESSION_DIR
echo "WARNING: run-regression-tests option needs REGRESSION_DIR env var, regression tests will NOT be performed."
Expand Down
31 changes: 7 additions & 24 deletions scripts/pre-builds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,20 @@ if [[ "$DASH_COMMIT_BRANCH" == *"/PR-"* ]]; then
echo "dependency_merge_commit = $dependency_merge_commit"
echo "dependency_merge_branch = $dependency_merge_branch"

if [[ "$dependency_is_merged" == [Tt]"rue" ]]; then # this dependency is a merged PR
#echo "pr_diff = $pr_diff"
pr_diff_for_dependency="$(echo "$pr_diff" | grep -v '^-' | sed -n -e '/'$dependency_project_name'\/ExternalProjectConfig\.cmake\.in/,/diff --git/p')"
echo "pr_diff_for_dependency = $pr_diff_for_dependency"
dependency_git_repository="$(echo "$pr_diff_for_dependency" | grep -o "GIT_REPOSITORY .*" || true)"
echo "dependency_git_repository = $dependency_git_repository"
dependency_git_tag="$(echo "$pr_diff_for_dependency" | grep -o "GIT_TAG .*" || true)"
echo "dependency_git_tag = $dependency_git_tag"
# The diff (without removals), taken only for ProjectName/ExternalProjectConfig.cmake.in, DOES NOT contain the correct GIT_REPOSITORY and GIT_TAG
if [ -n "$dependency_git_repository" ] && [[ "$dependency_git_repository" != *"$dependency_project_url"* ]] ||
[ -n "$dependency_git_tag" ] && [[ "$dependency_git_tag" != *"$dependency_merge_branch"* ]] && [[ "$dependency_git_tag" != *"$dependency_merge_commit"* ]]; then
pr_is_mergeable="false"
github_comment_body=$github_comment_body'\n- **Edit '$dependency_project_name'/ExternalProjectConfig.cmake.in** with'
if [ -n "$dependency_git_repository" ] && [[ "$dependency_git_repository" != *"$dependency_project_url"* ]]; then
github_comment_body=$github_comment_body'\nGIT_REPOSITORY '$dependency_project_url
fi
if [ -n "$dependency_git_tag" ] && [[ "$dependency_git_tag" != *"$dependency_merge_branch"* ]] && [[ "$dependency_git_tag" != *"$dependency_merge_commit"* ]]; then
github_comment_body=$github_comment_body'\nGIT_TAG origin/'$dependency_merge_branch
pr_is_mergeable="false"
fi
fi
else
github_comment_body=$github_comment_body'\n- **Merge or close '$dependency_url'**\n_For this build, '$dependency_project_name'/ExternalProjectConfig.cmake.in will be edited by builders with\nGIT_REPOSITORY '$dependency_project_url'\nGIT_TAG '$dependency_merge_commit'_'
fixed_name=$(echo "$dependency_project_name" | awk '{gsub(/\./, "_"); print toupper($0)}')
flag_repository="-D${fixed_name}_GIT_REPOSITORY=\"$dependency_project_url\""
flag_tag="-D${fixed_name}_GIT_TAG=\"$dependency_merge_commit\""

if [[ "$dependency_is_merged" != [Tt]"rue" ]]; then # this dependency is a merged PR
github_comment_body=$github_comment_body'\n- **Merge or close '$dependency_url'**\n_For this build, the following CMake flags will be set\n'${flag_repository}'\n'${flag_tag}'_'
pr_is_mergeable="false"
fi
done < <( echo "$pr_description" | grep '\[ci-depends-on' )

if [[ "$pr_has_dependencies" == "true" ]]; then
if [[ "$pr_is_mergeable" == "true" ]]; then
# PR has dependencies that are all closed/merged and ExternalProject pointers are up-to-date
github_comment_body='\n\n All dependencies are merged/closed and all ExternalProject pointers are up-to-date. Congrats! :+1:'
github_comment_body='\n\n All dependencies are merged/closed. Congrats! :+1:'
github-notify "success" "Dependencies are OK."
github-post-pr-comment "$pr_id" "$github_comment_header $github_comment_body"
else
Expand Down
Loading