bug 1315231 - fix gyp build on windows. r=franziskus
authorTed Mielczarek <ted@mielczarek.org>
Wed, 09 Nov 2016 15:25:07 -0500
changeset 12849 b494653e5be595f23348acc59cf9f90841a2c5a8
parent 12848 9a92823fa11da6625a75c28c673f3a50fd0d1fcb
child 12850 881e0bc1e1db09db0504a20d05542dcf45a140f0
push id1774
push usertmielczarek@mozilla.com
push dateMon, 14 Nov 2016 11:27:42 +0000
reviewersfranziskus
bugs1315231
bug 1315231 - fix gyp build on windows. r=franziskus
build.sh
coreconf/check_cc_clang.py
coreconf/config.gypi
coreconf/shlibsign.py
lib/freebl/freebl.gyp
nss.gyp
--- a/build.sh
+++ b/build.sh
@@ -104,17 +104,16 @@ done
 
 if [ "$opt_build" = "1" ]; then
     target=Release
     nspr_opt+=(--disable-debug --enable-optimize)
 else
     target=Debug
 fi
 if [ "$build_64" == "1" ]; then
-    target="${target}_x64"
     nspr_opt+=(--enable-64bit)
 else
     gyp_params+=(-Dtarget_arch=ia32)
     nspr_opt+=(--enable-x32)
 fi
 
 # check if we have to rebuild gyp
 if [ "$params" != "$(cat $cwd/out/config 2>/dev/null)" -o "$rebuild_gyp" == 1 -o "$clean" == 1 ]; then
--- a/coreconf/check_cc_clang.py
+++ b/coreconf/check_cc_clang.py
@@ -1,12 +1,16 @@
 #!/usr/bin/env python
 
 import os
 import subprocess
+import sys
 
 def main():
-    cc = os.environ.get('CC', 'cc')
-    cc_is_clang = 'clang' in subprocess.check_output([cc, '--version'])
-    print int(cc_is_clang)
+    if sys.platform == 'win32':
+        print 0
+    else:
+        cc = os.environ.get('CC', 'cc')
+        cc_is_clang = 'clang' in subprocess.check_output([cc, '--version'])
+        print int(cc_is_clang)
 
 if __name__ == '__main__':
     main()
--- a/coreconf/config.gypi
+++ b/coreconf/config.gypi
@@ -210,17 +210,17 @@
             'SubSystem': '2',
           },
         },
       }],
     ],
     'default_configuration': 'Debug',
     'configurations': {
       # Common settings for Debug+Release should go here.
-      'Common_Base': {
+      'Common': {
         'abstract': 1,
         'defines': [
           'NSS_NO_INIT_SUPPORT',
           'USE_UTIL_DIRECTLY',
           'NO_NSPR_10_SUPPORT',
           'SSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES',
         ],
         'msvs_configuration_attributes': {
@@ -374,66 +374,64 @@
               '-w44267', # Disable C4267: conversion from 'size_t' to 'type', possible loss of data
               '-w44244', # Disable C4244: conversion from 'type1' to 'type2', possible loss of data
               '-w44018', # Disable C4018: 'expression' : signed/unsigned mismatch
               '-w44312', # Disable C4312: 'type cast': conversion from 'type1' to 'type2' of greater size
             ],
             'conditions': [
               [ 'disable_werror==0', {
                 'cflags': ['-WX']
-              }]
+              }],
+              [ 'target_arch=="ia32"', {
+                'msvs_configuration_platform': 'Win32',
+                'msvs_settings': {
+                  'VCLinkerTool': {
+                    'MinimumRequiredVersion': '5.01',  # XP.
+                    'TargetMachine': '1',
+                    'ImageHasSafeExceptionHandlers': 'false',
+                  },
+                  'VCCLCompilerTool': {
+                    'PreprocessorDefinitions': [
+                      'WIN32',
+                    ],
+                  },
+                },
+
+              }],
+              [ 'target_arch=="x64"', {
+                'msvs_configuration_platform': 'x64',
+                'msvs_settings': {
+                  'VCLinkerTool': {
+                    'TargetMachine': '17', # x86-64
+                  },
+                  'VCCLCompilerTool': {
+                    'PreprocessorDefinitions': [
+                      'WIN64',
+                      '_AMD64_',
+                    ],
+                  },
+                },
+              }],
             ],
           }],
           [ 'disable_dbm==1', {
             'defines': [
               'NSS_DISABLE_DBM',
             ],
           }],
           [ 'disable_libpkix==1', {
             'defines': [
               'NSS_DISABLE_LIBPKIX',
             ],
           }],
         ],
       },
