From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 4765B3AA8004; Wed, 8 Jun 2022 11:55:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4765B3AA8004 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Add script to generate gource X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 0024bc2f028369b871a65ceb11b2fddfb0f9c3aa X-Git-Newrev: 854281e251d298099542a9209c0021e225850f86 Message-Id: <20220608115528.4765B3AA8004@sourceware.org> Date: Wed, 8 Jun 2022 11:55:28 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 11:55:28 -0000 https://gcc.gnu.org/g:854281e251d298099542a9209c0021e225850f86 commit 854281e251d298099542a9209c0021e225850f86 Author: Philip Herron Date: Thu Dec 9 16:30:43 2021 +0000 Add script to generate gource This script tries to isolate our changes to GCC minus the changes to gcc/config so that we can visualize our development history. Diff: --- gcc/rust/gource-gccrs.sh | 129 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/gcc/rust/gource-gccrs.sh b/gcc/rust/gource-gccrs.sh new file mode 100755 index 00000000000..f14a2e52c6e --- /dev/null +++ b/gcc/rust/gource-gccrs.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +set -e + +usage() { echo "Usage: $0 [-o output.mp4] [-r 1600x1080]" 1>&2; } + +RESOLUTION="1600x1080" +output="" +while getopts ho:r: flag; do + case "${flag}" in + o) + output=${OPTARG} + ;; + r) + RESOLUTION=${OPTARG} + ;; + h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac +done + +# we require gource and ffmpeg to generate this stuff +if ! [ -x "$(command -v git)" ]; then + echo 'Error: git is not installed.' >&2 + exit 1 +fi +if ! [ -x "$(command -v gource)" ]; then + echo 'Error: gource is not installed.' >&2 + exit 1 +fi +if ! [ -x "$(command -v ffmpeg)" ]; then + echo 'Error: ffmpeg is not installed.' >&2 + exit 1 +fi + +# are we in the root of the repo? +if [ ! -d ".git" ]; then + echo ".git directory not found, this script must be run at root repo" + exit 1 +fi + +# if the output already exists then we should stop +if test -f "$output"; then + echo "$output already exists." + exit 1 +fi + +# check if .ppm exists +if test -f "gource.ppm"; then + echo "gource.ppm already exists." + exit 1 +fi + +# is cargo-gccrs here? +if [ ! -d "cargo-gccrs" ]; then + git clone git@github.com:Rust-GCC/cargo-gccrs.git +fi + +# get the log file for cargo gccrs +pushd cargo-gccrs +rm -f cargo.log +gource --output-custom-log cargo.log . +sed -i -E "s#(.+)\|#\1|/cargo#" cargo.log +mv cargo.log ../ +popd + +# generate the log file for gccrs +git log --pretty=format:user:%aN%n%ct \ + --reverse \ + --raw \ + --encoding=UTF-8 \ + --no-renames \ + --no-show-signature \ + -- \ + .github \ + Dockerfile \ + *.md \ + gcc/rust \ + gcc/testsuite/rust \ + gcc/testsuite/rust.test > gccrs-raw.log +gource --log-format git --output-custom-log gccrs.log - < gccrs-raw.log +rm -f gccrs-raw.log + +# combine them +combined_log="$(mktemp /tmp/gource.XXXXXX)" +cat cargo.log gccrs.log | sort -n > "$combined_log" +rm -f gccrs.log +rm -f cargo.log + +echo "Committers:" +awk -F\| {'print $2'} < "$combined_log"| sort | uniq +echo "======================" + +GOURCE_RESOLUTION_ARG="-$RESOLUTION" +GOURCE_OUTPUT_ARGS="" +if [ -n "$output" ]; then + GOURCE_OUTPUT_ARGS="--output-ppm-stream gource.ppm" +fi + +# actually generate the gource +gource "$combined_log" \ + --title "GCC Rust" \ + -s 0.4 \ + -i 0 \ + "$GOURCE_RESOLUTION_ARG" \ + --highlight-users \ + --highlight-dirs \ + --file-extensions \ + --hide mouse \ + --key \ + --stop-at-end \ + "$GOURCE_OUTPUT_ARGS" + +# cleanup the log +rm -f "$combined_log" + +# transcode it +if [ -n "$output" ]; then + # this seems to encode at a high quality but ends up being many gb in size + ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i gource.ppm -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 "$output" +fi + +echo "crabby on film: $output" +echo "(\/)(º~º)(\/)"