diff --git a/Meta/WPT.sh b/Meta/WPT.sh index 214c4fd4c30..093ef6be5d5 100755 --- a/Meta/WPT.sh +++ b/Meta/WPT.sh @@ -4,13 +4,14 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -LADYBIRD_SOURCE_DIR="$(realpath "${DIR}"/..)" -WPT_SOURCE_DIR=${WPT_SOURCE_DIR:-"${LADYBIRD_SOURCE_DIR}/Tests/LibWeb/WPT/wpt"} -WPT_REPOSITORY_URL=${WPT_REPOSITORY_URL:-"https://github.com/web-platform-tests/wpt.git"} - # shellcheck source=/dev/null . "${DIR}/shell_include.sh" +ensure_ladybird_source_dir + +WPT_SOURCE_DIR=${WPT_SOURCE_DIR:-"${LADYBIRD_SOURCE_DIR}/Tests/LibWeb/WPT/wpt"} +WPT_REPOSITORY_URL=${WPT_REPOSITORY_URL:-"https://github.com/web-platform-tests/wpt.git"} + default_binary_path() { if [ "$(uname -s)" = "Darwin" ]; then echo "${LADYBIRD_SOURCE_DIR}/Build/ladybird/bin/Ladybird.app/Contents/MacOS/" diff --git a/Meta/ladybird.sh b/Meta/ladybird.sh index b204b3c3b7d..8f2ed508429 100755 --- a/Meta/ladybird.sh +++ b/Meta/ladybird.sh @@ -83,10 +83,6 @@ EOF fi -get_top_dir() { - git rev-parse --show-toplevel -} - create_build_dir() { check_program_version_at_least CMake cmake 3.25 || exit 1 cmake --preset "$BUILD_PRESET" "${CMAKE_ARGS[@]}" -S "$LADYBIRD_SOURCE_DIR" -B "$BUILD_DIR" @@ -97,10 +93,7 @@ cmd_with_target() { CMAKE_ARGS+=("-DCMAKE_C_COMPILER=${CC}") CMAKE_ARGS+=("-DCMAKE_CXX_COMPILER=${CXX}") - if [ ! -d "$LADYBIRD_SOURCE_DIR" ]; then - LADYBIRD_SOURCE_DIR="$(get_top_dir)" - export LADYBIRD_SOURCE_DIR - fi + ensure_ladybird_source_dir # Note: Keep in sync with buildDir defaults in CMakePresets.json case "${BUILD_PRESET}" in diff --git a/Meta/shell_include.sh b/Meta/shell_include.sh index 8be20ea96a9..b73d48b30bb 100644 --- a/Meta/shell_include.sh +++ b/Meta/shell_include.sh @@ -49,3 +49,14 @@ get_number_of_processing_units() { ($number_of_processing_units) } + +get_top_dir() { + git rev-parse --show-toplevel +} + +ensure_ladybird_source_dir() { + if [ -z "$LADYBIRD_SOURCE_DIR" ] || [ ! -d "$LADYBIRD_SOURCE_DIR" ]; then + LADYBIRD_SOURCE_DIR="$(get_top_dir)" + export LADYBIRD_SOURCE_DIR + fi +}