Add a gyp define LIBYUV_DISABLE_JPEG to not build jpeg library
BUG=346
TESTED=set GYP_DEFINES=target_arch=ia32 libyuv_disable_jpeg=1 & python gyp_libyuv -fninja -G msvs_version=2010 libyuv_test.gyp
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/16989004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1038 16f28f9a-4ce2-e073-06de-1de4eb20be90
diff --git a/README.chromium b/README.chromium
index 38eb699..e58eb6f 100644
--- a/README.chromium
+++ b/README.chromium
@@ -1,6 +1,6 @@
 Name: libyuv
 URL: http://code.google.com/p/libyuv/
-Version: 1037
+Version: 1038
 License: BSD
 License File: LICENSE
 
diff --git a/include/libyuv/version.h b/include/libyuv/version.h
index ca1e7c8..1ab8c5c 100644
--- a/include/libyuv/version.h
+++ b/include/libyuv/version.h
@@ -11,6 +11,6 @@
 #ifndef INCLUDE_LIBYUV_VERSION_H_  // NOLINT
 #define INCLUDE_LIBYUV_VERSION_H_
 
-#define LIBYUV_VERSION 1037
+#define LIBYUV_VERSION 1038
 
 #endif  // INCLUDE_LIBYUV_VERSION_H_  NOLINT
diff --git a/libyuv.gyp b/libyuv.gyp
index cc4b0f8..246d662 100644
--- a/libyuv.gyp
+++ b/libyuv.gyp
@@ -12,6 +12,7 @@
   ],
   'variables': {
     'use_system_libjpeg%': 0,
+    'libyuv_disable_jpeg%': 0,
     'build_neon': 0,
     'conditions': [
        [ '(target_arch == "armv7" or target_arch == "armv7s" or (target_arch == "arm" and arm_version >= 7)) and target_subarch != 64 and (arm_neon == 1 or arm_neon_optional == 1)', {
@@ -71,8 +72,7 @@
             'LIBYUV_DISABLE_NEON'
           ],
         }],
-        # TODO(fbarchard): Use gyp define to enable jpeg.
-        [ 'OS != "ios"', {
+        [ 'OS != "ios" and libyuv_disable_jpeg != 1', {
           'defines': [
             'HAVE_JPEG'
           ],
diff --git a/libyuv_test.gyp b/libyuv_test.gyp
index ab04cde..140ba6c 100644
--- a/libyuv_test.gyp
+++ b/libyuv_test.gyp
@@ -7,6 +7,9 @@
 # be found in the AUTHORS file in the root of the source tree.
 
 {
+  'variables': {
+    'libyuv_disable_jpeg%': 0,
+  },
   'targets': [
     {
       'target_name': 'libyuv_unittest',
@@ -62,7 +65,7 @@
             'DEBUG_INFORMATION_FORMAT' : 'dwarf-with-dsym',
           },
         }],
-        [ 'OS != "ios"', {
+        [ 'OS != "ios" and libyuv_disable_jpeg != 1', {
           'defines': [
             'HAVE_JPEG',
           ],
@@ -116,22 +119,24 @@
         'util/psnr.cc',
         'util/ssim.cc',
       ],
+      'dependencies': [
+        'libyuv.gyp:libyuv',
+      ],
       'conditions': [
         [ 'OS == "ios" and target_subarch == 64', {
           'defines': [
             'LIBYUV_DISABLE_NEON'
           ],
         }],
-        [ 'OS != "ios"', {
+
+        [ 'OS != "ios" and libyuv_disable_jpeg != 1', {
           'defines': [
             'HAVE_JPEG',
           ],
         }],
       ], # conditions
-      'dependencies': [
-        'libyuv.gyp:libyuv',
-      ],
     },
+
     {
       'target_name': 'cpuid',
       'type': 'executable',
diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc
index d70a479..9948074 100644
--- a/unit_test/convert_test.cc
+++ b/unit_test/convert_test.cc
@@ -1253,4 +1253,12 @@
   free_aligned_buffer_64(src_y);
 }
 
+TEST_F(libyuvTest, HaveJPEG) {
+#ifdef HAVE_JPEG
+  printf("JPEG enabled\n.");
+#else
+  printf("JPEG disabled\n.");
+#endif
+}
+
 }  // namespace libyuv