From 32c819949995155635aa86be2807d0fe81411d2f Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 28 Feb 2024 13:23:19 -0800 Subject: [PATCH] Trim unneeded code in scripts. --- scripts/config.sh | 66 ++++++++++++++-------------------------------- scripts/mk-docs.sh | 9 ++++--- scripts/test.sh | 2 +- 3 files changed, 26 insertions(+), 51 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index 6694d43b..e4be4c55 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -37,9 +37,7 @@ function future_date() { # Root of workspace-like directories. PROJECT_ROOT=$(relative "") || exit $? -CORE_ROOT=$(relative "core") || exit $? CONTRIB_ROOT=$(relative "contrib") || exit $? -SITE_ROOT=$(relative "site") || exit $? BENCHMARKS_ROOT=$(relative "benchmarks") || exit $? FUZZ_ROOT=$(relative "core/lib/fuzz") || exit $? @@ -47,35 +45,11 @@ FUZZ_ROOT=$(relative "core/lib/fuzz") || exit $? CORE_LIB_ROOT=$(relative "core/lib") || exit $? CORE_CODEGEN_ROOT=$(relative "core/codegen") || exit $? CORE_HTTP_ROOT=$(relative "core/http") || exit $? -GUIDE_TESTS_ROOT=$(relative "site/tests") || exit $? - -# Root of infrastructure directories. -EXAMPLES_DIR=$(relative "examples") || exit $? -DOC_DIR=$(relative "target/doc") || exit $? - -# Versioning information. These are changed as versions change. -VERSION=$(git grep -h "^version" "${CORE_LIB_ROOT}" | head -n 1 | cut -d '"' -f2) -MAJOR_VERSION=$(echo "${VERSION}" | cut -d'.' -f1-2) -GIT_BRANCH="$(git branch --show-current)" -GIT_BRANCH=${GIT_BRANCH:-$BRANCH} -IS_RELEASE_BRANCH=$( [[ $GIT_BRANCH == "v"* ]]; echo $? ) - -# A generated codename for this version. Use the git branch for pre-releases. -case $IS_RELEASE_BRANCH in - 1) - CODENAME="${GIT_BRANCH}" - DOC_VERSION="${GIT_BRANCH}-$(future_date)" - ;; - *) - CODENAME="${MAJOR_VERSION}" - DOC_VERSION="${VERSION}" - ;; -esac CORE_CRATE_ROOTS=( - "${CORE_HTTP_ROOT}" - "${CORE_CODEGEN_ROOT}" "${CORE_LIB_ROOT}" + "${CORE_CODEGEN_ROOT}" + "${CORE_HTTP_ROOT}" ) CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS=( @@ -88,38 +62,38 @@ CONTRIB_DB_POOLS_CRATE_ROOTS=( "${CONTRIB_ROOT}/db_pools/codegen" ) -ALL_CRATE_ROOTS=( - "${CORE_HTTP_ROOT}" - "${CORE_CODEGEN_ROOT}" - "${CORE_LIB_ROOT}" - "${CONTRIB_ROOT}/sync_db_pools/codegen" - "${CONTRIB_ROOT}/sync_db_pools/lib" - "${CONTRIB_ROOT}/db_pools/codegen" - "${CONTRIB_ROOT}/db_pools/lib" - "${CONTRIB_ROOT}/dyn_templates" - "${CONTRIB_ROOT}/ws" -) +# Root of infrastructure directories. +EXAMPLES_DIR=$(relative "examples") || exit $? +DOC_DIR=$(relative "target/doc") || exit $? + +# Versioning information. +VERSION=$(git grep -h "^version" "${CORE_LIB_ROOT}" | head -n 1 | cut -d '"' -f2) +GIT_BRANCH="$(git branch --show-current)" +GIT_BRANCH=${GIT_BRANCH:-$BRANCH} +IS_DEV_BRANCH=$( [[ $GIT_BRANCH == "v"* ]]; echo $? ) + +case $IS_DEV_BRANCH in + 1) DOC_VERSION="${GIT_BRANCH}-$(future_date)" ;; + *) DOC_VERSION="${VERSION}" ;; +esac function print_environment() { echo " VERSION: ${VERSION}" - echo " MAJOR_VERSION: ${MAJOR_VERSION}" echo " GIT_BRANCH: ${GIT_BRANCH}" - echo " IS_RELEASE_BRANCH: ${IS_RELEASE_BRANCH}" - echo " CODENAME: ${CODENAME}" + echo " IS_DEV_BRANCH: ${IS_DEV_BRANCH}" echo " DOC_VERSION: ${DOC_VERSION}" echo " SCRIPT_DIR: ${SCRIPT_DIR}" echo " PROJECT_ROOT: ${PROJECT_ROOT}" - echo " CORE_ROOT: ${CORE_ROOT}" echo " CONTRIB_ROOT: ${CONTRIB_ROOT}" - echo " SITE_ROOT: ${SITE_ROOT}" + echo " FUZZ_ROOT: ${FUZZ_ROOT}" echo " BENCHMARKS_ROOT: ${BENCHMARKS_ROOT}" echo " CORE_LIB_ROOT: ${CORE_LIB_ROOT}" echo " CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}" echo " CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}" - echo " GUIDE_TESTS_ROOT: ${GUIDE_TESTS_ROOT}" + echo " CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS: ${CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS[*]}" + echo " CONTRIB_DB_POOLS_CRATE_ROOTS: ${CONTRIB_DB_POOLS_CRATE_ROOTS[*]}" echo " EXAMPLES_DIR: ${EXAMPLES_DIR}" echo " DOC_DIR: ${DOC_DIR}" - echo " ALL_CRATE_ROOTS: ${ALL_CRATE_ROOTS[*]}" echo " date(): $(future_date)" } diff --git a/scripts/mk-docs.sh b/scripts/mk-docs.sh index bb6ccefa..3df48fe6 100755 --- a/scripts/mk-docs.sh +++ b/scripts/mk-docs.sh @@ -21,7 +21,9 @@ echo ":::: Generating docs (${DOC_VERSION})..." pushd "${PROJECT_ROOT}" > /dev/null 2>&1 # Set the crate version and fill in missing doc URLs with docs.rs links. RUSTDOCFLAGS="-Z unstable-options \ + --extern-html-root-url rocket=https://api.rocket.rs/${GIT_BRANCH}/rocket/ \ --crate-version ${DOC_VERSION} \ + --enable-index-page \ --generate-link-to-definition" \ cargo doc -Zrustdoc-map --no-deps --all-features \ -p rocket \ @@ -31,17 +33,16 @@ pushd "${PROJECT_ROOT}" > /dev/null 2>&1 -p rocket_ws popd > /dev/null 2>&1 -# Generating redirection list: from to. -echo ":::: Generating redirects..." REDIRECTS=" / /v0.5/rocket/ 302! /rocket/ /v0.5/rocket/ 302! /:v /:v/rocket/ /:v/* https://:v--rocket-docs.netlify.app/:splat 200 " - +# Generating redirection list: from to. if [ "${GIT_BRANCH}" = "master" ]; then + echo ":::: Generating redirects..." echo "${REDIRECTS}" | tee "${DOC_DIR}/_redirects" else - echo "-> '${GIT_BRANCH}' branch does not require redirects" + echo ":: Skipping redirects for branch '${GIT_BRANCH}'" fi diff --git a/scripts/test.sh b/scripts/test.sh index 555f4c7b..43468022 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -208,7 +208,7 @@ echo ":: Ensuring contrib sync_db_pools versions match..." check_versions_match "${CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS[@]}" echo ":: Ensuring contrib db_pools versions match..." -check_versions_match "${CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS[@]}" +check_versions_match "${CONTRIB_DB_POOLS_CRATE_ROOTS[@]}" echo ":: Ensuring minimum style requirements are met..." check_style