Bug 1308463 - Make gyp build system generate chk files r=franziskus
authorTim Taubert <ttaubert@mozilla.com>
Sat, 22 Oct 2016 14:36:26 +0200
changeset 12746 e048d75343c4b8dc26174f14394e09d8b92aff41
parent 12745 d861923a4e5b47d79fac8eaf76beafa4b8e925f7
child 12747 bf02406a181e44814fe39462a6c4b6f84a3c6e1f
push id1688
push userttaubert@mozilla.com
push dateSat, 22 Oct 2016 12:38:34 +0000
reviewersfranziskus
bugs1308463
Bug 1308463 - Make gyp build system generate chk files r=franziskus Differential Revision: https://nss-dev.phacility.com/D107
build.sh
coreconf/shlibsign.py
nss.gyp
--- a/build.sh
+++ b/build.sh
@@ -4,20 +4,24 @@
 # 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)
 
 set -e
 
-CWD=$(realpath $(dirname $0))
-OBJ_DIR=$(make platform)
+CWD=$(cd $(dirname $0); pwd -P)
+OBJ_DIR=$(make -C $CWD platform)
 DIST_DIR="$CWD/../dist/$OBJ_DIR"
 
+if [ -n $CCC ] && [ -z $CXX ]; then
+    export CXX="$CCC"
+fi
+
 # -c = clean first
 if [ "$1" = "-c" ]; then
     rm -rf "$CWD/out"
 fi
 
 if [ "$BUILD_OPT" = "1" ]; then
     TARGET=Release
 else
@@ -44,20 +48,8 @@ if which ninja >/dev/null 2>&1; then
     NINJA=ninja
 elif which ninja-build >/dev/null 2>&1; then
     NINJA=ninja-build
 else
     echo "Please install ninja" 1>&2
     exit 1
 fi
 $NINJA -C "$TARGET_DIR"
-
-# Sign libs.  TODO: get ninja to do this
-echo >"$TARGET_DIR/shlibsign.log"
-for lib in freebl3 freeblpriv3 nssdbm3 softokn3; do
-    if [ ! -e "$DIST_DIR/lib/lib$lib.signed" -o \
-         "$DIST_DIR/lib/lib$lib.so" -nt "$DIST_DIR/lib/lib$lib.signed" ]; then
-        LD_LIBRARY_PATH="$DIST_DIR/lib" DYLD_LIBRARY_PATH="$DIST_DIR/lib" \
-            "$DIST_DIR/bin/shlibsign" -v -i "$DIST_DIR/lib/lib$lib.so" \
-            >>"$TARGET_DIR/shlibsign.log" 2>&1
-        touch "$DIST_DIR/lib/lib$lib.signed"
-    fi
-done
new file mode 100644
--- /dev/null
+++ b/coreconf/shlibsign.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+#
+# 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
+
+def main():
+    for lib_file in sys.argv[1:]:
+        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
+
+    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()
+
+if __name__ == '__main__':
+    main()
--- a/nss.gyp
+++ b/nss.gyp
@@ -119,16 +119,47 @@
             'cmd/signver/signver.gyp:signver',
             'cmd/smimetools/smimetools.gyp:cmsutil',
             'cmd/ssltap/ssltap.gyp:ssltap',
             'cmd/symkeyutil/symkeyutil.gyp:symkeyutil',
           ],
         }],
       ],
     },
+    {
+      'target_name': 'nss_sign_shared_libs',
+      'type': 'none',
+      'dependencies': [
+        'cmd/shlibsign/shlibsign.gyp:shlibsign',
+      ],
+      'actions': [
+        {
+          'action_name': 'shlibsign',
+          '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',
+            '<(nss_dist_obj_dir)/lib/<(dll_prefix)freeblpriv3.chk',
+            '<(nss_dist_obj_dir)/lib/<(dll_prefix)nssdbm3.chk',
+            '<(nss_dist_obj_dir)/lib/<(dll_prefix)softokn3.chk'
+          ],
+          'conditions': [
+            ['OS!="linux"', {
+              'inputs/': [['exclude', 'freeblpriv']],
+              'outputs/': [['exclude', 'freeblpriv']]
+            }],
+          ],
+          'action': ['<(python)', '<(DEPTH)/coreconf/shlibsign.py', '<@(_inputs)']
+        }
+      ],
+    },
   ],
   'conditions': [
     [ 'disable_tests==0', {
       'targets': [
         {
           'target_name': 'nss_tests',
           'type': 'none',
           'dependencies': [