public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools: Add --version option in Brotli and BrotliCompress
@ 2017-04-07  8:50 Song, BinX
  0 siblings, 0 replies; 3+ messages in thread
From: Song, BinX @ 2017-04-07  8:50 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Gao, Liming

https://bugzilla.tianocore.org/show_bug.cgi?id=464
- Add --version option in Brotli and BrotliCompress

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bell Song <binx.song@intel.com>
---
 BaseTools/BinWrappers/PosixLike/BrotliCompress       | 3 +++
 BaseTools/Source/C/BrotliCompress/BrotliCompress.bat | 6 ++++++
 BaseTools/Source/C/BrotliCompress/tools/bro.c        | 8 +++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/BaseTools/BinWrappers/PosixLike/BrotliCompress b/BaseTools/BinWrappers/PosixLike/BrotliCompress
index 59c6465..f7a2079 100755
--- a/BaseTools/BinWrappers/PosixLike/BrotliCompress
+++ b/BaseTools/BinWrappers/PosixLike/BrotliCompress
@@ -32,6 +32,9 @@ while [ $# != 0 ];do
       ARGS+="--output $2 "
       shift
     ;;
+    --version)
+      ARGS+="$1 "
+    ;;
     *)
       ARGS+="--input $1 "
   esac
diff --git a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
index 257bf1e..5949782 100644
--- a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
+++ b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
@@ -52,6 +52,12 @@ if "%1"=="-o" (
   goto Begin
 )
 
+if "%1"=="--version" (
+  set ARGS=%ARGS% %1
+  shift
+  goto Begin
+)
+
 set ARGS=%ARGS% --input %1
 shift
 goto Begin
diff --git a/BaseTools/Source/C/BrotliCompress/tools/bro.c b/BaseTools/Source/C/BrotliCompress/tools/bro.c
index 2fa9f05..df54738 100644
--- a/BaseTools/Source/C/BrotliCompress/tools/bro.c
+++ b/BaseTools/Source/C/BrotliCompress/tools/bro.c
@@ -67,6 +67,8 @@ static int ParseQuality(const char* s, int* quality) {
   return 0;
 }
 
