media/libvpx/lint_config.sh
author Johann <johannkoenig@google.com>
Mon, 16 Jan 2017 11:51:27 -0800
changeset 376885 70a5310085fa0c77bfcf88c4180c3e3af438a44d
parent 376407 ddb6c3191d11308531624d0fd4049792b16d730c
permissions -rwxr-xr-x
Bug 1223692: Update libvpx to v1.6.0. r=rillian This includes the following patches: <patch file> <upstream review commit> <upstream hash> 1237848-check-lookahead-ctx.patch https://chromium-review.googlesource.com/324510 4f780e94a1fa54f22256e0f4d42a77c340a38fa1 block_error_fp.patch https://chromium-review.googlesource.com/282611 ff8505a54d0b3dda220f5c0695519c353c82b933 cast-char-to-uint-before-shift.patch https://chromium-review.googlesource.com/345470 2240d83d7882ce2d5d0826b9ce33b86321d7a724 clamp_abs_lvl_seg.patch https://chromium-review.googlesource.com/315754 2e693eb80e705ea68e23eed19616d22b4778b45a clamp-abs-QIndex.patch https://chromium-review.googlesource.com/315802 ff3674a15e5b1a006546e1edc64c3e778eb34ab1 rename_duplicate_files.patch https://chromium-review.googlesource.com/281967 6a82f0d7fb9ee908c389e8d55444bbaed3d54e9c https://chromium-review.googlesource.com/317880 d36659cec7fab96cedc67db4d511ed7135637d0e vp9_filter_restore_aligment.patch https://chromium-review.googlesource.com/276889 33b3953c548a20c0aee705657df0440a740c28b7 vpx_once.patch https://chromium-review.googlesource.com/312467 2635573a7f2e4bbd259379acf91efb97d983359f MozReview-Commit-ID: R7qB6egl3Z

#!/bin/bash -e
#
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script is used to compare vpx_config.h and vpx_config.asm to
# verify the two files match.
#
# Arguments:
#
# -h - C Header file.
# -a - ASM file.
# -p - Print the options if correct.
# -o - Output file.
#
# Usage:
#
# # Compare the two configuration files and output the final results.
# ./lint_config.sh -h vpx_config.h -a vpx_config.asm -o libvpx.config -p

export LC_ALL=C
print_final="no"

while getopts "h:a:o:p" flag
do
  if [ "$flag" = "h" ]; then
    header_file=$OPTARG
  elif [ "$flag" = "a" ]; then
    asm_file=$OPTARG
  elif [ "$flag" = "o" ]; then
    out_file=$OPTARG
  elif [ "$flag" = "p" ]; then
    print_final="yes"
  fi
done

if [ -z "$header_file" ]; then
  echo "Header file not specified."
  false
  exit
fi

if [ -z "$asm_file" ]; then
  echo "ASM file not specified."
  false
  exit
fi

# Concat header file and assembly file and select those ended with 0 or 1.
combined_config="$(cat $header_file $asm_file | grep -E ' +[01] *$')"

# Extra filtering for known exceptions.
combined_config="$(echo "$combined_config" | grep -v WIDE_REFERENCE)"
combined_config="$(echo "$combined_config" | grep -v ARCHITECTURE)"
combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)"

# Remove all spaces.
combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')"

# Remove #define in the header file.
combined_config="$(echo "$combined_config" | sed 's/.*define//')"

# Remove equ in the ASM file.
combined_config="$(echo "$combined_config" | sed 's/\.equ//')" # gas style
combined_config="$(echo "$combined_config" | sed 's/equ//')" # rvds style
combined_config="$(echo "$combined_config" | sed 's/\.set//')" # apple style

# Remove %define in YASM ASM files.
combined_config="$(echo "$combined_config" | sed 's/%define\s *//')" # yasm style

# Remove useless comma in gas style assembly file.
combined_config="$(echo "$combined_config" | sed 's/,//')"

# Substitute 0 with =no.
combined_config="$(echo "$combined_config" | sed 's/0$/=no/')"

# Substitute 1 with =yes.
combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')"

# Find the mismatch variables.
odd_config="$(echo "$combined_config" | sort | uniq -u)"
odd_vars="$(echo "$odd_config" | sed 's/=.*//' | uniq)"

for var in $odd_vars; do
  echo "Error: Configuration mismatch for $var."
  echo "Header file: $header_file"
  echo "$(cat -n $header_file | grep "$var[ \t]")"
  echo "Assembly file: $asm_file"
  echo "$(cat -n $asm_file | grep "$var[ \t]")"
  echo ""
done

if [ -n "$odd_vars" ]; then
  false
  exit
fi

if [ "$print_final" = "no" ]; then
  exit
fi

# Do some additional filter to make libvpx happy.
combined_config="$(echo "$combined_config" | grep -v ARCH_X86=no)"
combined_config="$(echo "$combined_config" | grep -v ARCH_X86_64=no)"

# Print out the unique configurations.
if [ -n "$out_file" ]; then
  echo "$combined_config" | sort | uniq > $out_file
else
  echo "$combined_config" | sort | uniq
fi