-      # Common settings for x86 should go here.
-      'x86_Base': {
-        'abstract': 1,
-        'msvs_settings': {
-          'VCLinkerTool': {
-            'MinimumRequiredVersion': '5.01',  # XP.
-            'TargetMachine': '1',
-          },
-          'VCCLCompilerTool': {
-            'PreprocessorDefinitions': [
-              'WIN32',
-            ],
-          },
-        },
-        'msvs_configuration_platform': 'Win32',
-      },
-      # Common settings for x86-64 should go here.
-      'x64_Base': {
-        'abstract': 1,
-        'msvs_configuration_platform': 'x64',
-        'msvs_settings': {
-          'VCLinkerTool': {
-            'TargetMachine': '17', # x86-64
-          },
-          'VCCLCompilerTool': {
-            'PreprocessorDefinitions': [
-              'WIN64',
-              '_AMD64_',
-            ],
-          },
-        },
-      },
       # Common settings for debug should go here.
-      'Debug_Base': {
-        'abstract': 1,
+      'Debug': {
+        'inherit_from': ['Common'],
         'conditions': [
           [ 'OS=="linux" or OS=="android"', {
             'cflags': [
               '-g',
               '<(moz_debug_flags)',
             ],
           }]
         ],
@@ -453,19 +451,19 @@
           'VCLinkerTool': {
             'LinkIncremental': '1',
           },
           'VCResourceCompilerTool': {
             'PreprocessorDefinitions': ['DEBUG'],
           },
         },
       },
-      # Common settings for release should go here.n
-      'Release_Base': {
-        'abstract': 1,
+      # Common settings for release should go here.
+      'Release': {
+        'inherit_from': ['Common'],
         'defines': [
           'NDEBUG',
         ],
         'xcode_settings': {
           'DEAD_CODE_STRIPPING': 'YES',  # -Wl,-dead_strip
           'GCC_OPTIMIZATION_LEVEL': '2', # -O2
         },
         'msvs_settings': {
@@ -473,34 +471,30 @@
             'Optimization': '2', # /Os
             'RuntimeLibrary': '2', # /MD
           },
           'VCLinkerTool': {
             'LinkIncremental': '1',
           },
         },
       },
