11cb0ef41Sopenharmony_ci#!/bin/bash
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci# Collect the number of [[deprecated]] calls detected when compiling V8.
41cb0ef41Sopenharmony_ci# Requires "v8_deprecate_get_isolate = true" to be useful.
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciset -e
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciif [ -z "$1" ]; then
91cb0ef41Sopenharmony_ci  (>&2 echo "Usage: collect_deprecation_stats.sh [<outdir>|<log>]")
101cb0ef41Sopenharmony_ci  exit 1
111cb0ef41Sopenharmony_cifi
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciif [ -d "$1" ]; then
141cb0ef41Sopenharmony_ci  OUTDIR=$1
151cb0ef41Sopenharmony_ci  FULL_LOG=/tmp/get_isolate_deprecation.log
161cb0ef41Sopenharmony_ci  gn clean "$OUTDIR"
171cb0ef41Sopenharmony_ci  autoninja -C "$OUTDIR" > $FULL_LOG
181cb0ef41Sopenharmony_cielse
191cb0ef41Sopenharmony_ci  FULL_LOG=$1
201cb0ef41Sopenharmony_cifi
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciFILTERED_LOG=/tmp/filtered_isolate_deprecation.log
231cb0ef41Sopenharmony_ciUNIQUE_WARNINGS_LOG=/tmp/unique_warnings.log
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_cigrep "warning:" "$FULL_LOG" | sed $'
261cb0ef41Sopenharmony_cis|^\.\./\.\./||;
271cb0ef41Sopenharmony_cis/: warning: \'/: /;
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci# strip everything after deprecated function name (including template param).
301cb0ef41Sopenharmony_cis/\(<.*>\)\\?\'.*//' > $FILTERED_LOG
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_cisort -u $FILTERED_LOG > $UNIQUE_WARNINGS_LOG
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciecho "Total deprecated calls: $(wc -l < $UNIQUE_WARNINGS_LOG)"
351cb0ef41Sopenharmony_cicut -f2 -d' ' $UNIQUE_WARNINGS_LOG | sort | uniq -c
36