]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Update BrotliCompress script to handle the different input format
authorLiming Gao <liming.gao@intel.com>
Fri, 8 Dec 2017 04:39:13 +0000 (12:39 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 12 Dec 2017 10:01:10 +0000 (18:01 +0800)
After this update, BrotliCompress can support below styles.
BrotliCompress -e InputFile -o OutputFile
BrotliCompress -e -o OutputFile InputFile

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/BinWrappers/PosixLike/BrotliCompress
BaseTools/Source/C/BrotliCompress/BrotliCompress.bat

index ca32d6a55c288db72391bdfc65aa4c1af240d6c7..6e4c8c992e03bd31a5773f3a0c5b8fbcd970ec45 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# This script will exec Brotli tool.
+# This script will exec Brotli tool with -e/-d options.
 #
 # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 #
 QLT="-q 9"
 INPUTFLAG=0
+ARGS=
 
-for arg; do
-  if [ $1 = -d ]
-    then
+while test $# -gt 0
+do
+  case $1 in
+    -e)
       INPUTFLAG=1
-  fi
-  if [ $1 = -e ]
-    then
+      ;;
+    -d)
       INPUTFLAG=1
-      shift
-      continue;
-  fi
-  if [ $1 = -g ]
-    then
-      ARGS+="$1 $2 "
-      shift
-      shift
-      continue;
-  fi
-  if [ $1 = -o ]
-    then
+      ARGS+="$1 "
+      ;;
+    -o|-g)
       ARGS+="$1 $2 "
       shift
-      shift
-      continue;
-  fi
-  if [ $1 = -q ]
-    then
+      ;;
+    -q)
       QLT="$1 $2 "
       shift
-      shift
-      continue;
-  fi
-  if [ $INPUTFLAG -eq 1 ]
-    then
-      if [ -z $2 ]
+      ;;
+    *)
+      if [ $INPUTFLAG -eq 1 ]
         then
-          ARGS+="$QLT -i $1 "
-          break;
+          ARGS+="-i $1 "
+          INPUTFLAG=0
+        else
+          ARGS+="$1 "
       fi
-  fi
-
-ARGS+="$1 "
-shift
+      ;;
+  esac
+  shift
 done
 
-exec Brotli $ARGS
+exec Brotli $ARGS $QLT
index b291ff07f89e6b252fc8df8441c017f1e370aaad..b1b4985816755d4e8a406a288c9234754c676f5b 100644 (file)
 \r
 set QLT=-q 9\r
 set INPUTFLAG=0\r
+set ARGS=\r
 \r
 :Begin\r
 if "%1"=="" goto End\r
 \r
 if "%1"=="-d" (\r
   set INPUTFLAG=1\r
+  set ARGS=%ARGS% %1\r
+  shift\r
+  goto Begin\r
 )\r
 \r
 if "%1"=="-e" (\r
@@ -51,17 +55,15 @@ if "%1"=="-q" (
   goto Begin\r
 )\r
 \r
-if %INPUTFLAG%==1 (\r
- if "%2"=="" (\r
-    set ARGS=%ARGS% %QLT% -i %1\r
-    goto End\r
-  )\r
+if %INPUTFLAG% == 1 (\r
+  set ARGS=%ARGS% -i %1\r
+  set INPUTFLAG=0\r
+) else (\r
+  set ARGS=%ARGS% %1\r
 )\r
-\r
-set ARGS=%ARGS% %1\r
 shift\r
 goto Begin\r
 \r
 :End\r
-Brotli %ARGS%\r
+Brotli %ARGS% %QLT%\r
 @echo on\r