-      #
-      # Concrete configurations
-      #
-      # These configurations shouldn't have anything in them, it should
-      # all be derived from the _Base configurations above.
-      'Debug': {
-        'inherit_from': ['Common_Base', 'x86_Base', 'Debug_Base'],
-      },
-      'Release': {
-        'inherit_from': ['Common_Base', 'x86_Base', 'Release_Base'],
-      },
-      # The gyp ninja backend requires these.
-      'Debug_x64': {
-        'inherit_from': ['Common_Base', 'x64_Base', 'Debug_Base'],
-      },
-      'Release_x64': {
-        'inherit_from': ['Common_Base', 'x64_Base', 'Release_Base'],
-      },
+      'conditions': [
+        [ 'OS=="win"', {
+          # The gyp ninja backend requires these.
+          # TODO: either we should support building both 32/64-bit as
+          # configurations from the same gyp build, or we should fix
+          # upstream gyp to not require these.
+          'Debug_x64': {
+            'inherit_from': ['Debug'],
+          },
+          'Release_x64': {
+            'inherit_from': ['Release'],
+          },
+        }],
+      ],
     },
   },
   'conditions': [
     [ 'OS=="linux" or OS=="android"', {
       'variables': {
         'process_map_file': ['/bin/sh', '-c', '/bin/grep -v ";-" >(mapfile) | sed -e "s,;+,," -e "s; DATA ;;" -e "s,;;,," -e "s,;.*,;," > >@(_outputs)'],
       },
     }],
--- a/coreconf/shlibsign.py
+++ b/coreconf/shlibsign.py
@@ -1,9 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 import subprocess
 import sys
@@ -13,15 +13,18 @@ def main():
         if os.path.isfile(lib_file):
             sign(lib_file)
 
 def sign(lib_file):
     ld_lib_path = os.path.realpath(os.path.join(lib_file, '..'))
     bin_path = os.path.realpath(os.path.join(ld_lib_path, '../bin'))
 
     env = os.environ.copy()
-    env['LD_LIBRARY_PATH'] = env['DYLD_LIBRARY_PATH'] = ld_lib_path
+    if sys.platform == 'win32':
+        env['PATH'] = os.pathsep.join((env['PATH'], ld_lib_path))
+    else:
+        env['LD_LIBRARY_PATH'] = env['DYLD_LIBRARY_PATH'] = ld_lib_path
 
     dev_null = open(os.devnull, 'wb')
-    subprocess.Popen([os.path.join(bin_path, 'shlibsign'), '-v', '-i', lib_file], env=env, stdout=dev_null, stderr=dev_null).wait()
+    subprocess.check_call([os.path.join(bin_path, 'shlibsign'), '-v', '-i', lib_file], env=env, stdout=dev_null, stderr=dev_null)
 
 if __name__ == '__main__':
     main()
--- a/lib/freebl/freebl.gyp
+++ b/lib/freebl/freebl.gyp
@@ -284,57 +284,54 @@
       'SHLIB_SUFFIX=\"<(dll_suffix)\"',
       'SHLIB_PREFIX=\"<(dll_prefix)\"',
       'SHLIB_VERSION=\"3\"',
       'SOFTOKEN_SHLIB_VERSION=\"3\"',
       'RIJNDAEL_INCLUDE_TABLES',
       'MP_API_COMPATIBLE'
     ],
     'conditions': [
-      [ 'OS=="win"', {
-        'configurations': {
-          'x86_Base': {
-            'msvs_settings': {
-              'VCCLCompilerTool': {
-                #TODO: -Ox optimize flags
-                'PreprocessorDefinitions': [
-                  'NSS_X86_OR_X64',
-                  'NSS_X86',
-                  'MP_ASSEMBLY_MULTIPLY',
-                  'MP_ASSEMBLY_SQUARE',
-                  'MP_ASSEMBLY_DIV_2DX1D',
-                  'MP_USE_UINT_DIGIT',
-                  'MP_NO_MP_WORD',
-                  'USE_HW_AES',
-                  'INTEL_GCM',
-                ],
-              },
-            },
-          },
-          'x64_Base': {
-            'msvs_settings': {
-              'VCCLCompilerTool': {
-                #TODO: -Ox optimize flags
-                'PreprocessorDefinitions': [
-                  'NSS_USE_64',
-                  'NSS_X86_OR_X64',
-                  'NSS_X64',
-                  'MP_IS_LITTLE_ENDIAN',
-                  'NSS_BEVAND_ARCFOUR',
-                  'MPI_AMD64',
-                  'MP_ASSEMBLY_MULTIPLY',
-                  'NSS_USE_COMBA',
-                  'USE_HW_AES',
-                  'INTEL_GCM',
-                ],
-              },
-            },
+      [ 'OS=="win" and target_arch=="ia32"', {
+        'msvs_settings': {
+          'VCCLCompilerTool': {
+            #TODO: -Ox optimize flags
+            'PreprocessorDefinitions': [
+              'NSS_X86_OR_X64',
+              'NSS_X86',
+              'MP_ASSEMBLY_MULTIPLY',
+              'MP_ASSEMBLY_SQUARE',
+              'MP_ASSEMBLY_DIV_2DX1D',
+              'MP_USE_UINT_DIGIT',
+              'MP_NO_MP_WORD',
+              'USE_HW_AES',
+              'INTEL_GCM',
+            ],
           },
         },
-      }, {
+      }],
+      [ 'OS=="win" and target_arch=="x64"', {
+        'msvs_settings': {
+          'VCCLCompilerTool': {
+            #TODO: -Ox optimize flags
+            'PreprocessorDefinitions': [
+              'NSS_USE_64',
+              'NSS_X86_OR_X64',
+              'NSS_X64',
+              'MP_IS_LITTLE_ENDIAN',
+              'NSS_BEVAND_ARCFOUR',
+              'MPI_AMD64',
+              'MP_ASSEMBLY_MULTIPLY',
+              'NSS_USE_COMBA',
+              'USE_HW_AES',
+              'INTEL_GCM',
+            ],
+          },
+        },
+      }],
+      [ 'OS!="win"', {
         'conditions': [
           [ 'target_arch=="x64"', {
             'defines': [
               'NSS_USE_64',
               'NSS_X86_OR_X64',
               'NSS_X64',
               # The Makefile does version-tests on GCC, but we're not doing that here.
               'HAVE_INT128_SUPPORT',
@@ -387,18 +384,14 @@
               'MP_ASSEMBLY_MULTIPLY',
               'MP_ASSEMBLY_SQUARE',
               'MP_USE_UINT_DIGIT',
               'SHA_NO_LONG_LONG',
             ],
           }],
         ],
       }],
-      [ 'OS=="mac"', {
-      }],
-      [ 'OS=="win"', {
-      }],
     ],
   },
   'variables': {
     'module': 'nss',
   }
 }
--- a/nss.gyp
+++ b/nss.gyp
@@ -128,16 +128,17 @@
       'target_name': 'nss_sign_shared_libs',
       'type': 'none',
       'dependencies': [
         'cmd/shlibsign/shlibsign.gyp:shlibsign',
       ],
       'actions': [
         {
           'action_name': 'shlibsign',
+          'msvs_cygwin_shell': 0,
           'inputs': [
             '<(nss_dist_obj_dir)/lib/<(dll_prefix)freebl3.<(dll_suffix)',
             '<(nss_dist_obj_dir)/lib/<(dll_prefix)freeblpriv3.<(dll_suffix)',
             '<(nss_dist_obj_dir)/lib/<(dll_prefix)nssdbm3.<(dll_suffix)',
             '<(nss_dist_obj_dir)/lib/<(dll_prefix)softokn3.<(dll_suffix)',
           ],
           'outputs': [
             '<(nss_dist_obj_dir)/lib/<(dll_prefix)freebl3.chk',