diff --git a/scripts/update-devtools.sh b/scripts/update-devtools.sh new file mode 100755 index 0000000000000..08a8215a3d81c --- /dev/null +++ b/scripts/update-devtools.sh @@ -0,0 +1,129 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Please provide a language argument: java, dotnet, ruby, python, javascript, or all." + exit 1 +fi + +LANGUAGE="$1" + +FULL_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json | jq -r '.channels.Stable.version') + +MAJOR_VERSION=$(echo "$FULL_VERSION" | cut -d'.' -f1) +PREVIOUS_VERSION=$((MAJOR_VERSION - 1)) +REMOVING_VERSION=$((MAJOR_VERSION - 3)) + +# Update pdl files if target directory does not exist +TARGET_DIR="common/devtools/chromium/v${MAJOR_VERSION}" +if [ ! -d "$TARGET_DIR" ]; then + REMOVING_DIR="common/devtools/chromium/v${REMOVING_VERSION}" + if [ -d "$REMOVING_DIR" ]; then + rm -r "$REMOVING_DIR" + echo "Removed directory: $REMOVING_DIR" + fi + + DEPS_CONTENT=$(curl -s "https://raw.githubusercontent.com/chromium/chromium/${FULL_VERSION}/DEPS") + curl -O "https://raw.githubusercontent.com/chromium/chromium/${FULL_VERSION}/third_party/blink/public/devtools_protocol/browser_protocol.pdl" + + V8_REVISION=$(echo "$DEPS_CONTENT" | grep 'v8_revision' | awk -F': ' '{print $2}' | tr -d "',") + curl -O "https://raw.githubusercontent.com/v8/v8/${V8_REVISION}/include/js_protocol.pdl" + + SOURCE_DIR="common/devtools/chromium/v${PREVIOUS_VERSION}" + mkdir -p "$TARGET_DIR" + + if [ -d "$SOURCE_DIR" ]; then + cp -r "$SOURCE_DIR/"* "$TARGET_DIR/" + fi + + mv js_protocol.pdl "$TARGET_DIR" + mv browser_protocol.pdl "$TARGET_DIR" + echo "Contents from $SOURCE_DIR have been copied to $TARGET_DIR!" + + # Fix known syntax issue with downloaded pdl + sed -i '' 's/`