+#define BRO_VER  "0.5.2"
+
 static void ParseArgv(int argc, char **argv,
                       char **input_path,
                       char **output_path,
@@ -110,6 +112,9 @@ static void ParseArgv(int argc, char **argv,
       }
       *verbose = 1;
       continue;
+    } else if (!strcmp("--version", argv[k])) {
+      fprintf(stderr, "Brotli Version %s\n", BRO_VER);
+      exit(1);
     }
     if (k < argc - 1) {
       if (!strcmp("--input", argv[k]) ||
@@ -177,7 +182,8 @@ error:
   fprintf(stderr,
           "Usage: %s [--force] [--quality n] [--gap n] [--decompress]"
           " [--input filename] [--output filename] [--repeat iters]"
-          " [--verbose] [--window n] [--custom-dictionary filename]\n",
+          " [--verbose] [--window n] [--custom-dictionary filename]"
+          " [--version]\n",
           argv[0]);
   exit(1);
 }
-- 
2.10.2.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] BaseTools: Add --version option in Brotli and BrotliCompress
@ 2017-04-13  1:19 Song, BinX
  2017-04-13  6:34 ` Gao, Liming
  0 siblings, 1 reply; 3+ messages in thread
From: Song, BinX @ 2017-04-13  1:19 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

https://bugzilla.tianocore.org/show_bug.cgi?id=464
V2:
- Add build version

V1:
- Add --version option in Brotli and BrotliCompress

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bell Song <binx.song@intel.com>
---
 BaseTools/BinWrappers/PosixLike/BrotliCompress     | 29 ++++++++++++++-------
 .../Source/C/BrotliCompress/BrotliCompress.bat     | 30 +++++++++++++---------
 BaseTools/Source/C/BrotliCompress/tools/bro.c      | 18 ++++++++++++-
 3 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/BaseTools/BinWrappers/PosixLike/BrotliCompress b/BaseTools/BinWrappers/PosixLike/BrotliCompress
index 59c6465..49358b2 100755
--- a/BaseTools/BinWrappers/PosixLike/BrotliCompress
+++ b/BaseTools/BinWrappers/PosixLike/BrotliCompress
@@ -11,32 +11,43 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
-LVL="--quality 9"
+QLT="-q 9"
+INPUTFLAG=0
 
 while [ $# != 0 ];do
   case $1 in
     -d)
-      ARGS+="--decompress "
+      INPUTFLAG=1
+      ARGS+="$1 "
     ;;
     -e)
+      INPUTFLAG=1
     ;;
     -g)
-      ARGS+="--gap $2 "
+      ARGS+="$1 $2 "
       shift
     ;;
-    -l)
-      LVL="--quality $2 "
+    -o)
+      ARGS+="$1 $2 "
       shift
     ;;
-    -o)
-      ARGS+="--output $2 "
+    -q)
+      QLT="$1 $2 "
       shift
     ;;
     *)
-      ARGS+="--input $1 "
+      if [ $INPUTFLAG -eq 1 ]
+      then
+        if [ -z $2 ]
+          then
+            ARGS+="$QLT -i $1 "
+            break;
+        fi
+      fi
+      ARGS+="$1 "
   esac
 
 shift
 done
 
-exec Brotli $ARGS $LVL
+exec Brotli $ARGS
diff --git a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
index 257bf1e..b291ff0 100644
--- a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
+++ b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
@@ -14,48 +14,54 @@
 @echo off
 @setlocal
 
-set LVL=--quality 9
+set QLT=-q 9
+set INPUTFLAG=0
 
 :Begin
 if "%1"=="" goto End
 
 if "%1"=="-d" (
-  set ARGS=%ARGS% --decompress
-  shift
-  goto Begin
+  set INPUTFLAG=1
 )
 
 if "%1"=="-e" (
+  set INPUTFLAG=1
   shift
   goto Begin
 )
 
 if "%1"=="-g" (
-  set ARGS=%ARGS% --gap %2
+  set ARGS=%ARGS% %1 %2
   shift
   shift
   goto Begin
 )
 
-if "%1"=="-l" (
-  set LVL=--quality %2
+if "%1"=="-o" (
+  set ARGS=%ARGS% %1 %2
   shift
   shift
   goto Begin
 )
 
-if "%1"=="-o" (
-  set ARGS=%ARGS% --output %2
-  set INTMP=%2
+if "%1"=="-q" (
+  set QLT=%1 %2
   shift
   shift
   goto Begin
 )
 
-set ARGS=%ARGS% --input %1
+if %INPUTFLAG%==1 (
+ if "%2"=="" (
+    set ARGS=%ARGS% %QLT% -i %1
+    goto End
+  )
+)
+
+set ARGS=%ARGS% %1
 shift
 goto Begin
 
 :End
-Brotli %ARGS% %LVL%
+Brotli %ARGS%
 @echo on
diff --git a/BaseTools/Source/C/BrotliCompress/tools/bro.c b/BaseTools/Source/C/BrotliCompress/tools/bro.c
index 2fa9f05..ef4592d 100644
--- a/BaseTools/Source/C/BrotliCompress/tools/bro.c
+++ b/BaseTools/Source/C/BrotliCompress/tools/bro.c
@@ -13,6 +13,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <time.h>
+#include <Common/BuildVersion.h>
 
 #include "../dec/decode.h"
 #include "../enc/encode.h"
@@ -67,6 +68,11 @@ static int ParseQuality(const char* s, int* quality) {
   return 0;
 }
 
+#define UTILITY_NAME          "Brotli"
+#define UTILITY_MAJOR_VERSION 0
+#define UTILITY_MINOR_VERSION 5
+#define UTILITY_REVERSION     2
+
 static void ParseArgv(int argc, char **argv,
                       char **input_path,
                       char **output_path,
@@ -110,6 +116,15 @@ static void ParseArgv(int argc, char **argv,
       }
       *verbose = 1;
       continue;
+    } else if (!strcmp("--version", argv[k])) {
+      fprintf(stderr,
+              "%s Version %d.%d.%d %s\n",
+              UTILITY_NAME,
+              UTILITY_MAJOR_VERSION,
+              UTILITY_MINOR_VERSION,
+              UTILITY_REVERSION,
+              __BUILD_VERSION);
+      exit(1);
     }
     if (k < argc - 1) {
       if (!strcmp("--input", argv[k]) ||
@@ -177,7 +192,8 @@ error:
   fprintf(stderr,
           "Usage: %s [--force] [--quality n] [--gap n] [--decompress]"
           " [--input filename] [--output filename] [--repeat iters]"
-          " [--verbose] [--window n] [--custom-dictionary filename]\n",
+          " [--verbose] [--window n] [--custom-dictionary filename]"
+          " [--version]\n",
           argv[0]);
   exit(1);
 }
-- 
2.10.2.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] BaseTools: Add --version option in Brotli and BrotliCompress
  2017-04-13  1:19 [PATCH] BaseTools: Add --version option in Brotli and BrotliCompress Song, BinX
@ 2017-04-13  6:34 ` Gao, Liming
  0 siblings, 0 replies; 3+ messages in thread
