Bug 1312397 - add test builds to gyp, r=ttaubert
authorFranziskus Kiefer <franziskuskiefer@gmail.com>
Mon, 24 Oct 2016 11:22:08 +0200
changeset 12752 eb5f08064c096a888dbfd67828e5c8aaa99c9f7f
parent 12751 cbeabbf0fb44ae6341996a91d51d20ccf53b5ff0
child 12753 a821e4cd9ddc2cd4f16ceaa997d468228ed93272
push id1694
push userfranziskuskiefer@gmail.com
push dateMon, 24 Oct 2016 12:58:17 +0000
reviewersttaubert
bugs1312397
Bug 1312397 - add test builds to gyp, r=ttaubert
build.sh
cmd/lib/lib.gyp
coreconf/config.gypi
lib/freebl/freebl.gyp
--- a/build.sh
+++ b/build.sh
@@ -2,32 +2,34 @@
 # This script builds NSS with gyp and ninja.
 #
 # This build system is still under development.  It does not yet support all
 # the features or platforms that NSS supports.
 #
 # -c = clean before build
 # -g = force a rebuild of gyp (and NSPR, because why not)
 # -v = verbose build
+# --test = ignore map files and export everything we have
 
 set -e
 
 CWD=$(cd $(dirname $0); pwd -P)
 OBJ_DIR=$(make -s -C "$CWD" platform)
 DIST_DIR="$CWD/../dist/$OBJ_DIR"
 
 if [ -n "$CCC" ] && [ -z "$CXX" ]; then
     export CXX="$CCC"
 fi
 
 while [ $# -gt 0 ]; do
     case $1 in
         -c) CLEAN=1 ;;
         -g) REBUILD_GYP=1 ;;
         -v) VERBOSE=1 ;;
+        --test) GYP_PARAMS="$GYP_PARAMS -Dtest_build=1" ;;
     esac
     shift
 done
 
 # -c = clean first
 if [ "$CLEAN" = 1 ]; then
     rm -rf "$CWD/out"
 fi
@@ -35,17 +37,17 @@ fi
 if [ "$BUILD_OPT" = "1" ]; then
     TARGET=Release
 else
     TARGET=Debug
 fi
 if [ "$USE_64" == "1" ]; then
     TARGET="${TARGET}_x64"
 else
-    GYP_PARAMS="-Dtarget_arch=ia32"
+    GYP_PARAMS="$GYP_PARAMS -Dtarget_arch=ia32"
 fi
 TARGET_DIR="$CWD/out/$TARGET"
 
 # These steps can take a while, so don't overdo them.
 # Force a redo with -g.
 if [ "$REBUILD_GYP" = 1 -o ! -d "$TARGET_DIR" ]; then
     # Build NSPR.
     make -C "$CWD" NSS_GYP=1 install_nspr
