Create new 'skia_os' variable to replace use of 'OS' in most places.
http://codereview.appspot.com/4627085



git-svn-id: http://skia.googlecode.com/svn/trunk@1782 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/CocoaDebuggerApp.gyp b/gyp/CocoaDebuggerApp.gyp
index 1960a67..e53dfbb 100644
--- a/gyp/CocoaDebuggerApp.gyp
+++ b/gyp/CocoaDebuggerApp.gyp
@@ -31,7 +31,7 @@
       ],
       'conditions' : [
         # Only supports Mac currently
-        ['OS == "mac"', {
+        ['skia_os == "mac"', {
           'sources': [
             '../experimental/CocoaDebugger/CocoaDebugger-Info.plist',
             '../experimental/CocoaDebugger/CocoaDebugger_Prefix.pch',
diff --git a/gyp/FileReaderApp.gyp b/gyp/FileReaderApp.gyp
index 2db992f..0e2c48f 100644
--- a/gyp/FileReaderApp.gyp
+++ b/gyp/FileReaderApp.gyp
@@ -30,7 +30,7 @@
       ],
       'conditions' : [
         # Only supports Mac currently
-        ['OS == "mac"', {
+        ['skia_os == "mac"', {
           'sources': [
             '../experimental/SimpleCocoaApp/SkNSWindow.mm',
             '../experimental/SimpleCocoaApp/SkNSView.mm',
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index 4e01526..0c4c04c 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -135,19 +135,19 @@
         'pdf.gyp:pdf',
       ],
       'conditions' : [
-       [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', {
+       [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
          'sources!': [
             '../samplecode/SampleDecode.cpp',
          ],
         }],
-        [ 'OS == "win"', {
+        [ 'skia_os == "win"', {
           'sources!': [
             # require UNIX functions
             '../samplecode/SampleEncode.cpp',
             '../samplecode/SamplePageFlip.cpp',
           ],
         }],
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'sources!': [
             '../samplecode/SampleDecode.cpp',
           ],
diff --git a/gyp/SimpleCocoaApp.gyp b/gyp/SimpleCocoaApp.gyp
index 9f415e4..ead9fe4 100644
--- a/gyp/SimpleCocoaApp.gyp
+++ b/gyp/SimpleCocoaApp.gyp
@@ -28,7 +28,7 @@
       ],
       'conditions' : [
         # Only supports Mac currently
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'sources': [
             '../include/utils/mac/SkCGUtils.h',
             '../src/utils/mac/SkCreateCGImageRef.cpp',
diff --git a/gyp/bench.gyp b/gyp/bench.gyp
index 11f0461..c57b51e 100644
--- a/gyp/bench.gyp
+++ b/gyp/bench.gyp
@@ -1,11 +1,5 @@
 # GYP file to build performance testbench.
 #
-# To build and run on Linux:
-#  ./gyp_skia bench.gyp && make
-#  out/Debug/bench -repeat 2
-#
-# Building on other platforms not tested yet.
-#
 {
   'includes': [
     'apptype_console.gypi',
@@ -53,13 +47,13 @@
         'utils.gyp:utils',
       ],
       'conditions': [
-        [ 'OS != "mac"', {
+        [ 'skia_os != "mac"', {
           'sources!': [
             '../bench/BenchSysTimer_mach.h',
             '../bench/BenchSysTimer_mach.cpp',
           ],
         }],
-        [ 'OS not in ["linux", "freebsd", "openbsd", "solaris"]', {
+        [ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris"]', {
           'sources!': [
             '../bench/BenchSysTimer_posix.h',
             '../bench/BenchSysTimer_posix.cpp',
@@ -71,13 +65,13 @@
             ],
           },
         }],
-        [ 'OS != "win"', {
+        [ 'skia_os != "win"', {
           'sources!': [
             '../bench/BenchSysTimer_windows.h',
             '../bench/BenchSysTimer_windows.cpp',
           ],
         }],
-        [ 'OS in ["win", "mac", "linux", "freebsd", "openbsd", "solaris"]', {
+        [ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris"]', {
           'sources!': [
             '../bench/BenchGpuTimer_none.h',
             '../bench/BenchGpuTimer_none.cpp',
diff --git a/gyp/common.gypi b/gyp/common.gypi
index d1f23d5..a9b0b53 100644
--- a/gyp/common.gypi
+++ b/gyp/common.gypi
@@ -12,13 +12,29 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 {
+  # Define all variables, allowing for override in GYP_DEFINES.
+  #
+  # One such variable is 'skia_os', which we use instead of 'OS' throughout
+  # our gyp files.  We set it automatically based on 'OS', but allow the
+  # user to override it via GYP_DEFINES if they like.
+  'variables': {
+    'skia_scalar%': 'float',
+    'skia_os%': '<(OS)',
+  },
+  'skia_scalar%': '<(skia_scalar)',
+  'skia_os': '<(skia_os)',
+
   'target_defaults': {
 
-    # Define variables, and allow for override in GYP_DEFINES environment var.
+    # Validate the 'skia_os' setting against 'OS', because only certain
+    # combinations work.  You should only override 'skia_os' for certain
+    # situations, like building for iOS on a Mac.
     'variables': {
-      'skia_scalar%': 'float',
+      'conditions': [
+        ['skia_os != OS and not (skia_os == "ios" and OS == "mac")',
+          {'error': '<!(Cannot build with skia_os=<(skia_os) on OS=<(OS))'}],
+      ],
     },
-    'skia_scalar%': '<(skia_scalar)',
 
     'configurations': {
       'Debug': {
@@ -51,7 +67,7 @@
         }
       ],
 
-      ['OS == "win"',
+      ['skia_os == "win"',
         {
           'defines': [
             'SK_BUILD_FOR_WIN32',
@@ -101,7 +117,7 @@
         },
       ],
 
-      ['OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', 
+      ['skia_os in ["linux", "freebsd", "openbsd", "solaris"]',
         {
           'defines': [
             'SK_SAMPLES_FOR_X',
@@ -122,7 +138,7 @@
         },
       ],
 
-      ['OS == "mac"', 
+      ['skia_os == "mac"', 
         {
           'defines': [
             'SK_BUILD_FOR_MAC',
diff --git a/gyp/core.gyp b/gyp/core.gyp
index 34d05c3..51d3066 100644
--- a/gyp/core.gyp
+++ b/gyp/core.gyp
@@ -254,7 +254,7 @@
       ],
       'msvs_disabled_warnings': [4244, 4267,4345, 4390, 4554, 4800],
       'conditions': [
-        [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'cflags': [
             '-Wno-unused',
             '-Wno-unused-function',
@@ -275,7 +275,7 @@
             ],
           },
         }],
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'include_dirs': [
             '../include/utils/mac',
           ],
@@ -296,7 +296,7 @@
             ],
           },
         }],
-        [ 'OS == "win"', {
+        [ 'skia_os == "win"', {
           'include_dirs': [
             'config/win',
           ],
@@ -308,7 +308,7 @@
             '../src/ports/SkDebug_stdio.cpp',
           ],
         }],
-        [ 'OS != "win"', {
+        [ 'skia_os != "win"', {
           'sources!': [
             '../src/ports/SkDebug_win.cpp',
             '../src/ports/SkTime_win.cpp',
diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp
index 787e0fc..04231c1 100644
--- a/gyp/gpu.gyp
+++ b/gyp/gpu.gyp
@@ -28,17 +28,17 @@
         '../src/gpu/SkGrTexturePixelRef.cpp',
       ],
       'conditions': [
-          [ 'OS == "linux"', {
+          [ 'skia_os == "linux"', {
           'defines': [
               'GR_LINUX_BUILD=1',
           ],
           }],
-          [ 'OS == "mac"', {
+          [ 'skia_os == "mac"', {
           'defines': [
               'GR_MAC_BUILD=1',
           ],
           }],
-          [ 'OS == "win"', {
+          [ 'skia_os == "win"', {
           'defines': [
               'GR_WIN32_BUILD=1',
           ],
@@ -46,17 +46,17 @@
       ],
       'direct_dependent_settings': {
         'conditions': [
-          [ 'OS == "linux"', {
+          [ 'skia_os == "linux"', {
             'defines': [
               'GR_LINUX_BUILD=1',
             ],
           }],
-          [ 'OS == "mac"', {
+          [ 'skia_os == "mac"', {
             'defines': [
               'GR_MAC_BUILD=1',
             ],
           }],
-          [ 'OS == "win"', {
+          [ 'skia_os == "win"', {
             'defines': [
               'GR_WIN32_BUILD=1',
             ],
@@ -197,7 +197,7 @@
         'GR_IMPLEMENTATION=1',
       ],
       'conditions': [
-        [ 'OS == "linux"', {
+        [ 'skia_os == "linux"', {
           'defines': [
               'GR_LINUX_BUILD=1',
           ],
@@ -211,7 +211,7 @@
             ],
           },
         }],
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'defines': [
               'GR_MAC_BUILD=1',
           ],
@@ -224,7 +224,7 @@
             '../gpu/src/GrGLDefaultInterface_none.cpp',
           ],
           }],
-        [ 'OS == "win"', {
+        [ 'skia_os == "win"', {
           'defines': [
             'GR_WIN32_BUILD=1',
             'GR_GL_FUNCTION_TYPE=__stdcall',
@@ -233,17 +233,17 @@
             '../gpu/src/GrGLDefaultInterface_none.cpp',
           ],
         }],
-        [ 'OS != "win"', {
+        [ 'skia_os != "win"', {
           'sources!': [
             '../gpu/src/win/GrGLDefaultInterface_win.cpp',
           ],
         }],
-        [ 'OS != "mac"', {
+        [ 'skia_os != "mac"', {
           'sources!': [
             '../gpu/src/mac/GrGLDefaultInterface_mac.cpp',
           ],
         }],
-        [ 'OS != "linux"', {
+        [ 'skia_os != "linux"', {
           'sources!': [
             '../gpu/src/unix/GrGLDefaultInterface_unix.cpp',
           ],
@@ -251,17 +251,17 @@
       ],
       'direct_dependent_settings': {
         'conditions': [
-          [ 'OS == "linux"', {
+          [ 'skia_os == "linux"', {
             'defines': [
               'GR_LINUX_BUILD=1',
             ],
           }],
-          [ 'OS == "mac"', {
+          [ 'skia_os == "mac"', {
             'defines': [
               'GR_MAC_BUILD=1',
             ],
           }],
-          [ 'OS == "win"', {
+          [ 'skia_os == "win"', {
             'defines': [
               'GR_WIN32_BUILD=1',
               'GR_GL_FUNCTION_TYPE=__stdcall',
diff --git a/gyp/images.gyp b/gyp/images.gyp
index 9627d3f..b50dd34 100644
--- a/gyp/images.gyp
+++ b/gyp/images.gyp
@@ -55,7 +55,7 @@
         '../src/ports/SkImageDecoder_WIC.cpp',
       ],
       'conditions': [
-        [ 'OS == "win"', {
+        [ 'skia_os == "win"', {
           'sources!': [
             '../include/images/SkJpegUtility.h',
 
@@ -69,12 +69,12 @@
             '../src/images/SkJpegUtility.cpp',
             '../src/images/SkMovie_gif.cpp',
           ],
-        },{ #else if OS != win
+        },{ #else if skia_os != win
           'sources!': [
             '../src/ports/SkImageDecoder_WIC.cpp',
           ],
         }],
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'sources!': [
             '../include/images/SkJpegUtility.h',
 
@@ -87,12 +87,12 @@
             '../src/images/SkJpegUtility.cpp',
             '../src/images/SkMovie_gif.cpp',
           ],
-        },{ #else if OS != mac
+        },{ #else if skia_os != mac
           'sources!': [
             '../src/ports/SkImageDecoder_CG.cpp',
           ],
         }],
-        [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'sources!': [
             '../include/images/SkJpegUtility.h',
 
diff --git a/gyp/opts.gyp b/gyp/opts.gyp
index 42fb8ae..e63b1cb 100644
--- a/gyp/opts.gyp
+++ b/gyp/opts.gyp
@@ -30,7 +30,7 @@
         '../src/core',
       ],
       'conditions': [
-        [ '(OS == "linux" or OS == "freebsd" or OS == "openbsd")', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'cflags': [
             '-msse2',
           ],
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index 950f803..e768a7e 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -93,7 +93,7 @@
           '../src/utils/SDL/SkOSWindow_SDL.cpp',
       ],
       'conditions': [
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'sources!': [
             '../src/utils/SkEGLContext_none.cpp',
           ],
@@ -107,7 +107,7 @@
               '../include/utils/mac',
             ],
           },
-        },{ #else if 'OS != "mac"'
+        },{ #else if 'skia_os != "mac"'
           'include_dirs!': [
             '../include/utils/mac',
           ],
@@ -119,7 +119,7 @@
             '../src/utils/mac/SkOSWindow_Mac.cpp',
           ],
         }],
-        [ 'OS in ["linux", "freebsd", "openbsd", "solaris"]', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'sources!': [
             '../src/utils/SkEGLContext_none.cpp',
           ],
@@ -129,7 +129,7 @@
               '-lGLU',
             ],
           },
-        },{ #else if 'OS not in ["linux", "freebsd", "openbsd", "solaris"]'
+        },{ #else if 'skia_os not in ["linux", "freebsd", "openbsd", "solaris"]'
           'include_dirs!': [
             '../include/utils/unix',
           ],
@@ -139,7 +139,7 @@
             '../src/utils/unix/SkOSWindow_Unix.cpp',
           ],
         }],
-        [ 'OS == "win"', {
+        [ 'skia_os == "win"', {
           'sources!': [
             '../src/utils/SkEGLContext_none.cpp',
           ],
@@ -148,7 +148,7 @@
               '../include/utils/win',
             ],
           },
-        },{ #else if 'OS != "win"'
+        },{ #else if 'skia_os != "win"'
           'include_dirs!': [
             '../include/utils/win',
           ],
diff --git a/gyp/views.gyp b/gyp/views.gyp
index 4afa2af..096a888 100644
--- a/gyp/views.gyp
+++ b/gyp/views.gyp
@@ -73,7 +73,7 @@
         '../src/views/SkListWidget.cpp', #depends on missing SkListSource implementation
       ],
       'conditions': [
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'link_settings': {
             'libraries': [
               '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
@@ -81,7 +81,7 @@
             ],
           },
         }],
-        [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd" or OS == "solaris"', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'sources': [
             '../unix_test_app/main.cpp',
           ],
diff --git a/gyp/xml.gyp b/gyp/xml.gyp
index 464a2a5..5c9edb2 100644
--- a/gyp/xml.gyp
+++ b/gyp/xml.gyp
@@ -33,7 +33,7 @@
           '../src/xml/SkXMLPullParser.cpp', #if 0 around class decl in header
       ],
       'conditions': [
-        [ 'OS == "win" or OS == "mac" or OS == "linux" or OS == "openbsd" or OS == "solaris"', {
+        [ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris"]', {
           'sources!': [
             # no jsapi.h by default on system
             '../include/xml/SkJS.h',
diff --git a/gyp/zlib.gyp b/gyp/zlib.gyp
index 44a8d2a..7665505 100644
--- a/gyp/zlib.gyp
+++ b/gyp/zlib.gyp
@@ -16,7 +16,7 @@
         '../src/core/SkFlate.cpp',
       ],
       'conditions': [
-        [ 'OS == "mac"', {
+        [ 'skia_os == "mac"', {
           'link_settings': {
             'libraries': [
               '$(SDKROOT)/usr/lib/libz.dylib',
@@ -24,7 +24,7 @@
           },
           'defines': [ 'SK_ZLIB_INCLUDE=<zlib.h>', ],
         }],
-        [ 'OS == "linux"', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'link_settings': { 'libraries': [ '-lz', ], },
           'defines': [ 'SK_ZLIB_INCLUDE=<zlib.h>', ],
         }],