Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
| 3 # Copyright 2013 Google Inc. | |
| 4 # | |
| 5 # Use of this source code is governed by a BSD-style license that can be | |
| 6 # found in the LICENSE file. | |
| 7 | |
| 8 if [ "${1}" == '-h' ] || [ "${1}" == '--help' ] | |
| 9 then | |
| 10 echo 'test_all_pdfs.sh | |
| 11 Usage: Run from the trunk directory of a Skia tree to convert a folder of PDFs i nto PNGs. | |
| 12 Many threads will be run simultaneously using the tool parallel if it is installed. | |
|
epoger
2013/11/11 18:56:18
Would be clearer like this:
Many threads will be
scroggo
2013/11/12 14:51:44
Done.
| |
| 13 Requires that skdiff and pdfviewer have already been built. | |
| 14 | |
| 15 Arguments: | |
| 16 folder Folder containing PDF files. The PNG results will be placed in " folder/new". | |
| 17 If folder contains a folder named "old", the PNGs in "folder/new " will be | |
| 18 compared to PNGs in "folder/old" with the same name, and the dif ferences | |
| 19 will be stored in a "folder/d".' | |
| 20 exit | |
| 21 fi | |
| 22 | |
| 23 # Early exit if pdfviewer has not been built. | |
| 24 # TODO (scroggo): Use release version if debug is unavailable | |
| 25 if [ ! -f out/Debug/pdfviewer ] | |
| 26 then | |
| 27 echo 'debug version of pdfviewer is required.' | |
| 28 exit | |
| 29 fi | |
| 30 | |
| 31 if [ -z $1 ] | |
| 32 then | |
| 33 echo 'folder is a required argument.' | |
| 34 exit | |
| 35 fi | |
| 36 | |
| 37 if [ ! -d $1 ] | |
| 38 then | |
| 39 echo 'folder must be a valid directory.' | |
| 40 exit | |
| 41 fi | |
| 42 | |
| 43 # Create the directory to contain the new results. If old new results exist, rem ove them. | |
| 44 if [ -d $1/new ] | |
| 45 then | |
| 46 rm -rf $1/new | |
| 47 fi | |
| 48 | |
| 49 mkdir $1/new/ | |
| 50 | |
| 51 # Run the script to read each PDF and convert it to a PNG. | |
| 52 if command -v parallel >/dev/null 2>&1 | |
| 53 then | |
| 54 echo 'Running in parallel' | |
| 55 ls -1 $1/*.pdf | sed "s/^/experimental\/PdfViewer\/scripts\/vm_pdf_viewer_ru n_one_pdf.sh /" \ | |
| 56 | parallel | |
| 57 else | |
| 58 echo 'Converting each file sequentially. Install "parallel" to convert in pa rallel.' | |
| 59 ls -1 $1/*.pdf | xargs experimental/PdfViewer/scripts/vm_pdf_viewer_run_one_ pdf.sh | |
| 60 fi | |
| 61 | |
| 62 # Next, compare to the old results. Exit now if there is no folder with old resu lts. | |
| 63 if [ ! -d $1/old ] | |
| 64 then | |
| 65 exit | |
| 66 fi | |
| 67 | |
| 68 # Check to make sure that skdiff has been built. | |
| 69 RELEASE_SKDIFF=out/Release/skdiff | |
| 70 DEBUG_SKDIFF=out/Debug/skdiff | |
| 71 if [ -f $RELEASE_SKDIFF ] | |
| 72 then | |
| 73 SKDIFF=$RELEASE_SKDIFF | |
| 74 elif [ -f $DEBUG_SKDIFF ] | |
| 75 then | |
| 76 SKDIFF=$DEBUG_SKDIFF | |
| 77 else | |
| 78 echo 'Build skdiff in order to do comparisons.' | |
| 79 exit | |
| 80 fi | |
| 81 | |
| 82 # Create the diff folder, after deleting old diffs if necessary. | |
| 83 if [ -d $1/d ] | |
| 84 then | |
| 85 rm -rf $1/d | |
| 86 fi | |
| 87 | |
| 88 mkdir $1/d | |
| 89 | |
| 90 $SKDIFF $1/old $1/new $1/d | |
| OLD | NEW |