--- a/cmd/lib/lib.gyp
+++ b/cmd/lib/lib.gyp
@@ -4,16 +4,17 @@
 {
   'includes': [
     '../../coreconf/config.gypi'
   ],
   'targets': [
     {
       'target_name': 'sectool',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'sources': [
         'basicutil.c',
         'derprint.c',
         'ffs.c',
         'moreoids.c',
         'pk11table.c',
         'pppolicy.c',
         'secpwd.c',
--- a/coreconf/config.gypi
+++ b/coreconf/config.gypi
@@ -92,86 +92,95 @@
     'disable_dbm%': 0,
     'disable_libpkix%': 0,
     'disable_werror%': 0,
     'mozilla_client%': 0,
     'moz_fold_libs%': 0,
     'moz_folded_library_name%': '',
     'ssl_enable_zlib%': 1,
     'use_asan%': 0,
+    'test_build%': 0,
   },
   'target_defaults': {
     # Settings specific to targets should go here.
     # This is mostly for linking to libraries.
     'variables': {
       'mapfile%': '',
     },
+    'standalone_static_library': 0,
     'include_dirs': [
       '<(nspr_include_dir)',
       '<(nss_dist_dir)/private/<(module)',
     ],
     'conditions': [
       [ 'OS=="linux"', {
         'libraries': [
           '-lpthread',
           '-ldl',
           '-lc',
         ],
       }],
+      [ 'test_build!=1', {
+        # skip the maps for test builds
+        'target_conditions': [
+          # mapfile handling
+          [ 'mapfile!=""', {
+            # Work around a gyp bug. Fixed upstream but not in Ubuntu packages:
+            # https://chromium.googlesource.com/external/gyp/+/b85ad3e578da830377dbc1843aa4fbc5af17a192%5E%21/
+            'sources': [
+              '<(DEPTH)/coreconf/empty.c',
+            ] ,
+            'xcode_settings': {
+              'OTHER_LDFLAGS': [
+                '-exported_symbols_list',
+                '<(INTERMEDIATE_DIR)/out.>(mapfile)',
+              ],
+            },
+              'conditions': [
+                [ 'OS=="linux" or OS=="android"', {
+                  'ldflags': [
+                    '-Wl,--version-script,<(INTERMEDIATE_DIR)/out.>(mapfile)',
+                  ],
+                }],
+                [ 'OS=="win"', {
+                  # On Windows, .def files are used directly as sources.
+                  'sources': [
+                    '>(mapfile)',
+                  ],
+                }, {
+                  # On other platforms, .def files need processing.
+                  'sources': [
+                    '<(INTERMEDIATE_DIR)/out.>(mapfile)',
+                  ],
+                  'actions': [{
+                    'action_name': 'generate_mapfile',
+                    'inputs': [
+                      '>(mapfile)',
+                    ],
+                    'outputs': [
+                      '<(INTERMEDIATE_DIR)/out.>(mapfile)',
+                    ],
+                    'action': ['<@(process_map_file)'],
+                  }],
+                }]
+              ],
+          }],
+        ],
+      }]
     ],
     'target_conditions': [
-      # If we ever want to properly export a static library, and copy it to lib,
-      # we will need to mark it as a 'standalone_static_library'. Otherwise,
+      # If we want to properly export a static library, and copy it to lib,
+      # we need to mark it as a 'standalone_static_library'. Otherwise,
       # the relative paths in the thin archive will break linking.
       [ '_type=="shared_library"', {
         'product_dir': '<(nss_dist_obj_dir)/lib'
       }, '_type=="executable"', {
         'product_dir': '<(nss_dist_obj_dir)/bin'
-      }],
-      # mapfile handling
-      [ 'mapfile!=""', {
-        # Work around a gyp bug. Fixed upstream but not in Ubuntu packages:
-        # https://chromium.googlesource.com/external/gyp/+/b85ad3e578da830377dbc1843aa4fbc5af17a192%5E%21/
-        'sources': [
-          '<(DEPTH)/coreconf/empty.c',
-        ],
-        'xcode_settings': {
-          'OTHER_LDFLAGS': [
-            '-exported_symbols_list',
-            '<(INTERMEDIATE_DIR)/out.>(mapfile)',
-          ],
-        },
-        'conditions': [
-          [ 'OS=="linux" or OS=="android"', {
-            'ldflags': [
-              '-Wl,--version-script,<(INTERMEDIATE_DIR)/out.>(mapfile)',
-            ],
-          }],
-          [ 'OS=="win"', {
-            # On Windows, .def files are used directly as sources.
-            'sources': [
-              '>(mapfile)',
-            ],
-          }, {
-            # On other platforms, .def files need processing.
-            'sources': [
-              '<(INTERMEDIATE_DIR)/out.>(mapfile)',
-            ],
-            'actions': [{
-              'action_name': 'generate_mapfile',
-              'inputs': [
-                '>(mapfile)',
-              ],
-              'outputs': [
-                '<(INTERMEDIATE_DIR)/out.>(mapfile)',
-              ],
-              'action': ['<@(process_map_file)'],
-            }],
-          }]
-        ],
+      }, '_standalone_static_library==1', {
+        'product_dir': '<(nss_dist_obj_dir)/lib'
       }],
       [ '_type=="shared_library" or _type=="executable"', {
         'libraries': [
           '<@(nspr_libs)',
         ],
         'library_dirs': [
           '<(nspr_lib_dir)',
         ],
--- a/lib/freebl/freebl.gyp
+++ b/lib/freebl/freebl.gyp
@@ -94,16 +94,21 @@
       ],
       'conditions': [
         [ 'OS=="linux"', {
           'sources': [
             'nsslowhash.c',
             'stubs.c',
           ],
           'conditions': [
+            [ 'test_build==1', {
+              'dependencies': [
+                '<(DEPTH)/lib/util/util.gyp:nssutil3',
+              ],
+            }],
             [ 'target_arch=="x64"', {
               'sources': [
                 'arcfour-amd64-gas.s',
                 'intel-aes.s',
                 'intel-gcm.s',
                 'mpi/mpi_amd64.c',
                 'mpi/mpi_amd64_gas.s',
                 'mpi/mp_comba.c',
@@ -243,16 +248,20 @@
   ],
   'conditions': [
     [ 'OS=="linux"', {
       # stub build
       'targets': [
         {
           'target_name': 'freebl3',
           'type': 'shared_library',
+          'defines': [
+            'FREEBL_NO_DEPEND',
+            'FREEBL_LOWHASH',
+          ],
           'sources': [
             'lowhash_vector.c'
           ],
           'dependencies': [
             '<(DEPTH)/exports.gyp:nss_exports'
           ],
           'variables': {
             'mapfile': 'freebl_hash.def'
@@ -334,21 +343,23 @@
             'defines': [
               'NSS_X86_OR_X64',
               'NSS_X86',
             ],
           }],
         ],
       }],
       [ 'OS=="linux"', {
-        'defines': [
-          'FREEBL_NO_DEPEND',
-          'FREEBL_LOWHASH',
-        ],
         'conditions': [
+          [ 'test_build==0', {
+            'defines': [
+              'FREEBL_NO_DEPEND',
+              'FREEBL_LOWHASH',
+            ],
+          }],
           [ 'target_arch=="x64"', {
             'defines': [
               'MP_IS_LITTLE_ENDIAN',
               'NSS_BEVAND_ARCFOUR',
               'MPI_AMD64',
               'MP_ASSEMBLY_MULTIPLY',
               'NSS_USE_COMBA',
               'USE_HW_AES',