Bug 1869043 allow a device to be specified with MediaTrackGraph::NotifyWhenDeviceStar...
[gecko.git] / media / libvpx / lint_config.sh
blob1a6c96dfbb94f63973272f3367827374e20e05aa
1 #!/bin/bash -e
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # This script is used to compare vpx_config.h and vpx_config.asm to
8 # verify the two files match.
10 # Arguments:
12 # -h - C Header file.
13 # -a - ASM file.
14 # -p - Print the options if correct.
15 # -o - Output file.
17 # Usage:
19 # # Compare the two configuration files and output the final results.
20 # ./lint_config.sh -h vpx_config.h -a vpx_config.asm -o libvpx.config -p
22 export LC_ALL=C
23 print_final="no"
25 while getopts "h:a:o:p" flag
27 if [ "$flag" = "h" ]; then
28 header_file=$OPTARG
29 elif [ "$flag" = "a" ]; then
30 asm_file=$OPTARG
31 elif [ "$flag" = "o" ]; then
32 out_file=$OPTARG
33 elif [ "$flag" = "p" ]; then
34 print_final="yes"
36 done
38 if [ -z "$header_file" ]; then
39 echo "Header file not specified."
40 false
41 exit
44 if [ -z "$asm_file" ]; then
45 echo "ASM file not specified."
46 false
47 exit
50 # Concat header file and assembly file and select those ended with 0 or 1.
51 combined_config="$(cat $header_file $asm_file | grep -E ' +[01] *$')"
53 # Extra filtering for known exceptions.
54 combined_config="$(echo "$combined_config" | grep -v WIDE_REFERENCE)"
55 combined_config="$(echo "$combined_config" | grep -v ARCHITECTURE)"
56 combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)"
58 # Remove all spaces.
59 combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')"
61 # Remove #define in the header file.
62 combined_config="$(echo "$combined_config" | sed 's/.*define//')"
64 # Remove equ in the ASM file.
65 combined_config="$(echo "$combined_config" | sed 's/\.equ//')" # gas style
66 combined_config="$(echo "$combined_config" | sed 's/equ//')" # rvds style
67 combined_config="$(echo "$combined_config" | sed 's/\.set//')" # apple style
69 # Remove %define in YASM ASM files.
70 combined_config="$(echo "$combined_config" | sed 's/%define\s *//')" # yasm style
72 # Remove useless comma in gas style assembly file.
73 combined_config="$(echo "$combined_config" | sed 's/,//')"
75 # Substitute 0 with =no.
76 combined_config="$(echo "$combined_config" | sed 's/0$/=no/')"
78 # Substitute 1 with =yes.
79 combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')"
81 # Find the mismatch variables.
82 odd_config="$(echo "$combined_config" | sort | uniq -u)"
83 odd_vars="$(echo "$odd_config" | sed 's/=.*//' | uniq)"
85 for var in $odd_vars; do
86 echo "Error: Configuration mismatch for $var."
87 echo "Header file: $header_file"
88 echo "$(cat -n $header_file | grep "$var[ \t]")"
89 echo "Assembly file: $asm_file"
90 echo "$(cat -n $asm_file | grep "$var[ \t]")"
91 echo ""
92 done
94 if [ -n "$odd_vars" ]; then
95 false
96 exit
99 if [ "$print_final" = "no" ]; then
100 exit
103 # Do some additional filter to make libvpx happy.
104 combined_config="$(echo "$combined_config" | grep -v ARCH_X86=no)"
105 combined_config="$(echo "$combined_config" | grep -v ARCH_X86_64=no)"
107 # Print out the unique configurations.
108 if [ -n "$out_file" ]; then
109 echo "$combined_config" | sort | uniq > $out_file
110 else
111 echo "$combined_config" | sort | uniq