From: Gao, Liming @ 2017-04-13  6:34 UTC (permalink / raw)
  To: Song, BinX, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Song, BinX
>Sent: Thursday, April 13, 2017 9:20 AM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
><yonghong.zhu@intel.com>
>Subject: [PATCH] BaseTools: Add --version option in Brotli and BrotliCompress
>
>https://bugzilla.tianocore.org/show_bug.cgi?id=464
>V2:
>- Add build version
>
>V1:
>- Add --version option in Brotli and BrotliCompress
>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Bell Song <binx.song@intel.com>
>---
> BaseTools/BinWrappers/PosixLike/BrotliCompress     | 29 ++++++++++++++--
>-----
> .../Source/C/BrotliCompress/BrotliCompress.bat     | 30 +++++++++++++------
>---
> BaseTools/Source/C/BrotliCompress/tools/bro.c      | 18 ++++++++++++-
> 3 files changed, 55 insertions(+), 22 deletions(-)
>
>diff --git a/BaseTools/BinWrappers/PosixLike/BrotliCompress
>b/BaseTools/BinWrappers/PosixLike/BrotliCompress
>index 59c6465..49358b2 100755
>--- a/BaseTools/BinWrappers/PosixLike/BrotliCompress
>+++ b/BaseTools/BinWrappers/PosixLike/BrotliCompress
>@@ -11,32 +11,43 @@
> # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
>BASIS,
> # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
>EXPRESS OR IMPLIED.
> #
>-LVL="--quality 9"
>+QLT="-q 9"
>+INPUTFLAG=0
>
> while [ $# != 0 ];do
>   case $1 in
>     -d)
>-      ARGS+="--decompress "
>+      INPUTFLAG=1
>+      ARGS+="$1 "
>     ;;
>     -e)
>+      INPUTFLAG=1
>     ;;
>     -g)
>-      ARGS+="--gap $2 "
>+      ARGS+="$1 $2 "
>       shift
>     ;;
>-    -l)
>-      LVL="--quality $2 "
>+    -o)
>+      ARGS+="$1 $2 "
>       shift
>     ;;
>-    -o)
>-      ARGS+="--output $2 "
>+    -q)
>+      QLT="$1 $2 "
>       shift
>     ;;
>     *)
>-      ARGS+="--input $1 "
>+      if [ $INPUTFLAG -eq 1 ]
>+      then
>+        if [ -z $2 ]
>+          then
>+            ARGS+="$QLT -i $1 "
>+            break;
>+        fi
>+      fi
>+      ARGS+="$1 "
>   esac
>
> shift
> done
>
>-exec Brotli $ARGS $LVL
>+exec Brotli $ARGS
>diff --git a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
>b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
>index 257bf1e..b291ff0 100644
>--- a/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
>+++ b/BaseTools/Source/C/BrotliCompress/BrotliCompress.bat
>@@ -14,48 +14,54 @@
> @echo off
> @setlocal
>
>-set LVL=--quality 9
>+set QLT=-q 9
>+set INPUTFLAG=0
>
> :Begin
> if "%1"=="" goto End
>
> if "%1"=="-d" (
>-  set ARGS=%ARGS% --decompress
>-  shift
>-  goto Begin
>+  set INPUTFLAG=1
> )
>
> if "%1"=="-e" (
>+  set INPUTFLAG=1
>   shift
>   goto Begin
> )
>
> if "%1"=="-g" (
>-  set ARGS=%ARGS% --gap %2
>+  set ARGS=%ARGS% %1 %2
>   shift
>   shift
>   goto Begin
> )
>
>-if "%1"=="-l" (
>-  set LVL=--quality %2
>+if "%1"=="-o" (
>+  set ARGS=%ARGS% %1 %2
>   shift
>   shift
>   goto Begin
> )
>
>-if "%1"=="-o" (
>-  set ARGS=%ARGS% --output %2
>-  set INTMP=%2
>+if "%1"=="-q" (
>+  set QLT=%1 %2
>   shift
>   shift
>   goto Begin
> )
>
>-set ARGS=%ARGS% --input %1
>+if %INPUTFLAG%==1 (
>+ if "%2"=="" (
>+    set ARGS=%ARGS% %QLT% -i %1
>+    goto End
>+  )
>+)
>+
>+set ARGS=%ARGS% %1
> shift
> goto Begin
>
> :End
>-Brotli %ARGS% %LVL%
>+Brotli %ARGS%
> @echo on
>diff --git a/BaseTools/Source/C/BrotliCompress/tools/bro.c
>b/BaseTools/Source/C/BrotliCompress/tools/bro.c
>index 2fa9f05..ef4592d 100644
>--- a/BaseTools/Source/C/BrotliCompress/tools/bro.c
>+++ b/BaseTools/Source/C/BrotliCompress/tools/bro.c
>@@ -13,6 +13,7 @@
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <time.h>
>+#include <Common/BuildVersion.h>
>
> #include "../dec/decode.h"
> #include "../enc/encode.h"
>@@ -67,6 +68,11 @@ static int ParseQuality(const char* s, int* quality) {
>   return 0;
> }
>
>+#define UTILITY_NAME          "Brotli"
>+#define UTILITY_MAJOR_VERSION 0
>+#define UTILITY_MINOR_VERSION 5
>+#define UTILITY_REVERSION     2
>+
> static void ParseArgv(int argc, char **argv,
>                       char **input_path,
>                       char **output_path,
>@@ -110,6 +116,15 @@ static void ParseArgv(int argc, char **argv,
>       }
>       *verbose = 1;
>       continue;
>+    } else if (!strcmp("--version", argv[k])) {
>+      fprintf(stderr,
>+              "%s Version %d.%d.%d %s\n",
>+              UTILITY_NAME,
>+              UTILITY_MAJOR_VERSION,
>+              UTILITY_MINOR_VERSION,
>+              UTILITY_REVERSION,
>+              __BUILD_VERSION);
>+      exit(1);
>     }
>     if (k < argc - 1) {
>       if (!strcmp("--input", argv[k]) ||
>@@ -177,7 +192,8 @@ error:
>   fprintf(stderr,
>           "Usage: %s [--force] [--quality n] [--gap n] [--decompress]"
>           " [--input filename] [--output filename] [--repeat iters]"
>-          " [--verbose] [--window n] [--custom-dictionary filename]\n",
>+          " [--verbose] [--window n] [--custom-dictionary filename]"
>+          " [--version]\n",
>           argv[0]);
>   exit(1);
> }
>--
>2.10.2.windows.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-13  6:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-13  1:19 [PATCH] BaseTools: Add --version option in Brotli and BrotliCompress Song, BinX
2017-04-13  6:34 ` Gao, Liming
  -- strict thread matches above, loose matches on Subject: below --
2017-04-07  8:50 Song, BinX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox