From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A0FA921B02851 for ; Thu, 7 Dec 2017 20:34:54 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 20:39:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,376,1508828400"; d="scan'208";a="185161729" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.15]) by fmsmga006.fm.intel.com with ESMTP; 07 Dec 2017 20:39:27 -0800 From: Liming Gao To: edk2-devel@lists.01.org Date: Fri, 8 Dec 2017 12:39:13 +0800 Message-Id: <1512707953-13216-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [Patch] BaseTools: Update BrotliCompress script to handle the different input format X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Dec 2017 04:34:54 -0000 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 --- BaseTools/BinWrappers/PosixLike/BrotliCompress | 61 +++++++++------------- .../Source/C/BrotliCompress/BrotliCompress.bat | 18 ++++--- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/BaseTools/BinWrappers/PosixLike/BrotliCompress b/BaseTools/BinWrappers/PosixLike/BrotliCompress index ca32d6a..6e4c8c9 100755 --- a/BaseTools/BinWrappers/PosixLike/BrotliCompress +++ b/BaseTools/BinWrappers/PosixLike/BrotliCompress @@ -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.
# This program and the accompanying materials @@ -13,50 +13,37 @@ # 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 diff --git a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat index b291ff0..b1b4985 100644 --- a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat +++ b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat @@ -16,12 +16,16 @@ set QLT=-q 9 set INPUTFLAG=0 +set ARGS= :Begin if "%1"=="" goto End if "%1"=="-d" ( set INPUTFLAG=1 + set ARGS=%ARGS% %1 + shift + goto Begin ) if "%1"=="-e" ( @@ -51,17 +55,15 @@ if "%1"=="-q" ( goto Begin ) -if %INPUTFLAG%==1 ( - if "%2"=="" ( - set ARGS=%ARGS% %QLT% -i %1 - goto End - ) +if %INPUTFLAG% == 1 ( + set ARGS=%ARGS% -i %1 + set INPUTFLAG=0 +) else ( + set ARGS=%ARGS% %1 ) - -set ARGS=%ARGS% %1 shift goto Begin :End -Brotli %ARGS% +Brotli %ARGS% %QLT% @echo on -- 2.8.0.windows.1