Skip to content

Commit 0eb643b

Browse files
authored
Merge pull request #64 from bakpaul/25_03_modify_ci_depends_on_for_fetchins_in_build
Modify ci-depends-on for fetching in build
2 parents fc1e10b + 67b68c6 commit 0eb643b

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

scripts/configure.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ set -o errexit # Exit on error
1414
# - CC and CXX
1515
# - COMPILER # important for Visual Studio paths (vs-2012, vs-2013 or vs-2015)
1616

17+
# 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"
1718

1819
## Checks
1920

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

2425
if [ "$#" -ge 4 ]; then
@@ -31,9 +32,13 @@ if [ "$#" -ge 4 ]; then
3132
PLATFORM="$(get-platform-from-config "$CONFIG")"
3233
COMPILER="$(get-compiler-from-config "$CONFIG")"
3334
ARCHITECTURE="$(get-architecture-from-config "$CONFIG")"
34-
BUILD_TYPE="$4"
35+
CI_DEPENDS_ON_FLAGS="$4"
36+
if [ "$CI_DEPENDS_ON_FLAGS" == "no-ci-depends-on" ]; then
37+
CI_DEPENDS_ON_FLAGS=""
38+
fi
39+
BUILD_TYPE="$5"
3540
BUILD_TYPE_CMAKE="$(get-build-type-cmake "$BUILD_TYPE")"
36-
BUILD_OPTIONS="${*:5}"
41+
BUILD_OPTIONS="${*:6}"
3742
if [ -z "$BUILD_OPTIONS" ]; then
3843
BUILD_OPTIONS="$(get-build-options)" # use env vars (Jenkins)
3944
fi
@@ -77,7 +82,7 @@ if vm-is-windows && [ ! -d "$SRC_DIR/lib" ]; then
7782
)
7883
fi
7984

80-
cmake_options=""
85+
cmake_options="$CI_DEPENDS_ON_FLAGS"
8186
add-cmake-option() {
8287
cmake_options="$cmake_options $*"
8388
}

scripts/main.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ if [ -n "$DASH_COMMIT_BRANCH" ] && [ -n "$GITHUB_COMMIT_HASH" ] && [ -n "$GITHUB
257257
fi
258258

259259

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

280-
external_project_file="$(find "$SRC_DIR" -wholename "*/$dependency_project_name/ExternalProjectConfig.cmake.in")"
281-
if [ -e "$external_project_file" ]; then
282-
# Force replace GIT_REPOSITORY and GIT_TAG
283-
sed -i'.bak' 's,GIT_REPOSITORY .*,GIT_REPOSITORY '"$dependency_project_url"',g' "$external_project_file" && rm -f "$external_project_file.bak"
284-
sed -i'.bak' 's,GIT_TAG .*,GIT_TAG '"$dependency_merge_commit"',g' "$external_project_file" && rm -f "$external_project_file.bak"
285-
fi
286-
echo "[ci-depends-on] Replacing $external_project_file with"
287-
echo " GIT_REPOSITORY $dependency_project_url"
288-
echo " GIT_TAG $dependency_merge_commit"
282+
# Format the CMake flags for this key and append to the result
283+
fixed_name=$(echo "$dependency_project_name" | awk '{gsub(/\./, "_"); print toupper($0)}')
284+
flag_repository="-D${fixed_name}_GIT_REPOSITORY=\"$dependency_project_url\""
285+
flag_tag="-D${fixed_name}_GIT_TAG=\"$dependency_merge_commit\""
286+
287+
288+
echo "[ci-depends-on] Adding following flags to cmake"
289+
echo " $flag_repository"
290+
echo " $flag_tag"
291+
292+
ci_depends_on_cmake_flags="$ci_depends_on_cmake_flags $flag_repository $flag_tag"
289293
done < <( echo "$pr_description" | grep '\[ci-depends-on' )
290-
fi
291294

295+
fi
296+
if [ -n "$ci_depends_on_cmake_flags" ]; then
297+
echo "[ci-depends-on] Finished ! "
298+
echo " The followings flags will be added for the cmake call : '$ci_depends_on_cmake_flags' "
299+
else
300+
echo "No [ci-depends-on] detected. "
301+
ci_depends_on_cmake_flags="no-ci-depends-on"
302+
fi
292303

293304
time_millisec_git_end="$(time-millisec)"
294305
time_sec_git="$(time-elapsed-sec $time_millisec_git_begin $time_millisec_git_end)"
@@ -298,7 +309,7 @@ echo "[END] Git work ($(time-date)) - took $time_sec_git seconds"
298309
# Configure
299310
echo "[BEGIN] Configure ($(time-date))"
300311
time_millisec_configure_begin="$(time-millisec)"
301-
. "$SCRIPT_DIR/configure.sh" "$BUILD_DIR" "$SRC_DIR" "$CONFIG" "$BUILD_TYPE" "$BUILD_OPTIONS"
312+
. "$SCRIPT_DIR/configure.sh" "$BUILD_DIR" "$SRC_DIR" "$CONFIG" "$ci_depends_on_cmake_flags" "$BUILD_TYPE" "$BUILD_OPTIONS"
302313
time_millisec_configure_end="$(time-millisec)"
303314
time_sec_configure="$(time-elapsed-sec $time_millisec_configure_begin $time_millisec_configure_end)"
304315
echo "[END] Configure ($(time-date)) - took $time_sec_configure seconds"

0 commit comments

Comments
 (0)