Trim unneeded code in scripts.

This commit is contained in:
Sergio Benitez 2024-02-28 13:23:19 -08:00
parent e4d8a8e377
commit ab028a7894
3 changed files with 26 additions and 50 deletions

View File

@ -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)"
}

View File

@ -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,8 +33,6 @@ 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!
@ -40,8 +40,10 @@ REDIRECTS="
/: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

View File

@ -207,7 +207,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